]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - forb-idl/forb-idl-c-stubs.c
IDL compiler: Invoke methods directly only within the same executor
[frescor/forb.git] / forb-idl / forb-idl-c-stubs.c
index 150ccf6fd392e7386fada0ac7e1541b30d800a6e..6405e32aa4b544b0bc0606b12c4361ca0c25b1d2 100644 (file)
@@ -44,9 +44,10 @@ cs_output_stub (IDL_tree     tree,
 /*             fprintf(of, "    return "FORB_RETVAL_VAR_NAME";\n"); */
 /*     } */
         fprintf(of, "  if (ev) ev->major = FORB_EX_NONE;\n");
-        fprintf(of, "  if (forb_object_is_local(_obj)) {\n");
+        fprintf(of, "  if (forb_object_is_local(_obj) &&\n"
+                          "forb_get_current_executor() == forb_object_get_executor(_obj)) {\n");
         fprintf(of, "    if (!_obj->interface ||\n"
-                    "        strncmp(_obj->interface->name, \"%s\", %d) != 0) {\n"
+                    "        strncmp(_obj->interface->name, \"%s\", %zd) != 0) {\n"
                     "      ev->major = FORB_EX_BAD_OPERATION;\n"
                     "      return %s;\n"
                     "    }\n", iface_id, strlen(iface_id), has_retval ? FORB_RETVAL_VAR_NAME : "");
@@ -68,7 +69,7 @@ cs_output_stub (IDL_tree     tree,
        fprintf(of, "    ex_on_fail(forb_request_init(&req, _obj) == 0, FORB_EX_INTERNAL);\n");
        fprintf(of, "    forb_iop_prepare_request(&req, \"%s\", FORB_METHOD_INDEX(%s), ev);\n",
                iface_id, opname);
-       fprintf(of, "    if (forb_exception_occured(ev)) goto exception;\n");
+       fprintf(of, "    if (forb_exception_occurred(ev)) goto exception;\n");
        for (sub = IDL_OP_DCL (tree).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
                IDL_tree        parm = IDL_LIST (sub).data;
                IDL_ParamRole   role;
@@ -85,9 +86,9 @@ cs_output_stub (IDL_tree     tree,
                }
        }
        fprintf(of, "    forb_request_send(&req, ev);\n");
-       fprintf(of, "    if (forb_exception_occured(ev)) goto exception;\n");
+       fprintf(of, "    if (forb_exception_occurred(ev)) goto exception;\n");
        fprintf(of, "    forb_request_wait_for_reply(&req);\n");
-       fprintf(of, "    if (forb_exception_occured(ev)) goto exception;\n");
+       fprintf(of, "    if (forb_exception_occurred(ev)) goto exception;\n");
        if (has_retval) {
          fprintf(of, "    ");
          forb_cbe_write_typespec(of, IDL_OP_DCL(tree).op_type_spec);
@@ -102,13 +103,17 @@ cs_output_stub (IDL_tree     tree,
                  gboolean  isSlice;
                  IDL_tree  ts = forb_cbe_get_typespec(parm);
                  int       n = oidl_param_info (ts, role, &isSlice);
+                 if (IDL_NODE_TYPE(forb_cbe_get_typespec(parm)) == IDLN_TYPE_SEQUENCE &&
+                     role == DATA_OUT) { /* Allocate out sequence */
+                         fprintf(ci->fh, "    *%s = forb_malloc(sizeof(**%s));\n", name, name);
+                         fprintf(ci->fh, "    if (!*%s) { ev->major = FORB_EX_NO_MEMORY; goto exception; }\n", name);
+                         fprintf(ci->fh, "    memset(*%s, 0, sizeof(**%s));\n", name, name);
+                         fprintf(ci->fh, "    CORBA_sequence_set_release(*%s, CORBA_TRUE);\n", name);
+                         /* TODO: Free previously allocated parameters on no memory error. */
+                 }
                  fprintf(of, "    ");
                  forb_cbe_write_typespec(of, IDL_PARAM_DCL(parm).param_type_spec);
-                 if (IDL_NODE_TYPE(forb_cbe_get_typespec(parm)) == IDLN_INTERFACE) {
-                         fprintf(ci->fh, "_deserialize(req.cdr_reply, %s, _obj->orb);\n", name);
-                 } else {
-                         fprintf(ci->fh, "_deserialize(req.cdr_reply, %s%s);\n", n==2?"*":"", name);
-                 }
+                 fprintf(ci->fh, "_deserialize(req.cdr_reply, %s%s);\n", n==2?"*":"", name);
                }
        }
        fprintf(of, "    forb_request_signal_processed(&req);\n"