]> rtime.felk.cvut.cz Git - frescor/forb.git/blobdiff - forb-idl/forb-idl-c-utils.c
Fixed warnings on printf() on 64 bit systems
[frescor/forb.git] / forb-idl / forb-idl-c-utils.c
index 6dcaad1b33daa16d19b4299e32ed5eb9e2a9a529..3d8aee64d3b5e2c2ebfd8aad71cf821f074e0f9e 100644 (file)
@@ -3,6 +3,7 @@
 #include "forb-idl-c-backend.h"
 
 #include <string.h>
+#include <inttypes.h>
 
 /** 
  * 
@@ -23,14 +24,20 @@ forb_cbe_write_ser_var(FILE *of, IDL_tree ts, IDL_tree name,
        int indent = 0, i;
        GString *id = g_string_new("");
        char *serialize = (serialization == SERIALIZE) ? "serialize" : "deserialize";
+       gboolean use_ampersand = TRUE;
 
-       //forb_idl_print_node(ts, 0);
-       
        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:
        {
@@ -55,7 +62,7 @@ forb_cbe_write_ser_var(FILE *of, IDL_tree ts, IDL_tree name,
                        indent++;
                        for (i=0; i<indent+1; i++)
                                fprintf(of, "  ");
-                       fprintf(of, "for (%c=0; %c<%" IDL_LL "d; %c++) \n",
+                       fprintf(of, "for (%c=0; %c<%" PRId64 "; %c++) \n",
                                var, var, IDL_INTEGER(IDL_LIST(curitem).data).value, var);
                        var++;
                }
@@ -72,8 +79,8 @@ forb_cbe_write_ser_var(FILE *of, IDL_tree ts, IDL_tree name,
        }
        fprintf(of, "if (!");
        forb_cbe_write_typespec(of, ts);
-       fprintf(of, "_%s(codec, &%s%s)) goto ser_exception;\n",
-               serialize, var_prefix, id->str);
+       fprintf(of, "_%s(codec, %s%s%s)) goto ser_exception;\n",
+               serialize, use_ampersand ? "&":"", var_prefix, id->str);
        if (indent)
                fprintf(of, "  }\n");
 
@@ -98,7 +105,6 @@ forb_cbe_type_is_builtin(IDL_tree tree)
   case IDLN_LIST:
   case IDLN_GENTREE:
   case IDLN_MEMBER:
-  case IDLN_NATIVE:
   case IDLN_CASE_STMT:
   case IDLN_MODULE:
   case IDLN_BINOP:
@@ -142,6 +148,7 @@ forb_cbe_type_is_builtin(IDL_tree tree)
   case IDLN_IDENT:
   case IDLN_INTERFACE:
   case IDLN_FORWARD_DCL:
+  case IDLN_NATIVE:
   default:
     return FALSE;
     break;
@@ -185,7 +192,7 @@ forb_cbe_get_typespec_str(IDL_tree tree)
     }
     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;
@@ -253,7 +260,7 @@ forb_cbe_get_typespec_str(IDL_tree tree)
     }
     break;
   case IDLN_NATIVE:
-    retval = "gpointer";       /* FIXME: */
+    retval = forb_cbe_get_typespec_str(IDL_NATIVE(tree).ident);
     break;
   case IDLN_FORWARD_DCL:
   case IDLN_INTERFACE:
@@ -428,7 +435,7 @@ forb_cbe_get_const(IDL_tree tree)
     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);