From ffa8e7dbc862ecffd5ec722d348d6300c43ccdc3 Mon Sep 17 00:00:00 2001 From: Rafal Galka Date: Thu, 8 Jan 2015 10:55:23 +0100 Subject: [PATCH] [Tool] Skeleton generator moved to subdirectory Change-Id: Ifda10be187799bf71a719f4b4706b6803f697729 --- tools/{ => skeleton_generator}/WAPIOven.py | 30 +++++++++---------- tools/{ => skeleton_generator}/WebIDL.py | 34 +++++++++++----------- tools/{ => skeleton_generator}/tpl/tpl_api.js | 16 ++++++---- .../{ => skeleton_generator}/tpl/tpl_extension.cc | 0 tools/{ => skeleton_generator}/tpl/tpl_extension.h | 0 tools/{ => skeleton_generator}/tpl/tpl_instance.cc | 6 ++-- tools/{ => skeleton_generator}/tpl/tpl_instance.h | 0 7 files changed, 45 insertions(+), 41 deletions(-) rename tools/{ => skeleton_generator}/WAPIOven.py (94%) rename tools/{ => skeleton_generator}/WebIDL.py (98%) rename tools/{ => skeleton_generator}/tpl/tpl_api.js (97%) rename tools/{ => skeleton_generator}/tpl/tpl_extension.cc (100%) rename tools/{ => skeleton_generator}/tpl/tpl_extension.h (100%) rename tools/{ => skeleton_generator}/tpl/tpl_instance.cc (99%) rename tools/{ => skeleton_generator}/tpl/tpl_instance.h (100%) diff --git a/tools/WAPIOven.py b/tools/skeleton_generator/WAPIOven.py similarity index 94% rename from tools/WAPIOven.py rename to tools/skeleton_generator/WAPIOven.py index 40cb50c..5b7bf4b 100644 --- a/tools/WAPIOven.py +++ b/tools/skeleton_generator/WAPIOven.py @@ -6,16 +6,16 @@ import jinja2 cppPrimitiveMap = { 'DOMString':'std::string', 'object':'picojson::object', - 'boolean':'bool', - 'byte':'double', - 'octet':'double', - 'short':'double', - 'long':'double', + 'boolean':'bool', + 'byte':'double', + 'octet':'double', + 'short':'double', + 'long':'double', 'long long': 'double', 'unsigned short': 'double', 'unsigned long': 'double', 'unsigned long long': 'double', - 'float':'double', + 'float':'double', 'double':'double'} class IndentPrintable(object): @@ -113,10 +113,10 @@ class Compiler(IndentPrintable): t = self.ctx['typedef'][arg.xtype.name] if t.union: union_names = [t.name for t in t.union] - arg.isEnum = reduce(lambda x, y: x & y, [ x in self.ctx['enum'] for x in union_names]) + arg.isEnum = reduce(lambda x, y: x & y, [ x in self.ctx['enum'] for x in union_names]) if arg.isEnum : arg.enums = reduce(lambda x,y: x+y, [ self.ctx['enum'][x] for x in self.ctx['enum'] if x in union_names]) - arg.isTypes = reduce(lambda x, y: x & y, [ x in m.getTypes('Interface') for x in union_names]) + arg.isTypes = reduce(lambda x, y: x & y, [ x in m.getTypes('Interface') for x in union_names]) if arg.xtype.name in self.ctx['callback']: arg.isListener = True arg.listenerType = self.ctx['callback'][arg.xtype.name] @@ -167,7 +167,7 @@ class Compiler(IndentPrintable): if isinstance(x, WebIDL.XTypedef): self.ctx['typedef'][x.name] = x.xtype - + if isinstance(x, WebIDL.XEnum): self.ctx['enum'][x.name] = x.childs @@ -181,8 +181,8 @@ class Compiler(IndentPrintable): self.prepare() tpl = self.tplEnv.get_template(Compiler.TPL_API_JS) - return tpl.render({'modules':self.tree, - 'callbacks':self.ctx['callback'], + return tpl.render({'modules':self.tree, + 'callbacks':self.ctx['callback'], 'tizen': self.ctx['Tizen'], 'window': self.ctx['Window'], 'cmdtable' : self.ctx['cmdtable']}) @@ -200,9 +200,9 @@ class Compiler(IndentPrintable): instance_cc = self.makeCppStub(module, Compiler.TPL_INSTANCE_CC) return { - module+'_extension.h':extension_h, - module+'_extension.cc':extension_cc, - module+'_instance.h':instance_h, + module+'_extension.h':extension_h, + module+'_extension.cc':extension_cc, + module+'_instance.h':instance_h, module+'_instance.cc':instance_cc} def makeCppStub(self, module, tpl_file): @@ -285,7 +285,7 @@ if __name__ == '__main__': if only != 'cpp': print jscode pass - + if only != 'js': for cc in cppcode: print cppcode[cc] diff --git a/tools/WebIDL.py b/tools/skeleton_generator/WebIDL.py similarity index 98% rename from tools/WebIDL.py rename to tools/skeleton_generator/WebIDL.py index 2524129..31aeef1 100644 --- a/tools/WebIDL.py +++ b/tools/skeleton_generator/WebIDL.py @@ -22,7 +22,7 @@ class XObject(object): def add(self, child): if isinstance(child, XObject): - type = child.type + type = child.type child.parent = self else: type = 'string' @@ -387,7 +387,7 @@ class Parser: z = 0 if t.value[0] == '-': z = 1 - + if len(t.value) > 1 and t.value[z] == '0' and (t.value[z+1] == 'x' or t.value[z+1] == 'X'): if t.value[z+2:].find('8') and t.value[z+2:].find('9'): t.value = int(t.value, 8) @@ -490,7 +490,7 @@ class Parser: def p_PartialDefinition(self, p): ''' - PartialDefinition : PartialInterface + PartialDefinition : PartialInterface | PartialDictionary ''' p[0] = p[1] @@ -595,7 +595,7 @@ class Parser: EnumValues : "," string EnumValues | Empty ''' - if len(p) > 2: + if len(p) > 2: p[0] = [p[2]] + p[3] else: p[0] = [] @@ -894,19 +894,19 @@ class Parser: def p_Other(self, p): ''' Other : integer - | float - | identifier - | string - | other - | "-" - | "." + | float + | identifier + | string + | other + | "-" + | "." | ellipsis - | ":" - | ";" - | "<" - | "=" - | ">" - | "?" + | ":" + | ";" + | "<" + | "=" + | ">" + | "?" | Date | DOMString | Infinity @@ -1088,7 +1088,7 @@ class Parser: typename = p[1] if p[1] != 'unsigned' else p[2] p[0] = XType(typename, None, 0, False, False, p[1] == 'unsigned') - + def p_IntegerType(self, p): ''' IntegerType : short diff --git a/tools/tpl/tpl_api.js b/tools/skeleton_generator/tpl/tpl_api.js similarity index 97% rename from tools/tpl/tpl_api.js rename to tools/skeleton_generator/tpl/tpl_api.js index 34b2198..5da5cc8 100644 --- a/tools/tpl/tpl_api.js +++ b/tools/skeleton_generator/tpl/tpl_api.js @@ -83,7 +83,8 @@ function SetReadOnlyProperty(obj, n, v){ {% for enums in module.getTypes('Enum') %} var {{enums.name}} = { {% for e in enums.childs %} - '{{e}}': '{{e}}'{% if not loop.last %}, {% endif %} + '{{e}}': '{{e}}'{% if not loop.last %}, {% endif %} + {% endfor %} }; {% endfor %} @@ -103,7 +104,7 @@ function {{iface.name}}() { {{iface.name}}.prototype.{{operation.name}} = function( {%- for arg in operation.arguments -%} {%- if not arg.optional -%} - {%- if not loop.first %}, {% endif -%} + {%- if not loop.first %}, {% endif -%} {{arg.name}} {%- endif -%} {%- endfor %}) { @@ -138,7 +139,8 @@ function {{iface.name}}() { {%- endif -%} {%- if arg.optional -%}, optional : true{% endif -%} {%- if arg.xtype.nullable -%}, nullable : true{% endif -%} - }{% if not loop.last %}, {% endif %} + }{% if not loop.last %}, {% endif %} + {% endfor %} ]); {% endif %} @@ -202,19 +204,21 @@ function {{iface.name}}() { {{attribute.name}}); // read only property {%- else -%} null); // read only property - {%- endif %} + {%- endif %} + {% else %} returnObject.{{attribute.name}} = {% if attribute.name in operation.argnames -%} {{attribute.name}}; {%- else -%} null; - {%- endif %} + {%- endif %} + {% endif %} {% endfor %} return returnObject; {% endif %} -} +}; {% endfor %} diff --git a/tools/tpl/tpl_extension.cc b/tools/skeleton_generator/tpl/tpl_extension.cc similarity index 100% rename from tools/tpl/tpl_extension.cc rename to tools/skeleton_generator/tpl/tpl_extension.cc diff --git a/tools/tpl/tpl_extension.h b/tools/skeleton_generator/tpl/tpl_extension.h similarity index 100% rename from tools/tpl/tpl_extension.h rename to tools/skeleton_generator/tpl/tpl_extension.h diff --git a/tools/tpl/tpl_instance.cc b/tools/skeleton_generator/tpl/tpl_instance.cc similarity index 99% rename from tools/tpl/tpl_instance.cc rename to tools/skeleton_generator/tpl/tpl_instance.cc index 511b05b..ed18fce 100644 --- a/tools/tpl/tpl_instance.cc +++ b/tools/skeleton_generator/tpl/tpl_instance.cc @@ -46,11 +46,11 @@ enum {{module.title}}Callbacks { {% endfor %} }; -static void ReplyAsync({{module.title}}Instance* instance, {{module.title}}Callbacks cbfunc, +static void ReplyAsync({{module.title}}Instance* instance, {{module.title}}Callbacks cbfunc, int callbackId, bool isSuccess, picojson::object& param) { param["callbackId"] = picojson::value(static_cast(callbackId)); param["status"] = picojson::value(isSuccess ? "success" : "error"); - + // insert result for async callback to param switch(cbfunc) { {% for iface in moduleObj.getTypes('Interface') %} @@ -70,7 +70,7 @@ static void ReplyAsync({{module.title}}Instance* instance, {{module.title}}Callb } picojson::value result = picojson::value(param); - + instance->PostMessage(result.serialize().c_str()); } {% endif %} diff --git a/tools/tpl/tpl_instance.h b/tools/skeleton_generator/tpl/tpl_instance.h similarity index 100% rename from tools/tpl/tpl_instance.h rename to tools/skeleton_generator/tpl/tpl_instance.h -- 2.7.4