From: pius.lee Date: Sun, 18 Jan 2015 00:56:06 +0000 (+0900) Subject: [Tool][Generator] define native parameter on async,sync native call X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~607 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e34215289459e0219de770d967c3e14fbcd363ad;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Tool][Generator] define native parameter on async,sync native call Change-Id: Ief0c4c8750c33533af06719aed9e5d98282d8983 Signed-off-by: pius.lee --- diff --git a/tools/skeleton_generator/tpl/tpl_api.js b/tools/skeleton_generator/tpl/tpl_api.js index 03eda48d..a055e14a 100644 --- a/tools/skeleton_generator/tpl/tpl_api.js +++ b/tools/skeleton_generator/tpl/tpl_api.js @@ -180,7 +180,6 @@ function {{iface.name}}( ]); {% endif %} - {% if operation.arguments %} var nativeParam = { {% for arg in operation.primitiveArgs if not arg.optional %} '{{arg.name}}': args.{{arg.name}}{% if not loop.last %},{% endif %} @@ -193,34 +192,32 @@ function {{iface.name}}( nativeParam['{{arg.name}}'] = args.{{arg.name}}; } {% endfor %} - {% endif %} - {% set successcbs = [] %} - {% set errorcbs = [] %} + try { {% if operation.async %} var syncResult = callNativeWithCallback('{{operation.native_cmd}}', nativeParam, function(result) { - {% for arg in operation.arguments %} - {% if arg.isListener %} - {% set cb = callbacks[arg.xtype.name] %} - {% if cb.callbackType in ['success', 'error'] %} + {% for arg in operation.arguments %} + {% if arg.isListener %} + {% set cb = callbacks[arg.xtype.name] %} + {% if cb.callbackType in ['success', 'error'] %} if (result.status === '{{cb.callbackType}}') { - {% if arg.optional %} + {% if arg.optional %} if (args.{{arg.name}}) { args.{{arg.name}}.on{{cb.callbackType}}(/* {{cb.callbackType}} argument */); } - {% else %} + {% else %} args.{{arg.name}}.on{{cb.callbackType}}(/* {{cb.callbackType}} argument */); - {% endif %} + {% endif %} } - {% else %} - {% for cbmethod in cb.getTypes('Operation') %} + {% else %} + {% for cbmethod in cb.getTypes('Operation') %} if ( /* put some condition and delete true -> */true) { args.{{arg.name}}.{{cbmethod.name}}(/* some argument for {{cbmethod.name}} */); } + {% endfor %} + {% endif %} + {% endif %} {% endfor %} - {% endif %} - {% endif %} - {% endfor %} }); {% else %} var syncResult = callNative('{{operation.native_cmd}}', nativeParam);