[Tool][Generator] define native parameter on async,sync native call
authorpius.lee <pius.lee@samsung.com>
Sun, 18 Jan 2015 00:56:06 +0000 (09:56 +0900)
committerpius.lee <pius.lee@samsung.com>
Sun, 18 Jan 2015 00:58:02 +0000 (09:58 +0900)
Change-Id: Ief0c4c8750c33533af06719aed9e5d98282d8983
Signed-off-by: pius.lee <pius.lee@samsung.com>
tools/skeleton_generator/tpl/tpl_api.js

index 03eda48da2ee2f739852783aae64b15abebedab0..a055e14a913721713f38c3403519d87008535648 100644 (file)
@@ -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);