|
|
@ -70,7 +70,6 @@ |
|
|
|
from __future__ import print_function |
|
|
|
from __future__ import print_function |
|
|
|
import sys, re, os |
|
|
|
import sys, re, os |
|
|
|
from templates import * |
|
|
|
from templates import * |
|
|
|
from sets import Set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info[0] >= 3: |
|
|
|
if sys.version_info[0] >= 3: |
|
|
|
from io import StringIO |
|
|
|
from io import StringIO |
|
|
@ -185,7 +184,7 @@ class ClassInfo(object): |
|
|
|
self.consts = {} |
|
|
|
self.consts = {} |
|
|
|
customname = False |
|
|
|
customname = False |
|
|
|
self.jsfuncs = {} |
|
|
|
self.jsfuncs = {} |
|
|
|
self.constructor_arg_num = Set() |
|
|
|
self.constructor_arg_num = set() |
|
|
|
|
|
|
|
|
|
|
|
self.has_smart_ptr = False |
|
|
|
self.has_smart_ptr = False |
|
|
|
|
|
|
|
|
|
|
@ -369,14 +368,23 @@ class JSWrapperGenerator(object): |
|
|
|
return namespace, classes, chunks[-1] |
|
|
|
return namespace, classes, chunks[-1] |
|
|
|
|
|
|
|
|
|
|
|
def add_enum(self, decl): |
|
|
|
def add_enum(self, decl): |
|
|
|
name = decl[1] |
|
|
|
name = decl[0].rsplit(" ", 1)[1] |
|
|
|
namespace, classes, val = self.split_decl_name(name) |
|
|
|
namespace, classes, val = self.split_decl_name(name) |
|
|
|
namespace = '.'.join(namespace) |
|
|
|
namespace = '.'.join(namespace) |
|
|
|
|
|
|
|
ns = self.namespaces.setdefault(namespace, Namespace()) |
|
|
|
|
|
|
|
if len(name) == 0: name = "<unnamed>" |
|
|
|
|
|
|
|
if name.endswith("<unnamed>"): |
|
|
|
|
|
|
|
i = 0 |
|
|
|
|
|
|
|
while True: |
|
|
|
|
|
|
|
i += 1 |
|
|
|
|
|
|
|
candidate_name = name.replace("<unnamed>", "unnamed_%u" % i) |
|
|
|
|
|
|
|
if candidate_name not in ns.enums: |
|
|
|
|
|
|
|
name = candidate_name |
|
|
|
|
|
|
|
break; |
|
|
|
val = '_'.join(classes + [name]) |
|
|
|
val = '_'.join(classes + [name]) |
|
|
|
cname = name.replace('.', '::') |
|
|
|
cname = name.replace('.', '::') |
|
|
|
ns = self.namespaces.setdefault(namespace, Namespace()) |
|
|
|
|
|
|
|
if name in ns.enums: |
|
|
|
if name in ns.enums: |
|
|
|
print("Generator warning: constant %s (cname=%s) already exists" \ |
|
|
|
print("Generator warning: enum %s (cname=%s) already exists" \ |
|
|
|
% (name, cname)) |
|
|
|
% (name, cname)) |
|
|
|
# sys.exit(-1) |
|
|
|
# sys.exit(-1) |
|
|
|
else: |
|
|
|
else: |
|
|
@ -384,6 +392,12 @@ class JSWrapperGenerator(object): |
|
|
|
for item in decl[3]: |
|
|
|
for item in decl[3]: |
|
|
|
ns.enums[name].append(item) |
|
|
|
ns.enums[name].append(item) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const_decls = decl[3] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for decl in const_decls: |
|
|
|
|
|
|
|
name = decl[0] |
|
|
|
|
|
|
|
self.add_const(name.replace("const ", "").strip(), decl) |
|
|
|
|
|
|
|
|
|
|
|
def add_const(self, name, decl): |
|
|
|
def add_const(self, name, decl): |
|
|
|
cname = name.replace('.','::') |
|
|
|
cname = name.replace('.','::') |
|
|
|
namespace, classes, name = self.split_decl_name(name) |
|
|
|
namespace, classes, name = self.split_decl_name(name) |
|
|
@ -803,7 +817,7 @@ class JSWrapperGenerator(object): |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
# Generate bindings for methods |
|
|
|
# Generate bindings for methods |
|
|
|
for method_name, method in class_info.methods.iteritems(): |
|
|
|
for method_name, method in class_info.methods.items(): |
|
|
|
if method.cname in ignore_list: |
|
|
|
if method.cname in ignore_list: |
|
|
|
continue |
|
|
|
continue |
|
|
|
if not method.name in white_list[method.class_name]: |
|
|
|
if not method.name in white_list[method.class_name]: |
|
|
@ -833,7 +847,7 @@ class JSWrapperGenerator(object): |
|
|
|
class_bindings.append(smart_ptr_reg_template.substitute(cname=class_info.cname, name=class_info.name)) |
|
|
|
class_bindings.append(smart_ptr_reg_template.substitute(cname=class_info.cname, name=class_info.name)) |
|
|
|
|
|
|
|
|
|
|
|
# Attach external constructors |
|
|
|
# Attach external constructors |
|
|
|
# for method_name, method in class_info.ext_constructors.iteritems(): |
|
|
|
# for method_name, method in class_info.ext_constructors.items(): |
|
|
|
# print("ext constructor", method_name) |
|
|
|
# print("ext constructor", method_name) |
|
|
|
#if class_info.ext_constructors: |
|
|
|
#if class_info.ext_constructors: |
|
|
|
|
|
|
|
|
|
|
|