Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

makes the script more generic

  • Loading branch information...
commit c15a9fa5cb8e8f25f304d4643d14c581f05b3c0b 1 parent 14435ed
@funkaster authored
Showing with 14 additions and 4 deletions.
  1. +14 −4 js/generate_bindings.rb
View
18 js/generate_bindings.rb
@@ -87,8 +87,9 @@ def convert_arguments_and_call(str, indent_level = 0)
args_str << @klass.generator.arg_format(arg, type)
# fundamental type
if type[:fundamental] && !type[:pointer]
- # fix for JS_ConvertArguments (it only accepts doubles)
+ # fix for JS_ConvertArguments (it only accepts doubles and JSBool for booleans)
type[:name] = "double" if type[:name] == "float"
+ type[:name] = "JSBool" if type[:name] == "bool"
str << "#{indent}\t#{type[:name]} arg#{i};\n"
call_params << [type[:name], "arg#{i}"]
convert_params << "&arg#{i}"
@@ -274,7 +275,7 @@ def initialize(node, bindings_generator)
next if @name == "CCTextureCache" && method['name'] == "addImageAsync"
# mark as singleton (produce no constructor code)
- @singleton = true if method['name'].match(/^shared.*#{prefixless_name}/i)
+ @singleton = true if method['name'].match(/^shared.*/i)
# the accessors
if method['static'] != "1" && md = method['name'].match(/(get|set)(\w+)/)
@@ -868,6 +869,7 @@ def initialize(doc, out_prefix)
@const_volatile = {}
@typedefs = {}
+ extra_include = (!ARGV[0].match(/cocos2d\.h/) ? "#include \"#{File.basename(ARGV[0], ".xml")}.h\"\n#include \"cocos2d_generated.hpp\"" : "")
@out_header.puts <<-EOS
#ifndef __#{out_prefix}__h
@@ -875,9 +877,14 @@ def initialize(doc, out_prefix)
#include "ScriptingCore.h"
#include "cocos2d.h"
+#{extra_include}
using namespace cocos2d;
+ EOS
+ # only print this for cocos2d header
+ if ARGV[0].match(/cocos2d\.h/)
+ @out_header.puts <<-EOS
typedef struct {
\tuint32_t flags;
\tvoid* data;
@@ -886,7 +893,9 @@ def initialize(doc, out_prefix)
typedef enum {
\tkPointerTemporary = 1
} pointerShellFlags;
-
+ EOS
+ end
+ @out_header.puts <<-EOS
#define JSGET_PTRSHELL(type, cobj, jsobj) do { \\
\tpointerShell_t *pt = (pointerShell_t *)JS_GetPrivate(jsobj); \\
\tif (pt) { \\
@@ -1163,7 +1172,8 @@ def find_missing_dependencies
end
def instantiate_class_generators
- green_lighted = %w(CCPoint CCSize _ccGridSize CCRect CCDirector CCNode CCSprite CCScene CCSpriteFrameCache
+ green_lighted = ENV['CCX_CLASSES'] ? ENV['CCX_CLASSES'].split(':') :
+ %w(CCPoint CCSize _ccGridSize CCRect CCDirector CCNode CCSprite CCScene CCSpriteFrameCache
CCSpriteFrame CCAction CCAnimate CCAnimation CCRepeatForever CCLayer CCTouch
CCSet CCMoveBy CCMoveTo CCRotateTo CCRotateBy CCRenderTexture CCMenu CCMenuItem
CCMenuItemLabel CCMenuItemSprite CCMenuItemImage CCLabelTTF CCSequence
Please sign in to comment.
Something went wrong with that request. Please try again.