From 672ed6ed0c69c71a4589b6a3b7b74b5caa7ba1ea Mon Sep 17 00:00:00 2001 From: Martin Carlberg Date: Mon, 12 Aug 2013 22:41:36 +0200 Subject: [PATCH] Fixed: Handle protocol declaration with no method declarations --- Objective-J/ObjJAcornCompiler.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Objective-J/ObjJAcornCompiler.js b/Objective-J/ObjJAcornCompiler.js index 441ee1c78..099bc04d9 100644 --- a/Objective-J/ObjJAcornCompiler.js +++ b/Objective-J/ObjJAcornCompiler.js @@ -1857,18 +1857,21 @@ ProtocolDeclarationStatement: function(node, st, c) { compiler.protocolDefs[protocolName] = protocolDef; protocolScope.protocolDef = protocolDef; - var someRequired = node.required, - requiredLength = someRequired.length; + var someRequired = node.required; - if (requiredLength > 0) - { - // We only add the required methods - for (var i = 0; i < requiredLength; ++i) { - var required = someRequired[i]; - if (!generate) compiler.lastPos = required.start; - c(required, protocolScope, "Statement"); + if (someRequired) { + var requiredLength = someRequired.length; + + if (requiredLength > 0) + { + // We only add the required methods + for (var i = 0; i < requiredLength; ++i) { + var required = someRequired[i]; + if (!generate) compiler.lastPos = required.start; + c(required, protocolScope, "Statement"); + } + if (!generate) buffer.concat(compiler.source.substring(compiler.lastPos, required.end)); } - if (!generate) buffer.concat(compiler.source.substring(compiler.lastPos, required.end)); } buffer.concat("\nobjc_registerProtocol(the_protocol);\n");