#include "forb-idl-c-backend.h"
#include <string.h>
+#include <inttypes.h>
+
+/**
+ *
+ *
+ * @param of
+ * @param ts Type spec.
+ * @param name decl
+ * @param use_name use identifier from name
+ * @param var_prefix prefix for identifier taken from name
+ * @param serialization
+ */
+void
+forb_cbe_write_ser_var(FILE *of, IDL_tree ts, IDL_tree name,
+ bool use_name,
+ char *var_prefix,
+ enum forb_ser serialization)
+{
+ int indent = 0, i;
+ GString *id = g_string_new("");
+ char *serialize = (serialization == SERIALIZE) ? "serialize" : "deserialize";
+ gboolean use_ampersand = TRUE;
+
+ switch(IDL_NODE_TYPE(name)) {
+ case IDLN_IDENT:
+ fprintf(of, " ");
+ if (use_name)
+ g_string_assign(id, IDL_IDENT(name).str);
+
+ if (IDL_NODE_TYPE(forb_cbe_get_typespec(ts)) == IDLN_TYPE_ARRAY)
+ use_ampersand = FALSE;
+
+/* printf("%s%s:\n", var_prefix, use_name ? id->str:""); */
+/* forb_idl_print_node(forb_cbe_get_typespec(ts), 2); */
+
+ break;
+ case IDLN_TYPE_ARRAY:
+ {
+ IDL_tree curitem;
+ char var;
+ if (use_name)
+ g_string_assign(id, IDL_IDENT(IDL_TYPE_ARRAY(name).ident).str);
+
+ var = 'i';
+ fprintf(of, " {\n CORBA_unsigned_long ");
+ for(curitem = IDL_TYPE_ARRAY(name).size_list; curitem; curitem = IDL_LIST(curitem).next) {
+ fprintf(of, "%c", var);
+ if (IDL_LIST(curitem).next)
+ fprintf(of, ", ");
+ g_string_append_printf(id, "[%c]", var);
+ var++;
+ }
+ fprintf(of, ";\n");
+
+ var = 'i';
+ for(curitem = IDL_TYPE_ARRAY(name).size_list; curitem; curitem = IDL_LIST(curitem).next) {
+ indent++;
+ for (i=0; i<indent+1; i++)
+ fprintf(of, " ");
+ fprintf(of, "for (%c=0; %c<%" PRId64 "; %c++) \n",
+ var, var, IDL_INTEGER(IDL_LIST(curitem).data).value, var);
+ var++;
+ }
+
+
+ for (i=0; i<indent+2; i++)
+ fprintf(of, " ");
+
+ }
+ break;
+ default:
+ g_error("Weird varname - %s", IDL_tree_type_names[IDL_NODE_TYPE(name)]);
+ break;
+ }
+ fprintf(of, "if (!");
+ forb_cbe_write_typespec(of, ts);
+ fprintf(of, "_%s(codec, %s%s%s)) goto ser_exception;\n",
+ serialize, use_ampersand ? "&":"", var_prefix, id->str);
+ if (indent)
+ fprintf(of, " }\n");
+
+ g_string_free(id, TRUE);
+}
+
char *
forb_cbe_get_typecode_name (IDL_tree tree)
gboolean
forb_cbe_type_is_builtin(IDL_tree tree)
{
- return FALSE;
+/* return FALSE; */
switch(IDL_NODE_TYPE(tree)) {
case IDLN_LIST:
case IDLN_GENTREE:
case IDLN_MEMBER:
- case IDLN_NATIVE:
case IDLN_CASE_STMT:
case IDLN_MODULE:
case IDLN_BINOP:
case IDLN_TYPE_OBJECT:
case IDLN_TYPE_TYPECODE:
case IDLN_TYPE_ENUM:
+ case IDLN_TYPE_SEQUENCE:
return TRUE;
break;
case IDLN_TYPE_DCL:
case IDLN_OP_DCL:
case IDLN_PARAM_DCL:
case IDLN_TYPE_FIXED:
- case IDLN_TYPE_SEQUENCE:
case IDLN_TYPE_ARRAY:
case IDLN_TYPE_STRUCT:
case IDLN_TYPE_UNION:
case IDLN_IDENT:
case IDLN_INTERFACE:
case IDLN_FORWARD_DCL:
+ case IDLN_NATIVE:
default:
return FALSE;
break;
}
break;
case IDLN_TYPE_FIXED:
- return g_strdup_printf( "CORBA_fixed_%" IDL_LL "d_%" IDL_LL "d",
+ return g_strdup_printf( "CORBA_fixed_%" PRId64 "_%" PRId64 "",
IDL_INTEGER(IDL_TYPE_FIXED(tree).positive_int_const).value,
IDL_INTEGER(IDL_TYPE_FIXED(tree).integer_lit).value);
break;
}
break;
case IDLN_NATIVE:
- retval = "gpointer";
+ retval = forb_cbe_get_typespec_str(IDL_NATIVE(tree).ident);
break;
case IDLN_FORWARD_DCL:
case IDLN_INTERFACE:
IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0);
if (for_epv)
- fprintf (of, " (*%s%s)", nom_prefix ? nom_prefix : "",
+ fprintf (of, "\t(*%s%s)", nom_prefix ? nom_prefix : "",
IDL_IDENT(IDL_OP_DCL(op).ident).str);
else
fprintf (of, " %s%s_%s", nom_prefix ? nom_prefix : "",
fprintf (of, "(");
- if (for_epv)
- fprintf (of, "PortableServer_Servant _servant, ");
- else
+/* if (for_epv) */
+/* fprintf (of, "PortableServer_Servant _servant, "); */
+/* else */
fprintf (of, "%s _obj, ", id);
g_free (id);
g_string_printf(tmpstr, "%f", IDL_FLOAT(tree).value);
break;
case IDLN_INTEGER:
- g_string_printf(tmpstr, "%" IDL_LL "d", IDL_INTEGER(tree).value);
+ g_string_printf(tmpstr, "%" PRId64 "", IDL_INTEGER(tree).value);
break;
case IDLN_STRING:
g_string_printf(tmpstr, "\"%s\"", IDL_STRING(tree).value);