]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - forb-idl/forb-idl-c-stubs.c
Stubs must allocate memory for out-direction sequence parameters
[frescor/forb.git] / forb-idl / forb-idl-c-stubs.c
index 150ccf6fd392e7386fada0ac7e1541b30d800a6e..9466c4bca4ab415933b75692e03f70f5264f94c9 100644 (file)
@@ -102,11 +102,19 @@ cs_output_stub (IDL_tree     tree,
                  gboolean  isSlice;
                  IDL_tree  ts = forb_cbe_get_typespec(parm);
                  int       n = oidl_param_info (ts, role, &isSlice);
-                 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);
+                         fprintf(of, "    ");
+                         forb_cbe_write_typespec(of, IDL_PARAM_DCL(parm).param_type_spec);
+                 fprintf(ci->fh, "_deserialize(req.cdr_reply, %s, _obj->orb);\n", name);
                  } else {
+                         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);
+                                 /* TODO: Free previously allocated parameters on no memory error. */
+                         }
+                         fprintf(of, "    ");
+                         forb_cbe_write_typespec(of, IDL_PARAM_DCL(parm).param_type_spec);
                          fprintf(ci->fh, "_deserialize(req.cdr_reply, %s%s);\n", n==2?"*":"", name);
                  }
                }