| 1 | #include "config.h"
|
|---|
| 2 | #include "orbit-idl-c-backend.h"
|
|---|
| 3 |
|
|---|
| 4 | #include <string.h>
|
|---|
| 5 | #include <ctype.h>
|
|---|
| 6 |
|
|---|
| 7 | /*
|
|---|
| 8 | Voyager implementation notes:
|
|---|
| 9 |
|
|---|
| 10 | The name of the explicit metaclass is found in ch_output_const_dcl(). That
|
|---|
| 11 | function is responsible for putting constants into the header file.
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | /* ch = C header */
|
|---|
| 15 | static void ch_output_types(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 16 | #ifdef USE_LIBIDL_CODE
|
|---|
| 17 | static void ch_output_poa(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 18 | #endif
|
|---|
| 19 | static void ch_output_itypes (IDL_tree tree, OIDL_C_Info *ci);
|
|---|
| 20 | static void ch_output_stub_protos(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 21 | static void ch_output_skel_protos(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 22 | static void ch_output_voyager(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 23 | static void ch_VoyagerOutputClassDeclaration(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 24 |
|
|---|
| 25 | static GString *gsMetaClassName=NULL; /* Holding an explicit metaclass if any */
|
|---|
| 26 |
|
|---|
| 27 | void
|
|---|
| 28 | orbit_idl_output_c_headers (IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 29 | {
|
|---|
| 30 | fprintf (ci->fh, OIDL_C_WARNING);
|
|---|
| 31 | fprintf (ci->fh, "/*\n * %s\n */\n\n", rinfo->input_filename);
|
|---|
| 32 |
|
|---|
| 33 | fprintf(ci->fh, "#ifndef %s%s_H\n", rinfo->header_guard_prefix, ci->c_base_name);
|
|---|
| 34 | fprintf(ci->fh, "#define %s%s_H 1\n\n", rinfo->header_guard_prefix, ci->c_base_name);
|
|---|
| 35 |
|
|---|
| 36 | fprintf(ci->fh, "#include <glib.h>\n\n");
|
|---|
| 37 | #ifdef USE_LIBIDL_CODE
|
|---|
| 38 | fprintf(ci->fh, "#define ORBIT_IDL_SERIAL %d\n", ORBIT_CONFIG_SERIAL);
|
|---|
| 39 | fprintf(ci->fh, "#include <orbit/orbit-types.h>\n\n");
|
|---|
| 40 | #else
|
|---|
| 41 | fprintf(ci->fh, "#include <nomcls.h> /* This is needed for _nomNew() */\n\n");
|
|---|
| 42 | #endif
|
|---|
| 43 |
|
|---|
| 44 | fprintf(ci->fh, "#ifdef __cplusplus\n");
|
|---|
| 45 | fprintf(ci->fh, "extern \"C\" {\n");
|
|---|
| 46 | fprintf(ci->fh, "#endif /* __cplusplus */\n\n");
|
|---|
| 47 |
|
|---|
| 48 | /* Forward declare our class */
|
|---|
| 49 | ch_VoyagerOutputClassDeclaration(tree, rinfo, ci);
|
|---|
| 50 | /* Do all the typedefs, etc. */
|
|---|
| 51 | fprintf(ci->fh, "\n/** typedefs **/\n");
|
|---|
| 52 | ch_output_types(tree, rinfo, ci);
|
|---|
| 53 |
|
|---|
| 54 | #ifdef USE_LIBIDL_CODE
|
|---|
| 55 | if ( ci->do_skel_defs ) {
|
|---|
| 56 | /* Do all the POA structures, etc. */
|
|---|
| 57 | fprintf(ci->fh, "\n/** POA structures **/\n");
|
|---|
| 58 | ch_output_poa(tree, rinfo, ci);
|
|---|
| 59 | fprintf(ci->fh, "\n/** skel prototypes **/\n");
|
|---|
| 60 | ch_output_skel_protos(tree, rinfo, ci);
|
|---|
| 61 | }
|
|---|
| 62 | #endif
|
|---|
| 63 |
|
|---|
| 64 | fprintf(ci->fh, "\n/** stub prototypes **/\n");
|
|---|
| 65 | fprintf(ci->fh, " /* (%s, %s line %d) */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 66 | ch_output_stub_protos(tree, rinfo, ci);
|
|---|
| 67 |
|
|---|
| 68 | /* Voyager special stuff */
|
|---|
| 69 | fprintf(ci->fh, "\n/** Voyager **/\n");
|
|---|
| 70 | ch_output_voyager(tree, rinfo, ci);
|
|---|
| 71 |
|
|---|
| 72 | if ( ci->ext_dcls && ci->ext_dcls->str )
|
|---|
| 73 | fputs( ci->ext_dcls->str, ci->fh); /* this may be huge! */
|
|---|
| 74 |
|
|---|
| 75 | #ifdef USE_LIBIDL_CODE
|
|---|
| 76 | if (rinfo->idata) {
|
|---|
| 77 | /* FIXME: hackish ? */
|
|---|
| 78 | fprintf(ci->fh, "\n#include <orbit/orb-core/orbit-interface.h>\n\n");
|
|---|
| 79 |
|
|---|
| 80 | ch_output_itypes(tree, ci);
|
|---|
| 81 | }
|
|---|
| 82 | #endif
|
|---|
| 83 |
|
|---|
| 84 | fprintf(ci->fh, "#ifdef __cplusplus\n");
|
|---|
| 85 | fprintf(ci->fh, "}\n");
|
|---|
| 86 | fprintf(ci->fh, "#endif /* __cplusplus */\n\n");
|
|---|
| 87 |
|
|---|
| 88 | #ifdef USE_LIBIDL_CODE
|
|---|
| 89 | fprintf(ci->fh, "#ifndef EXCLUDE_ORBIT_H\n");
|
|---|
| 90 | fprintf(ci->fh, "#include <orbit/orbit.h>\n\n");
|
|---|
| 91 | fprintf(ci->fh, "#endif /* EXCLUDE_ORBIT_H */\n");
|
|---|
| 92 | #endif
|
|---|
| 93 |
|
|---|
| 94 | fprintf(ci->fh, "#endif /* %s%s_H */\n", rinfo->header_guard_prefix, ci->c_base_name);
|
|---|
| 95 |
|
|---|
| 96 | #ifdef USE_LIBIDL_CODE
|
|---|
| 97 | fprintf(ci->fh, "#undef ORBIT_IDL_SERIAL\n");
|
|---|
| 98 | #endif
|
|---|
| 99 | }
|
|---|
| 100 |
|
|---|
| 101 | static void ch_output_voyager(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 102 | {
|
|---|
| 103 |
|
|---|
| 104 | if (!tree)
|
|---|
| 105 | return;
|
|---|
| 106 |
|
|---|
| 107 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 108 | case IDLN_INTERFACE:
|
|---|
| 109 | {
|
|---|
| 110 | char *id;
|
|---|
| 111 |
|
|---|
| 112 | //ch_output_interface (tree, rinfo, ci);
|
|---|
| 113 | id = orbit_cbe_get_typespec_str(tree);
|
|---|
| 114 |
|
|---|
| 115 | fprintf(ci->fh, "\n/** Voyager (%s: %s line %d) **/\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 116 |
|
|---|
| 117 | /* C specific class structure */
|
|---|
| 118 | fprintf(ci->fh, "/*\n * (%s, %s line %d)\n */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 119 | fprintf(ci->fh, "/*\n * C specific class structure\n */\n");
|
|---|
| 120 | fprintf(ci->fh, "NOMEXTERN struct %sCClassDataStructure {\n", id);
|
|---|
| 121 | fprintf(ci->fh, " nomMethodTabs parentMtab;\n nomDToken instanceDataToken;\n} NOMDLINK %sCClassData;\n\n", id);
|
|---|
| 122 | /* vomNewClass() */
|
|---|
| 123 | fprintf(ci->fh, "/*\n * Class creation function\n */\n");
|
|---|
| 124 | fprintf(ci->fh, "NOMEXTERN NOMClass * NOMLINK %sNewClass(gulong somtmajorVersion, gulong somtminorVersion);\n",
|
|---|
| 125 | id);
|
|---|
| 126 | fprintf(ci->fh, "\n");
|
|---|
| 127 |
|
|---|
| 128 | fprintf(ci->fh, "/* %s: Line %d %s */\n", __FUNCTION__, __LINE__, __FUNCTION__);
|
|---|
| 129 | if(NULL==gsMetaClassName)
|
|---|
| 130 | fprintf(ci->fh, "#define _%s %sClassData.classObject\n", id, id);
|
|---|
| 131 | else
|
|---|
| 132 | fprintf(ci->fh, "#define _%s (%s*)%sClassData.classObject\n", id, gsMetaClassName->str, id);
|
|---|
| 133 | /* New() macro */
|
|---|
| 134 | fprintf(ci->fh, "\n/*\n * New macro for %s\n */\n", id);
|
|---|
| 135 | fprintf(ci->fh, "#define %sNew() \\\n", id);
|
|---|
| 136 | /* Changed for typesafetyness */
|
|---|
| 137 | fprintf(ci->fh, " ((%s*)_nomNew((_%s ? _%s : (%s*)%sNewClass(%s_MajorVersion, %s_MinorVersion)), (void*) 0))\n",
|
|---|
| 138 | id, id, id, id, id, id ,id);
|
|---|
| 139 | // fprintf(ci->fh, " (_nomNew((_%s ? _%s : %sNewClass(%s_MajorVersion, %s_MinorVersion)), (void*) 0))\n",
|
|---|
| 140 | // id, id, id, id ,id);
|
|---|
| 141 |
|
|---|
| 142 | fprintf(ci->fh, "\n");
|
|---|
| 143 | g_free (id);
|
|---|
| 144 | }
|
|---|
| 145 | break;
|
|---|
| 146 | default:
|
|---|
| 147 | break;
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 151 | case IDLN_MODULE:
|
|---|
| 152 | ch_output_voyager (IDL_MODULE (tree).definition_list, rinfo, ci);
|
|---|
| 153 | break;
|
|---|
| 154 | case IDLN_LIST: {
|
|---|
| 155 | IDL_tree sub;
|
|---|
| 156 |
|
|---|
| 157 | for (sub = tree; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 158 | ch_output_voyager (IDL_LIST (sub).data, rinfo, ci);
|
|---|
| 159 | }
|
|---|
| 160 | }
|
|---|
| 161 | break;
|
|---|
| 162 | case IDLN_INTERFACE:
|
|---|
| 163 | ch_output_voyager (IDL_INTERFACE (tree).body, rinfo, ci);
|
|---|
| 164 | break;
|
|---|
| 165 | default:
|
|---|
| 166 | break;
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | static void
|
|---|
| 171 | ch_output_var(IDL_tree val, IDL_tree name, OIDL_C_Info *ci)
|
|---|
| 172 | {
|
|---|
| 173 | orbit_cbe_write_typespec(ci->fh, val);
|
|---|
| 174 |
|
|---|
| 175 | fprintf(ci->fh, " ");
|
|---|
| 176 | switch(IDL_NODE_TYPE(name)) {
|
|---|
| 177 | case IDLN_IDENT:
|
|---|
| 178 | fprintf(ci->fh, "%s", IDL_IDENT(name).str);
|
|---|
| 179 | break;
|
|---|
| 180 | case IDLN_TYPE_ARRAY:
|
|---|
| 181 | {
|
|---|
| 182 | IDL_tree curitem;
|
|---|
| 183 |
|
|---|
| 184 | fprintf(ci->fh, "%s", IDL_IDENT(IDL_TYPE_ARRAY(name).ident).str);
|
|---|
| 185 | for(curitem = IDL_TYPE_ARRAY(name).size_list; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 186 | fprintf(ci->fh, "[%" IDL_LL "d]", IDL_INTEGER(IDL_LIST(curitem).data).value);
|
|---|
| 187 | }
|
|---|
| 188 | }
|
|---|
| 189 | break;
|
|---|
| 190 | default:
|
|---|
| 191 | g_error("Weird varname - %s", IDL_tree_type_names[IDL_NODE_TYPE(name)]);
|
|---|
| 192 | break;
|
|---|
| 193 | }
|
|---|
| 194 | fprintf(ci->fh, ";\n");
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | static void ch_output_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 198 | static void ch_output_type_struct(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 199 | static void ch_output_type_enum(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 200 | static void ch_output_type_dcl(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 201 | static void ch_output_native(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 202 | static void ch_output_type_union(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 203 | static void ch_output_codefrag(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 204 | static void ch_output_const_dcl(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 205 | static void ch_prep(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci);
|
|---|
| 206 | static void ch_type_alloc_and_tc(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci, gboolean do_alloc);
|
|---|
| 207 |
|
|---|
| 208 | static void
|
|---|
| 209 | ch_output_types (IDL_tree tree,
|
|---|
| 210 | OIDL_Run_Info *rinfo,
|
|---|
| 211 | OIDL_C_Info *ci)
|
|---|
| 212 | {
|
|---|
| 213 | if (!tree)
|
|---|
| 214 | return;
|
|---|
| 215 |
|
|---|
| 216 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 217 | case IDLN_EXCEPT_DCL: {
|
|---|
| 218 | char *id;
|
|---|
| 219 |
|
|---|
| 220 | id = IDL_ns_ident_to_qstring (
|
|---|
| 221 | IDL_IDENT_TO_NS (IDL_EXCEPT_DCL (tree).ident), "_", 0);
|
|---|
| 222 |
|
|---|
| 223 | fprintf (ci->fh, "#undef ex_%s\n", id);
|
|---|
| 224 | fprintf (ci->fh, "#define ex_%s \"%s\"\n",
|
|---|
| 225 | id, IDL_IDENT (IDL_EXCEPT_DCL (tree).ident).repo_id);
|
|---|
| 226 |
|
|---|
| 227 | g_free (id);
|
|---|
| 228 |
|
|---|
| 229 | ch_output_type_struct (tree, rinfo, ci);
|
|---|
| 230 | }
|
|---|
| 231 | break;
|
|---|
| 232 | case IDLN_FORWARD_DCL:
|
|---|
| 233 | case IDLN_INTERFACE:
|
|---|
| 234 | /* ch_output_interface (tree, rinfo, ci); */
|
|---|
| 235 | break;
|
|---|
| 236 | case IDLN_TYPE_STRUCT:
|
|---|
| 237 | ch_output_type_struct (tree, rinfo, ci);
|
|---|
| 238 | break;
|
|---|
| 239 | case IDLN_TYPE_ENUM:
|
|---|
| 240 | ch_output_type_enum (tree, rinfo, ci);
|
|---|
| 241 | break;
|
|---|
| 242 | case IDLN_TYPE_DCL:
|
|---|
| 243 | ch_output_type_dcl (tree, rinfo, ci);
|
|---|
| 244 | break;
|
|---|
| 245 | case IDLN_TYPE_UNION:
|
|---|
| 246 | ch_output_type_union (tree, rinfo, ci);
|
|---|
| 247 | break;
|
|---|
| 248 | case IDLN_CODEFRAG:
|
|---|
| 249 | ch_output_codefrag (tree, rinfo, ci);
|
|---|
| 250 | break;
|
|---|
| 251 | case IDLN_SRCFILE: {
|
|---|
| 252 | if (rinfo->onlytop) {
|
|---|
| 253 | char *idlfn = IDL_SRCFILE (tree).filename;
|
|---|
| 254 |
|
|---|
| 255 | if (!IDL_SRCFILE (tree).seenCnt &&
|
|---|
| 256 | !IDL_SRCFILE(tree).isTop &&
|
|---|
| 257 | !IDL_SRCFILE(tree).wasInhibit) {
|
|---|
| 258 | gchar *hfn, *htail;
|
|---|
| 259 |
|
|---|
| 260 | hfn = g_path_get_basename (idlfn);
|
|---|
| 261 | htail = strrchr (hfn,'.');
|
|---|
| 262 |
|
|---|
| 263 | g_assert (htail && strlen (htail) >= 2);
|
|---|
| 264 |
|
|---|
| 265 | htail [1] = 'h';
|
|---|
| 266 | htail [2] = 0;
|
|---|
| 267 |
|
|---|
| 268 | fprintf (ci->fh, "#include \"%s\"\n", hfn);
|
|---|
| 269 |
|
|---|
| 270 | g_free (hfn);
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | fprintf (ci->fh, "/* from IDL source file \"%s\" "
|
|---|
| 274 | "(seen %d, isTop %d, wasInhibit %d) */ \n",
|
|---|
| 275 | idlfn,
|
|---|
| 276 | IDL_SRCFILE (tree).seenCnt,
|
|---|
| 277 | IDL_SRCFILE (tree).isTop,
|
|---|
| 278 | IDL_SRCFILE (tree).wasInhibit);
|
|---|
| 279 | }
|
|---|
| 280 | }
|
|---|
| 281 | break;
|
|---|
| 282 | case IDLN_CONST_DCL:
|
|---|
| 283 | ch_output_const_dcl (tree, rinfo, ci);
|
|---|
| 284 | break;
|
|---|
| 285 | case IDLN_NATIVE:
|
|---|
| 286 | ch_output_native (tree, rinfo, ci);
|
|---|
| 287 | break;
|
|---|
| 288 | default:
|
|---|
| 289 | break;
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 293 | case IDLN_MODULE:
|
|---|
| 294 | ch_output_types (IDL_MODULE (tree).definition_list, rinfo, ci);
|
|---|
| 295 | break;
|
|---|
| 296 | case IDLN_LIST: {
|
|---|
| 297 | IDL_tree sub;
|
|---|
| 298 |
|
|---|
| 299 | for (sub = tree; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 300 | ch_output_types (IDL_LIST (sub).data, rinfo, ci);
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 | break;
|
|---|
| 304 | case IDLN_INTERFACE:
|
|---|
| 305 | ch_output_types (IDL_INTERFACE (tree).body, rinfo, ci);
|
|---|
| 306 | break;
|
|---|
| 307 | default:
|
|---|
| 308 | break;
|
|---|
| 309 | }
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | /*
|
|---|
| 313 | This function declares the class struct and the pointer on the class.
|
|---|
| 314 | */
|
|---|
| 315 | static void
|
|---|
| 316 | ch_VoyagerOutputClassDeclaration(IDL_tree tree,
|
|---|
| 317 | OIDL_Run_Info *rinfo,
|
|---|
| 318 | OIDL_C_Info *ci)
|
|---|
| 319 | {
|
|---|
| 320 | if (!tree)
|
|---|
| 321 | return;
|
|---|
| 322 |
|
|---|
| 323 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 324 | case IDLN_EXCEPT_DCL:
|
|---|
| 325 | break;
|
|---|
| 326 | case IDLN_FORWARD_DCL:
|
|---|
| 327 | case IDLN_INTERFACE:
|
|---|
| 328 | ch_output_interface (tree, rinfo, ci);
|
|---|
| 329 | break;
|
|---|
| 330 | case IDLN_TYPE_STRUCT:
|
|---|
| 331 | break;
|
|---|
| 332 | case IDLN_TYPE_ENUM:
|
|---|
| 333 | break;
|
|---|
| 334 | case IDLN_TYPE_DCL:
|
|---|
| 335 | break;
|
|---|
| 336 | case IDLN_TYPE_UNION:
|
|---|
| 337 | break;
|
|---|
| 338 | case IDLN_CODEFRAG:
|
|---|
| 339 | break;
|
|---|
| 340 | case IDLN_SRCFILE:
|
|---|
| 341 | break;
|
|---|
| 342 | case IDLN_CONST_DCL:
|
|---|
| 343 | break;
|
|---|
| 344 | case IDLN_NATIVE:
|
|---|
| 345 | break;
|
|---|
| 346 | default:
|
|---|
| 347 | break;
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 351 | case IDLN_MODULE:
|
|---|
| 352 | break;
|
|---|
| 353 | case IDLN_LIST: {
|
|---|
| 354 | IDL_tree sub;
|
|---|
| 355 |
|
|---|
| 356 | for (sub = tree; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 357 | ch_VoyagerOutputClassDeclaration (IDL_LIST (sub).data, rinfo, ci);
|
|---|
| 358 | }
|
|---|
| 359 | }
|
|---|
| 360 | break;
|
|---|
| 361 | case IDLN_INTERFACE:
|
|---|
| 362 | break;
|
|---|
| 363 | default:
|
|---|
| 364 | break;
|
|---|
| 365 | }
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 | static void
|
|---|
| 370 | ch_output_interface(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 371 | {
|
|---|
| 372 | char *fullname;
|
|---|
| 373 | fullname = orbit_cbe_get_typespec_str(tree);
|
|---|
| 374 | fprintf(ci->fh,"/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 375 | fprintf(ci->fh, "#if !defined(ORBIT_DECL_%s) && !defined(_%s_defined)\n#define ORBIT_DECL_%s 1\n#define _%s_defined 1\n",
|
|---|
| 376 | fullname, fullname, fullname, fullname);
|
|---|
| 377 |
|
|---|
| 378 | #ifdef USE_LIBIDL_CODE
|
|---|
| 379 | if ( tree->declspec & IDLF_DECLSPEC_PIDL ) {
|
|---|
| 380 | /* PIDL interfaces are not normal CORBA Objects */
|
|---|
| 381 | fprintf(ci->fh, "typedef struct %s_type *%s;\n", fullname, fullname);
|
|---|
| 382 | fprintf(ci->fh, "#ifndef TC_%s\n", fullname);
|
|---|
| 383 | fprintf(ci->fh, "# define TC_%s TC_CORBA_Object\n", fullname);
|
|---|
| 384 | fprintf(ci->fh, "#endif\n");
|
|---|
| 385 | } else {
|
|---|
| 386 | fprintf(ci->fh, "#define %s__freekids CORBA_Object__freekids\n", fullname);
|
|---|
| 387 |
|
|---|
| 388 | fprintf(ci->fh, "typedef CORBA_Object %s;\n\n", fullname);
|
|---|
| 389 | fprintf(ci->fh, "extern CORBA_unsigned_long %s__classid;\n", fullname);
|
|---|
| 390 | ch_type_alloc_and_tc(tree, rinfo, ci, FALSE);
|
|---|
| 391 | }
|
|---|
| 392 | #else
|
|---|
| 393 | fprintf(ci->fh, "#ifndef %s\n", fullname);
|
|---|
| 394 | #if 0
|
|---|
| 395 | /* For being more typesave when calling methods */
|
|---|
| 396 | fprintf(ci->fh, "typedef struct %s_struct {\n", fullname);
|
|---|
| 397 | fprintf(ci->fh, " struct nomMethodTabStruct *mtab;\n");
|
|---|
| 398 | fprintf(ci->fh, " gulong body[1];\n");
|
|---|
| 399 | fprintf(ci->fh, "} %sObj;\n", fullname);
|
|---|
| 400 |
|
|---|
| 401 | fprintf(ci->fh, "#define %s %sObj\n", fullname, fullname);
|
|---|
| 402 | fprintf(ci->fh, "typedef %s *P%s;\n", fullname, fullname);
|
|---|
| 403 | #endif
|
|---|
| 404 | fprintf(ci->fh, "#define %s NOMObject\n", fullname);
|
|---|
| 405 | fprintf(ci->fh, "typedef %s *P%s;\n", fullname, fullname);
|
|---|
| 406 | fprintf(ci->fh, "#endif\n");
|
|---|
| 407 | #endif
|
|---|
| 408 |
|
|---|
| 409 | fprintf(ci->fh, "#endif\n\n");
|
|---|
| 410 | g_free(fullname);
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | static void
|
|---|
| 414 | ch_output_type_enum (IDL_tree tree,
|
|---|
| 415 | OIDL_Run_Info *rinfo,
|
|---|
| 416 | OIDL_C_Info *ci)
|
|---|
| 417 | {
|
|---|
| 418 | IDL_tree l;
|
|---|
| 419 | char *enumid;
|
|---|
| 420 |
|
|---|
| 421 | /* CORBA spec says to do
|
|---|
| 422 | * typedef unsigned int enum_name;
|
|---|
| 423 | * and then #defines for each enumerator.
|
|---|
| 424 | * This works just as well and seems cleaner.
|
|---|
| 425 | */
|
|---|
| 426 |
|
|---|
| 427 | enumid = IDL_ns_ident_to_qstring (
|
|---|
| 428 | IDL_IDENT_TO_NS (IDL_TYPE_ENUM (tree).ident), "_", 0);
|
|---|
| 429 | fprintf (ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n", enumid, enumid);
|
|---|
| 430 | fprintf (ci->fh, "typedef enum {\n");
|
|---|
| 431 |
|
|---|
| 432 | for (l = IDL_TYPE_ENUM (tree).enumerator_list; l; l = IDL_LIST (l).next) {
|
|---|
| 433 | char *id;
|
|---|
| 434 |
|
|---|
| 435 | id = IDL_ns_ident_to_qstring (
|
|---|
| 436 | IDL_IDENT_TO_NS (IDL_LIST (l).data), "_", 0);
|
|---|
| 437 |
|
|---|
| 438 | fprintf (ci->fh, " %s%s\n", id, IDL_LIST (l).next ? "," : "");
|
|---|
| 439 |
|
|---|
| 440 | g_free (id);
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | fprintf (ci->fh, "} %s;\n", enumid);
|
|---|
| 444 |
|
|---|
| 445 | ch_type_alloc_and_tc (tree, rinfo, ci, FALSE);
|
|---|
| 446 |
|
|---|
| 447 | fprintf (ci->fh, "#endif\n");
|
|---|
| 448 |
|
|---|
| 449 | g_free (enumid);
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | static void
|
|---|
| 453 | ch_output_type_dcl(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 454 | {
|
|---|
| 455 | IDL_tree l;
|
|---|
| 456 |
|
|---|
| 457 | ch_prep (IDL_TYPE_DCL (tree).type_spec, rinfo, ci);
|
|---|
| 458 |
|
|---|
| 459 | for (l = IDL_TYPE_DCL (tree).dcls; l; l = IDL_LIST (l).next) {
|
|---|
| 460 | char *ctmp = NULL;
|
|---|
| 461 |
|
|---|
| 462 | IDL_tree ent = IDL_LIST (l).data;
|
|---|
| 463 |
|
|---|
| 464 | switch (IDL_NODE_TYPE(ent)) {
|
|---|
| 465 | case IDLN_IDENT:
|
|---|
| 466 | ctmp = IDL_ns_ident_to_qstring (
|
|---|
| 467 | IDL_IDENT_TO_NS (ent), "_", 0);
|
|---|
| 468 | break;
|
|---|
| 469 | case IDLN_TYPE_ARRAY:
|
|---|
| 470 | ctmp = IDL_ns_ident_to_qstring (
|
|---|
| 471 | IDL_IDENT_TO_NS (IDL_TYPE_ARRAY (ent).ident), "_", 0);
|
|---|
| 472 | break;
|
|---|
| 473 | default:
|
|---|
| 474 | g_assert_not_reached ();
|
|---|
| 475 | break;
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | fprintf (ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n", ctmp, ctmp);
|
|---|
| 479 | fprintf (ci->fh, "typedef ");
|
|---|
| 480 | orbit_cbe_write_typespec (ci->fh, IDL_TYPE_DCL (tree).type_spec);
|
|---|
| 481 |
|
|---|
| 482 | switch (IDL_NODE_TYPE (ent)) {
|
|---|
| 483 | case IDLN_IDENT:
|
|---|
| 484 | fprintf (ci->fh, " %s;\n", ctmp);
|
|---|
| 485 | fprintf (ci->fh, "#define %s_marshal(x,y,z) ", ctmp);
|
|---|
| 486 | orbit_cbe_write_typespec (ci->fh, IDL_TYPE_DCL (tree).type_spec);
|
|---|
| 487 | fprintf (ci->fh, "_marshal((x),(y),(z))\n");
|
|---|
| 488 |
|
|---|
| 489 | fprintf (ci->fh, "#define %s_demarshal(x,y,z,i) ", ctmp);
|
|---|
| 490 | orbit_cbe_write_typespec (ci->fh, IDL_TYPE_DCL (tree).type_spec);
|
|---|
| 491 | fprintf (ci->fh, "_demarshal((x),(y),(z),(i))\n");
|
|---|
| 492 | break;
|
|---|
| 493 | case IDLN_TYPE_ARRAY: {
|
|---|
| 494 | IDL_tree sub;
|
|---|
| 495 |
|
|---|
| 496 | fprintf (ci->fh, " %s", ctmp);
|
|---|
| 497 | for (sub = IDL_TYPE_ARRAY (ent).size_list; sub; sub = IDL_LIST (sub).next)
|
|---|
| 498 | fprintf (ci->fh, "[%" IDL_LL "d]",
|
|---|
| 499 | IDL_INTEGER (IDL_LIST (sub).data).value);
|
|---|
| 500 |
|
|---|
| 501 | fprintf (ci->fh, ";\n");
|
|---|
| 502 | fprintf (ci->fh, "typedef ");
|
|---|
| 503 | orbit_cbe_write_typespec (ci->fh, IDL_TYPE_DCL (tree).type_spec);
|
|---|
| 504 | fprintf (ci->fh, " %s_slice", ctmp);
|
|---|
| 505 | for (sub = IDL_LIST (IDL_TYPE_ARRAY (ent).size_list).next;
|
|---|
| 506 | sub; sub = IDL_LIST (sub).next)
|
|---|
| 507 | fprintf (ci->fh, "[%" IDL_LL "d]", IDL_INTEGER (IDL_LIST (sub).data).value);
|
|---|
| 508 | fprintf(ci->fh, ";\n");
|
|---|
| 509 | }
|
|---|
| 510 | break;
|
|---|
| 511 | default:
|
|---|
| 512 | break;
|
|---|
| 513 | }
|
|---|
| 514 |
|
|---|
| 515 | ch_type_alloc_and_tc (ent, rinfo, ci, TRUE);
|
|---|
| 516 | fprintf (ci->fh, "#endif\n");
|
|---|
| 517 | g_free (ctmp);
|
|---|
| 518 | }
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | static void
|
|---|
| 522 | ch_output_native(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 523 | {
|
|---|
| 524 | #ifdef USE_LIBIDL_CODE
|
|---|
| 525 | char *ctmp;
|
|---|
| 526 | IDL_tree id = IDL_NATIVE(tree).ident;
|
|---|
| 527 | ctmp = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(id), "_", 0);
|
|---|
| 528 | fprintf(ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n", ctmp, ctmp);
|
|---|
| 529 | fprintf(ci->fh, "typedef struct %s_type *%s;\n", ctmp, ctmp);
|
|---|
| 530 | /* Dont even think about emitting a typecode. */
|
|---|
| 531 | fprintf(ci->fh, "#endif\n");
|
|---|
| 532 | g_free(ctmp);
|
|---|
| 533 | #endif
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | static void
|
|---|
| 537 | ch_output_type_struct(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 538 | {
|
|---|
| 539 | char *id;
|
|---|
| 540 | IDL_tree cur, curmem;
|
|---|
| 541 |
|
|---|
| 542 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_TYPE_STRUCT(tree).ident),
|
|---|
| 543 | "_", 0);
|
|---|
| 544 | fprintf(ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n", id, id);
|
|---|
| 545 | /* put typedef out first for recursive seq */
|
|---|
| 546 | fprintf(ci->fh, "typedef struct %s_type %s;\n", id, id);
|
|---|
| 547 |
|
|---|
| 548 | /* Scan for any nested decls */
|
|---|
| 549 | for(cur = IDL_TYPE_STRUCT(tree).member_list; cur; cur = IDL_LIST(cur).next) {
|
|---|
| 550 | IDL_tree ts;
|
|---|
| 551 | ts = IDL_MEMBER(IDL_LIST(cur).data).type_spec;
|
|---|
| 552 | ch_prep(ts, rinfo, ci);
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | fprintf(ci->fh, "struct %s_type {\n", id);
|
|---|
| 556 |
|
|---|
| 557 | for(cur = IDL_TYPE_STRUCT(tree).member_list; cur; cur = IDL_LIST(cur).next) {
|
|---|
| 558 | for(curmem = IDL_MEMBER(IDL_LIST(cur).data).dcls; curmem; curmem = IDL_LIST(curmem).next) {
|
|---|
| 559 | ch_output_var(IDL_MEMBER(IDL_LIST(cur).data).type_spec, IDL_LIST(curmem).data, ci);
|
|---|
| 560 | }
|
|---|
| 561 | }
|
|---|
| 562 | if(!IDL_TYPE_STRUCT(tree).member_list)
|
|---|
| 563 | fprintf(ci->fh, "int dummy;\n");
|
|---|
| 564 | fprintf(ci->fh, "};\n\n");
|
|---|
| 565 |
|
|---|
| 566 | ch_type_alloc_and_tc(tree, rinfo, ci, TRUE);
|
|---|
| 567 |
|
|---|
| 568 | fprintf(ci->fh, "#endif\n");
|
|---|
| 569 |
|
|---|
| 570 | g_free(id);
|
|---|
| 571 | }
|
|---|
| 572 |
|
|---|
| 573 |
|
|---|
| 574 | static void
|
|---|
| 575 | ch_output_type_union(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 576 | {
|
|---|
| 577 | char *id;
|
|---|
| 578 | IDL_tree curitem;
|
|---|
| 579 |
|
|---|
| 580 | if (IDL_NODE_TYPE (IDL_TYPE_UNION (tree).switch_type_spec) == IDLN_TYPE_ENUM)
|
|---|
| 581 | ch_output_type_enum (IDL_TYPE_UNION (tree).switch_type_spec, rinfo, ci);
|
|---|
| 582 |
|
|---|
| 583 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_TYPE_UNION(tree).ident), "_", 0);
|
|---|
| 584 | fprintf(ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n", id, id);
|
|---|
| 585 | fprintf(ci->fh, "typedef struct %s_type %s;\n", id, id);
|
|---|
| 586 |
|
|---|
| 587 | /* Scan for any nested decls */
|
|---|
| 588 | for(curitem = IDL_TYPE_UNION(tree).switch_body; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 589 | IDL_tree member = IDL_CASE_STMT(IDL_LIST(curitem).data).element_spec;
|
|---|
| 590 | ch_prep(IDL_MEMBER(member).type_spec, rinfo, ci);
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | fprintf(ci->fh, "struct %s_type {\n", id);
|
|---|
| 594 | orbit_cbe_write_typespec(ci->fh, IDL_TYPE_UNION(tree).switch_type_spec);
|
|---|
| 595 | fprintf(ci->fh, " _d;\nunion {\n");
|
|---|
| 596 |
|
|---|
| 597 | for(curitem = IDL_TYPE_UNION(tree).switch_body; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 598 | IDL_tree member;
|
|---|
| 599 |
|
|---|
| 600 | member = IDL_CASE_STMT(IDL_LIST(curitem).data).element_spec;
|
|---|
| 601 | ch_output_var(IDL_MEMBER(member).type_spec,
|
|---|
| 602 | IDL_LIST(IDL_MEMBER(member).dcls).data,
|
|---|
| 603 | ci);
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | fprintf(ci->fh, "} _u;\n};\n");
|
|---|
| 607 |
|
|---|
| 608 | ch_type_alloc_and_tc(tree, rinfo, ci, TRUE);
|
|---|
| 609 |
|
|---|
| 610 | fprintf(ci->fh, "#endif\n");
|
|---|
| 611 |
|
|---|
| 612 | g_free(id);
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | static void
|
|---|
| 616 | ch_output_codefrag(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 617 | {
|
|---|
| 618 | GSList *list;
|
|---|
| 619 |
|
|---|
| 620 | for(list = IDL_CODEFRAG(tree).lines; list;
|
|---|
| 621 | list = g_slist_next(list)) {
|
|---|
| 622 | if(!strncmp(list->data,
|
|---|
| 623 | "#pragma include_defs",
|
|---|
| 624 | sizeof("#pragma include_defs")-1)) {
|
|---|
| 625 | char *ctmp, *cte;
|
|---|
| 626 | ctmp = ((char *)list->data) + sizeof("#pragma include_defs");
|
|---|
| 627 | while(*ctmp && (isspace((int)*ctmp) || *ctmp == '"')) ctmp++;
|
|---|
| 628 | cte = ctmp;
|
|---|
| 629 | while(*cte && !isspace((int)*cte) && *cte != '"') cte++;
|
|---|
| 630 | *cte = '\0';
|
|---|
| 631 | fprintf(ci->fh, "#include <%s>\n", ctmp);
|
|---|
| 632 | } else
|
|---|
| 633 | fprintf(ci->fh, "%s\n", (char *)list->data);
|
|---|
| 634 | }
|
|---|
| 635 | }
|
|---|
| 636 |
|
|---|
| 637 | #if 0
|
|---|
| 638 | static gchar* mySkipSpaces(char* theString)
|
|---|
| 639 | {
|
|---|
| 640 | if(!theString) /* Huh???*/
|
|---|
| 641 | return "";
|
|---|
| 642 |
|
|---|
| 643 | while(*theString)
|
|---|
| 644 | theString++;
|
|---|
| 645 |
|
|---|
| 646 | return theString
|
|---|
| 647 | }
|
|---|
| 648 | #endif
|
|---|
| 649 |
|
|---|
| 650 | #include <string.h>
|
|---|
| 651 | /*
|
|---|
| 652 | This function extracts the return vlaue from the string which is created by
|
|---|
| 653 | the parameter check macro. The string is of the form:
|
|---|
| 654 |
|
|---|
| 655 | "retval, parm1, parm2,..."
|
|---|
| 656 |
|
|---|
| 657 | */
|
|---|
| 658 | static gchar* VoyagerExtractRetValFromParmCheck(gchar* theString)
|
|---|
| 659 | {
|
|---|
| 660 | gchar* ptr, *ptr2;
|
|---|
| 661 |
|
|---|
| 662 | if(NULL==(ptr=strchr(theString, ',')))
|
|---|
| 663 | {
|
|---|
| 664 | /* No ',' so no parameters provided */
|
|---|
| 665 | return g_strdup(theString);
|
|---|
| 666 | }
|
|---|
| 667 | *ptr='\0';
|
|---|
| 668 | ptr2=g_strdup(theString);
|
|---|
| 669 | *ptr=',';
|
|---|
| 670 | return ptr2;
|
|---|
| 671 | };
|
|---|
| 672 |
|
|---|
| 673 | /*
|
|---|
| 674 | This functions puts constants into the header file. For Voyager we
|
|---|
| 675 | use constants to encode some special information e.g. the metaclass name
|
|---|
| 676 | or info about which parameters to check for methods. This information is
|
|---|
| 677 | marked by special strings in the constants name.
|
|---|
| 678 | */
|
|---|
| 679 | static void
|
|---|
| 680 | ch_output_const_dcl(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 681 | {
|
|---|
| 682 | char *id;
|
|---|
| 683 | IDL_tree ident;
|
|---|
| 684 | IDL_tree typespec;
|
|---|
| 685 | gchar *ptr;
|
|---|
| 686 |
|
|---|
| 687 | ident = IDL_CONST_DCL (tree).ident;
|
|---|
| 688 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS (ident), "_", 0);
|
|---|
| 689 |
|
|---|
| 690 | /* Enable parameter check for a method. This is done by putting a #define xxx
|
|---|
| 691 | at the top of the file. Checking code is sourrounded by #ifdef/#endif. */
|
|---|
| 692 | ptr=strstr( id , NOM_PARMCHECK_STRING);
|
|---|
| 693 | if(ptr)
|
|---|
| 694 | {
|
|---|
| 695 | gchar *retVal;
|
|---|
| 696 | *ptr='\0';
|
|---|
| 697 | //printf(" %d --- > %s %s Params: %s\n",
|
|---|
| 698 | //__LINE__, id, IDL_IDENT(ident).str, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value);
|
|---|
| 699 | /* Print out the line for easy finding in this source file */
|
|---|
| 700 | fprintf(ci->fh, "/* %s: %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 701 | fprintf(ci->fh, "/* Value: %s */\n", IDL_STRING(IDL_CONST_DCL(tree).const_exp).value);
|
|---|
| 702 | /* Protect by #ifdef...*/
|
|---|
| 703 | fprintf(ci->fh, "#ifndef %s_ParmCheck_h\n", id);
|
|---|
| 704 | fprintf(ci->fh, "#define %s_ParmCheck_h\n", id);
|
|---|
| 705 | /* Default return code (provided by the macro) */
|
|---|
| 706 | retVal=VoyagerExtractRetValFromParmCheck(IDL_STRING(IDL_CONST_DCL(tree).const_exp).value);
|
|---|
| 707 | fprintf(ci->fh, "#define %s_retval %s\n", id, retVal);
|
|---|
| 708 | g_free(retVal);
|
|---|
| 709 | fprintf(ci->fh, "#endif /* !%s */\n\n", id);
|
|---|
| 710 | *ptr='_';
|
|---|
| 711 | }
|
|---|
| 712 | else
|
|---|
| 713 | {
|
|---|
| 714 | fprintf(ci->fh, "#ifndef %s\n", id);
|
|---|
| 715 | fprintf(ci->fh, "#define %s ", id);
|
|---|
| 716 |
|
|---|
| 717 | orbit_cbe_write_const(ci->fh,
|
|---|
| 718 | IDL_CONST_DCL(tree).const_exp);
|
|---|
| 719 |
|
|---|
| 720 | typespec = orbit_cbe_get_typespec (IDL_CONST_DCL(tree).const_type);
|
|---|
| 721 | if (IDL_NODE_TYPE (typespec) == IDLN_TYPE_INTEGER &&
|
|---|
| 722 | !IDL_TYPE_INTEGER (typespec).f_signed)
|
|---|
| 723 | fprintf(ci->fh, "U");
|
|---|
| 724 |
|
|---|
| 725 | fprintf(ci->fh, "\n");
|
|---|
| 726 | fprintf(ci->fh, "#endif /* !%s */\n\n", id);
|
|---|
| 727 | }
|
|---|
| 728 |
|
|---|
| 729 | /* Get the name of our explicit metaclass if any. */
|
|---|
| 730 | if(IDLN_STRING==IDL_NODE_TYPE(IDL_CONST_DCL(tree).const_exp))
|
|---|
| 731 | {
|
|---|
| 732 | /* Our metaclass info is a string */
|
|---|
| 733 | if(strstr( IDL_IDENT(ident).str, NOM_METACLASS_STRING))
|
|---|
| 734 | {
|
|---|
| 735 | gsMetaClassName=g_string_new(NULL);
|
|---|
| 736 | g_string_printf(gsMetaClassName, "%s", IDL_STRING(IDL_CONST_DCL(tree).const_exp).value);
|
|---|
| 737 | //printf(" %d --- > %s %s (%x)\n",
|
|---|
| 738 | //__LINE__, id, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value, gsMetaClassName[ulCurInterface]);
|
|---|
| 739 | }
|
|---|
| 740 | }
|
|---|
| 741 | g_free(id);
|
|---|
| 742 | }
|
|---|
| 743 |
|
|---|
| 744 | static void
|
|---|
| 745 | ch_prep_fixed(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 746 | {
|
|---|
| 747 | char *ctmp;
|
|---|
| 748 |
|
|---|
| 749 | ctmp = orbit_cbe_get_typespec_str(tree);
|
|---|
| 750 | fprintf(ci->fh,
|
|---|
| 751 | "typedef struct { CORBA_unsigned_short _digits; CORBA_short _scale; CORBA_char _value[%d]; } %s;\n",
|
|---|
| 752 | (int) (IDL_INTEGER(IDL_TYPE_FIXED(tree).positive_int_const).value + 2)/2,
|
|---|
| 753 | ctmp);
|
|---|
| 754 | g_free(ctmp);
|
|---|
| 755 |
|
|---|
| 756 | ch_type_alloc_and_tc(tree, rinfo, ci, TRUE);
|
|---|
| 757 | }
|
|---|
| 758 |
|
|---|
| 759 | static void
|
|---|
| 760 | ch_prep_sequence(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 761 | {
|
|---|
| 762 | char *ctmp, *fullname, *fullname_def, *ctmp2;
|
|---|
| 763 | IDL_tree tts;
|
|---|
| 764 | gboolean separate_defs, fake_if;
|
|---|
| 765 | IDL_tree fake_seq = NULL;
|
|---|
| 766 |
|
|---|
| 767 | tts = orbit_cbe_get_typespec(IDL_TYPE_SEQUENCE(tree).simple_type_spec);
|
|---|
| 768 | ctmp = orbit_cbe_get_typespec_str(IDL_TYPE_SEQUENCE(tree).simple_type_spec);
|
|---|
| 769 | ctmp2 = orbit_cbe_get_typespec_str(tts);
|
|---|
| 770 | fake_if = (IDL_NODE_TYPE(tts) == IDLN_INTERFACE);
|
|---|
| 771 | if(fake_if)
|
|---|
| 772 | {
|
|---|
| 773 | g_free(ctmp2);
|
|---|
| 774 | ctmp2 = g_strdup("CORBA_Object");
|
|---|
| 775 | }
|
|---|
| 776 | separate_defs = strcmp(ctmp, ctmp2);
|
|---|
| 777 | fullname = orbit_cbe_get_typespec_str(tree);
|
|---|
| 778 |
|
|---|
| 779 | if(separate_defs)
|
|---|
| 780 | {
|
|---|
| 781 | if(fake_if)
|
|---|
| 782 | tts = IDL_type_object_new();
|
|---|
| 783 | fake_seq = IDL_type_sequence_new(tts, NULL);
|
|---|
| 784 | IDL_NODE_UP(fake_seq) = IDL_NODE_UP(tree);
|
|---|
| 785 | ch_prep_sequence(fake_seq, rinfo, ci);
|
|---|
| 786 | fullname_def = g_strdup_printf("CORBA_sequence_%s", ctmp2);
|
|---|
| 787 | if(!fake_if)
|
|---|
| 788 | IDL_TYPE_SEQUENCE(fake_seq).simple_type_spec = NULL;
|
|---|
| 789 | }
|
|---|
| 790 | else
|
|---|
| 791 | fullname_def = g_strdup(fullname);
|
|---|
| 792 |
|
|---|
| 793 | if(IDL_NODE_TYPE(IDL_TYPE_SEQUENCE(tree).simple_type_spec)
|
|---|
| 794 | == IDLN_TYPE_SEQUENCE)
|
|---|
| 795 | ch_prep_sequence(IDL_TYPE_SEQUENCE(tree).simple_type_spec, rinfo, ci);
|
|---|
| 796 |
|
|---|
| 797 | /* NOTE: ORBIT_DECL_%s protects redef of everything (struct,TC,externs)
|
|---|
| 798 | * while _%s_defined protects only the struct */
|
|---|
| 799 |
|
|---|
| 800 | fprintf(ci->fh, "#if !defined(ORBIT_DECL_%s)\n#define ORBIT_DECL_%s 1\n",
|
|---|
| 801 | fullname, fullname);
|
|---|
| 802 | if ( ci->do_impl_hack )
|
|---|
| 803 | orbit_cbe_id_define_hack(ci->fh, "ORBIT_IMPL", fullname, ci->c_base_name);
|
|---|
| 804 |
|
|---|
| 805 | if(separate_defs)
|
|---|
| 806 | {
|
|---|
| 807 | fprintf(ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n",
|
|---|
| 808 | fullname, fullname);
|
|---|
| 809 | if(!strcmp(ctmp, "CORBA_RepositoryId"))
|
|---|
| 810 | fprintf(ci->fh, "/* CRACKHEADS */\n");
|
|---|
| 811 | fprintf(ci->fh, "typedef %s %s;\n", fullname_def, fullname);
|
|---|
| 812 | fprintf(ci->fh, "#endif\n");
|
|---|
| 813 | ch_type_alloc_and_tc(tree, rinfo, ci, FALSE);
|
|---|
| 814 | fprintf(ci->fh, "#define %s__alloc %s__alloc\n",
|
|---|
| 815 | fullname, fullname_def);
|
|---|
| 816 | fprintf(ci->fh, "#define %s__freekids %s__freekids\n",
|
|---|
| 817 | fullname, fullname_def);
|
|---|
| 818 | fprintf(ci->fh, "#define CORBA_sequence_%s_allocbuf CORBA_sequence_%s_allocbuf\n",
|
|---|
| 819 | ctmp, ctmp2);
|
|---|
| 820 | fprintf(ci->fh, "#define %s_marshal(x,y,z) %s_marshal((x),(y),(z))\n", fullname, fullname_def);
|
|---|
| 821 |
|
|---|
| 822 | fprintf(ci->fh, "#define %s_demarshal(x,y,z,i) %s_demarshal((x),(y),(z),(i))\n", fullname, fullname_def);
|
|---|
| 823 | IDL_tree_free(fake_seq);
|
|---|
| 824 | }
|
|---|
| 825 | else
|
|---|
| 826 | {
|
|---|
| 827 | char *tc, *member_type;
|
|---|
| 828 |
|
|---|
| 829 | fprintf(ci->fh, "#if !defined(_%s_defined)\n#define _%s_defined 1\n",
|
|---|
| 830 | fullname, fullname);
|
|---|
| 831 | fprintf(ci->fh, "typedef struct { CORBA_unsigned_long _maximum, _length; ");
|
|---|
| 832 | orbit_cbe_write_typespec(ci->fh, IDL_TYPE_SEQUENCE(tree).simple_type_spec);
|
|---|
| 833 | fprintf(ci->fh, "* _buffer; CORBA_boolean _release; } ");
|
|---|
| 834 | orbit_cbe_write_typespec(ci->fh, tree);
|
|---|
| 835 | fprintf(ci->fh, ";\n#endif\n");
|
|---|
| 836 | ch_type_alloc_and_tc(tree, rinfo, ci, TRUE);
|
|---|
| 837 |
|
|---|
| 838 | tc = orbit_cbe_get_typecode_name (orbit_cbe_get_typespec (tree));
|
|---|
| 839 | member_type = orbit_cbe_type_is_builtin (IDL_TYPE_SEQUENCE (tree).simple_type_spec) ?
|
|---|
| 840 | ctmp + strlen ("CORBA_") : ctmp;
|
|---|
| 841 |
|
|---|
| 842 | fprintf (ci->fh, "#define CORBA_sequence_%s_allocbuf(l) "
|
|---|
| 843 | "((%s*)ORBit_small_allocbuf (%s, (l)))\n",
|
|---|
| 844 | member_type, member_type, tc);
|
|---|
| 845 |
|
|---|
| 846 | g_free (tc);
|
|---|
| 847 | }
|
|---|
| 848 |
|
|---|
| 849 | fprintf(ci->fh, "#endif\n");
|
|---|
| 850 |
|
|---|
| 851 | g_free(ctmp2);
|
|---|
| 852 | g_free(ctmp);
|
|---|
| 853 | g_free(fullname);
|
|---|
| 854 | g_free(fullname_def);
|
|---|
| 855 | }
|
|---|
| 856 |
|
|---|
| 857 | static
|
|---|
| 858 | void ch_prep (IDL_tree tree,
|
|---|
| 859 | OIDL_Run_Info *rinfo,
|
|---|
| 860 | OIDL_C_Info *ci)
|
|---|
| 861 | {
|
|---|
| 862 | switch (IDL_NODE_TYPE (tree)) {
|
|---|
| 863 | case IDLN_TYPE_SEQUENCE:
|
|---|
| 864 | ch_prep_sequence (tree, rinfo, ci);
|
|---|
| 865 | break;
|
|---|
| 866 | case IDLN_TYPE_FIXED:
|
|---|
| 867 | ch_prep_fixed (tree, rinfo, ci);
|
|---|
| 868 | break;
|
|---|
| 869 | case IDLN_TYPE_STRUCT:
|
|---|
| 870 | ch_output_type_struct (tree, rinfo, ci);
|
|---|
| 871 | break;
|
|---|
| 872 | case IDLN_TYPE_ENUM:
|
|---|
| 873 | ch_output_type_enum (tree, rinfo, ci);
|
|---|
| 874 | break;
|
|---|
| 875 | default:
|
|---|
| 876 | break;
|
|---|
| 877 | }
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | static void
|
|---|
| 881 | ch_type_alloc_and_tc(IDL_tree tree, OIDL_Run_Info *rinfo,
|
|---|
| 882 | OIDL_C_Info *ci, gboolean do_alloc)
|
|---|
| 883 | {
|
|---|
| 884 | char *ctmp;
|
|---|
| 885 | IDL_tree tts;
|
|---|
| 886 |
|
|---|
| 887 | ctmp = orbit_cbe_get_typespec_str(tree);
|
|---|
| 888 |
|
|---|
| 889 | if ( ci->do_impl_hack ) {
|
|---|
| 890 | fprintf(ci->fh, "#if !defined(TC_IMPL_TC_%s_0)\n", ctmp);
|
|---|
| 891 | orbit_cbe_id_define_hack(ci->fh, "TC_IMPL_TC", ctmp, ci->c_base_name);
|
|---|
| 892 | }
|
|---|
| 893 |
|
|---|
| 894 | fprintf (ci->fh, "#ifdef ORBIT_IDL_C_IMODULE_%s\n", ci->c_base_name);
|
|---|
| 895 | fprintf (ci->fh, "static\n");
|
|---|
| 896 | fprintf (ci->fh, "#else\n");
|
|---|
| 897 | fprintf (ci->fh, "extern\n");
|
|---|
| 898 | fprintf (ci->fh, "#endif\n");
|
|---|
| 899 | fprintf (ci->fh, "ORBIT2_MAYBE_CONST struct CORBA_TypeCode_struct TC_%s_struct;\n", ctmp);
|
|---|
| 900 |
|
|---|
| 901 | fprintf (ci->fh, "#define TC_%s ((CORBA_TypeCode)&TC_%s_struct)\n", ctmp, ctmp);
|
|---|
| 902 | if (ci->do_impl_hack)
|
|---|
| 903 | fprintf (ci->fh, "#endif\n");
|
|---|
| 904 |
|
|---|
| 905 | if(do_alloc) {
|
|---|
| 906 | char *tc;
|
|---|
| 907 |
|
|---|
| 908 | tts = orbit_cbe_get_typespec(tree);
|
|---|
| 909 |
|
|---|
| 910 | tc = orbit_cbe_get_typecode_name (tts);
|
|---|
| 911 |
|
|---|
| 912 | fprintf (ci->fh, "#define %s__alloc() ((%s%s *)ORBit_small_alloc (%s))\n",
|
|---|
| 913 | ctmp, ctmp, (IDL_NODE_TYPE(tree) == IDLN_TYPE_ARRAY)?"_slice":"", tc);
|
|---|
| 914 |
|
|---|
| 915 | fprintf (ci->fh, "#define %s__freekids(m,d) ORBit_small_freekids (%s,(m),(d))\n", ctmp, tc);
|
|---|
| 916 |
|
|---|
| 917 | if ( IDL_NODE_TYPE(tts) == IDLN_TYPE_SEQUENCE )
|
|---|
| 918 | {
|
|---|
| 919 | char *member_type = orbit_cbe_get_typespec_str(IDL_TYPE_SEQUENCE(tts).simple_type_spec);
|
|---|
| 920 | char *member_name = orbit_cbe_type_is_builtin (IDL_TYPE_SEQUENCE (tts).simple_type_spec) ?
|
|---|
| 921 | member_type + strlen ("CORBA_") : member_type;
|
|---|
| 922 |
|
|---|
| 923 | fprintf (ci->fh, "#define %s_allocbuf(l) "
|
|---|
| 924 | "((%s*)ORBit_small_allocbuf (%s, (l)))\n",
|
|---|
| 925 | ctmp, member_name, tc);
|
|---|
| 926 |
|
|---|
| 927 | g_free (member_type);
|
|---|
| 928 | }
|
|---|
| 929 |
|
|---|
| 930 | g_free (tc);
|
|---|
| 931 | }
|
|---|
| 932 |
|
|---|
| 933 | g_free(ctmp);
|
|---|
| 934 | }
|
|---|
| 935 |
|
|---|
| 936 | /************************/
|
|---|
| 937 | #ifdef USE_LIBIDL_CODE
|
|---|
| 938 | static void
|
|---|
| 939 | cbe_header_interface_print_vepv(IDL_tree node, FILE *of)
|
|---|
| 940 | {
|
|---|
| 941 | char *id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(node).ident),
|
|---|
| 942 | "_", 0);
|
|---|
| 943 | fprintf(of, " POA_%s__epv *%s_epv;\n", id, id);
|
|---|
| 944 | g_free(id);
|
|---|
| 945 |
|
|---|
| 946 | }
|
|---|
| 947 |
|
|---|
| 948 | static void
|
|---|
| 949 | ch_output_poa(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 950 | {
|
|---|
| 951 | if(!tree) return;
|
|---|
| 952 |
|
|---|
| 953 | if ( tree->declspec & IDLF_DECLSPEC_PIDL )
|
|---|
| 954 | return;
|
|---|
| 955 |
|
|---|
| 956 | switch(IDL_NODE_TYPE(tree)) {
|
|---|
| 957 | case IDLN_MODULE:
|
|---|
| 958 | ch_output_poa(IDL_MODULE(tree).definition_list, rinfo, ci);
|
|---|
| 959 | break;
|
|---|
| 960 | case IDLN_LIST:
|
|---|
| 961 | {
|
|---|
| 962 | IDL_tree sub;
|
|---|
| 963 |
|
|---|
| 964 | for(sub = tree; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 965 | ch_output_poa(IDL_LIST(sub).data, rinfo, ci);
|
|---|
| 966 | }
|
|---|
| 967 | }
|
|---|
| 968 | break;
|
|---|
| 969 | case IDLN_INTERFACE:
|
|---|
| 970 | {
|
|---|
| 971 | IDL_tree sub;
|
|---|
| 972 | char *id;
|
|---|
| 973 |
|
|---|
| 974 |
|
|---|
| 975 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0);
|
|---|
| 976 |
|
|---|
| 977 | fprintf(ci->fh, "#ifndef _defined_POA_%s\n#define _defined_POA_%s 1\n",
|
|---|
| 978 | id, id);
|
|---|
| 979 |
|
|---|
| 980 | /* First, do epv for this interface, then vepv, then servant */
|
|---|
| 981 | fprintf(ci->fh, "typedef struct {\n");
|
|---|
| 982 | fprintf(ci->fh, " void *_private;\n");
|
|---|
| 983 | for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 984 | IDL_tree cur;
|
|---|
| 985 |
|
|---|
| 986 | cur = IDL_LIST(sub).data;
|
|---|
| 987 |
|
|---|
| 988 | switch(IDL_NODE_TYPE(cur)) {
|
|---|
| 989 | case IDLN_OP_DCL:
|
|---|
| 990 | orbit_cbe_op_write_proto(ci->fh, cur, "", TRUE);
|
|---|
| 991 | fprintf(ci->fh, ";\n");
|
|---|
| 992 | break;
|
|---|
| 993 | case IDLN_ATTR_DCL:
|
|---|
| 994 | {
|
|---|
| 995 | OIDL_Attr_Info *ai;
|
|---|
| 996 | IDL_tree curitem;
|
|---|
| 997 |
|
|---|
| 998 | for(curitem = IDL_ATTR_DCL(cur).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 999 | ai = IDL_LIST(curitem).data->data;
|
|---|
| 1000 |
|
|---|
| 1001 | orbit_cbe_op_write_proto(ci->fh, ai->op1, "", TRUE);
|
|---|
| 1002 | fprintf(ci->fh, ";\n");
|
|---|
| 1003 |
|
|---|
| 1004 | if(ai->op2) {
|
|---|
| 1005 | orbit_cbe_op_write_proto(ci->fh, ai->op2, "", TRUE);
|
|---|
| 1006 | fprintf(ci->fh, ";\n");
|
|---|
| 1007 | }
|
|---|
| 1008 | }
|
|---|
| 1009 | }
|
|---|
| 1010 | break;
|
|---|
| 1011 | default:
|
|---|
| 1012 | break;
|
|---|
| 1013 | }
|
|---|
| 1014 | }
|
|---|
| 1015 |
|
|---|
| 1016 | fprintf(ci->fh, "} POA_%s__epv;\n", id);
|
|---|
| 1017 |
|
|---|
| 1018 | fprintf(ci->fh, "typedef struct {\n");
|
|---|
| 1019 | fprintf(ci->fh, " PortableServer_ServantBase__epv *_base_epv;\n");
|
|---|
| 1020 | IDL_tree_traverse_parents(tree, (GFunc)cbe_header_interface_print_vepv, ci->fh);
|
|---|
| 1021 | fprintf(ci->fh, "} POA_%s__vepv;\n", id);
|
|---|
| 1022 |
|
|---|
| 1023 | fprintf(ci->fh, "typedef struct {\n");
|
|---|
| 1024 | fprintf(ci->fh, " void *_private;\n");
|
|---|
| 1025 | fprintf(ci->fh, " POA_%s__vepv *vepv;\n", id);
|
|---|
| 1026 | fprintf(ci->fh, "} POA_%s;\n", id);
|
|---|
| 1027 |
|
|---|
| 1028 | fprintf(ci->fh,
|
|---|
| 1029 | "extern void POA_%s__init(PortableServer_Servant servant, CORBA_Environment *ev);\n", id);
|
|---|
| 1030 | fprintf(ci->fh,
|
|---|
| 1031 | "extern void POA_%s__fini(PortableServer_Servant servant, CORBA_Environment *ev);\n", id);
|
|---|
| 1032 |
|
|---|
| 1033 | fprintf(ci->fh, "#endif /* _defined_POA_%s */\n", id);
|
|---|
| 1034 |
|
|---|
| 1035 | g_free(id);
|
|---|
| 1036 | }
|
|---|
| 1037 | break;
|
|---|
| 1038 | default:
|
|---|
| 1039 | break;
|
|---|
| 1040 | }
|
|---|
| 1041 | }
|
|---|
| 1042 | #endif
|
|---|
| 1043 |
|
|---|
| 1044 | /************************/
|
|---|
| 1045 | typedef struct {
|
|---|
| 1046 | FILE *of;
|
|---|
| 1047 | IDL_tree realif;
|
|---|
| 1048 | char* chrOverridenMethodName;
|
|---|
| 1049 | } InheritedOutputInfo;
|
|---|
| 1050 | static void ch_output_inherited_protos(IDL_tree curif, InheritedOutputInfo *ioi);
|
|---|
| 1051 |
|
|---|
| 1052 | static void
|
|---|
| 1053 | VoyagerOutputClassDataStructMember(FILE *of, IDL_tree op, const char *nom_prefix)
|
|---|
| 1054 | {
|
|---|
| 1055 | g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);
|
|---|
| 1056 |
|
|---|
| 1057 | fprintf (of, " nomMToken %s", IDL_IDENT (IDL_OP_DCL (op).ident).str);
|
|---|
| 1058 | }
|
|---|
| 1059 |
|
|---|
| 1060 | static void
|
|---|
| 1061 | VoyagerOutputClassDataStructAttributeMember (FILE *of,
|
|---|
| 1062 | IDL_tree op,
|
|---|
| 1063 | const char *nom_prefix,
|
|---|
| 1064 | gboolean for_epv)
|
|---|
| 1065 | {
|
|---|
| 1066 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1067 | IDL_tree sub;
|
|---|
| 1068 | #endif
|
|---|
| 1069 | char *id;
|
|---|
| 1070 |
|
|---|
| 1071 | g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);
|
|---|
| 1072 |
|
|---|
| 1073 |
|
|---|
| 1074 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1075 | /* This is used for writing the return type */
|
|---|
| 1076 | orbit_cbe_write_param_typespec (of, op);
|
|---|
| 1077 | #endif
|
|---|
| 1078 |
|
|---|
| 1079 | id = IDL_ns_ident_to_qstring (
|
|---|
| 1080 | IDL_IDENT_TO_NS (IDL_INTERFACE (
|
|---|
| 1081 | IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0);
|
|---|
| 1082 |
|
|---|
| 1083 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1084 | if (for_epv)
|
|---|
| 1085 | fprintf (of, " (*%s%s)", nom_prefix ? nom_prefix : "",
|
|---|
| 1086 | IDL_IDENT(IDL_OP_DCL(op).ident).str);
|
|---|
| 1087 | else
|
|---|
| 1088 | fprintf (of, " %s%s_%s", nom_prefix ? nom_prefix : "",
|
|---|
| 1089 | id, IDL_IDENT (IDL_OP_DCL (op).ident).str);
|
|---|
| 1090 | #else
|
|---|
| 1091 | /* We support special instance vars which are not known to the outside
|
|---|
| 1092 | (in contrast to attributes which have _set() and _get() methods).
|
|---|
| 1093 | These instance vars are specially marked attributes in the IDL file
|
|---|
| 1094 | which are processed by a macro. This macro adds the string
|
|---|
| 1095 | __INSTANCEVAR__ to the attribute name. For these attributes
|
|---|
| 1096 | we do not add methods to the class here. */
|
|---|
| 1097 | if(!strstr(IDL_IDENT (IDL_OP_DCL (op).ident).str, "__INSTANCEVAR__"))
|
|---|
| 1098 | if(!for_epv)
|
|---|
| 1099 | fprintf (of, " _%s", IDL_IDENT (IDL_OP_DCL (op).ident).str);
|
|---|
| 1100 | #endif
|
|---|
| 1101 |
|
|---|
| 1102 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1103 | fprintf (of, "(");
|
|---|
| 1104 |
|
|---|
| 1105 | if (for_epv)
|
|---|
| 1106 | fprintf (of, "PortableServer_Servant _servant, ");
|
|---|
| 1107 | else
|
|---|
| 1108 | fprintf (of, "%s _obj, ", id);
|
|---|
| 1109 | #endif
|
|---|
| 1110 |
|
|---|
| 1111 | g_free (id);
|
|---|
| 1112 |
|
|---|
| 1113 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1114 | /* Do params... */
|
|---|
| 1115 | for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 1116 | IDL_tree parm = IDL_LIST (sub).data;
|
|---|
| 1117 |
|
|---|
| 1118 | orbit_cbe_write_param_typespec (of, parm);
|
|---|
| 1119 |
|
|---|
| 1120 | fprintf (of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
|
|---|
| 1121 | }
|
|---|
| 1122 |
|
|---|
| 1123 | if (IDL_OP_DCL (op).context_expr)
|
|---|
| 1124 | fprintf (of, "CORBA_Context _ctx, ");
|
|---|
| 1125 | fprintf (of, "CORBA_Environment *ev)");
|
|---|
| 1126 | #endif
|
|---|
| 1127 | }
|
|---|
| 1128 |
|
|---|
| 1129 |
|
|---|
| 1130 | /*
|
|---|
| 1131 | This function puts out something like the following in the *.h file:
|
|---|
| 1132 |
|
|---|
| 1133 | #define WPFolder_wpEchoString(nomSelf, a, b, ...) \
|
|---|
| 1134 | WPObject_wpEchoString((WPObject*) nomSelf, a, b, ...)
|
|---|
| 1135 | */
|
|---|
| 1136 | static void
|
|---|
| 1137 | VoyagerOutputOverridenMethod(IDL_tree curif, InheritedOutputInfo *ioi)
|
|---|
| 1138 | {
|
|---|
| 1139 | char *id, *realid;
|
|---|
| 1140 | IDL_tree curitem;
|
|---|
| 1141 | char* overridenMethodName;
|
|---|
| 1142 |
|
|---|
| 1143 | if(curif == ioi->realif)
|
|---|
| 1144 | return;
|
|---|
| 1145 |
|
|---|
| 1146 | overridenMethodName=ioi->chrOverridenMethodName;
|
|---|
| 1147 |
|
|---|
| 1148 | realid = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(ioi->realif).ident), "_", 0);
|
|---|
| 1149 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curif).ident), "_", 0);
|
|---|
| 1150 |
|
|---|
| 1151 | for(curitem = IDL_INTERFACE(curif).body; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1152 | IDL_tree curop = IDL_LIST(curitem).data;
|
|---|
| 1153 |
|
|---|
| 1154 | switch(IDL_NODE_TYPE(curop)) {
|
|---|
| 1155 | case IDLN_OP_DCL:
|
|---|
| 1156 | {
|
|---|
| 1157 | /* Check if the current method (introduced by some parent) is the one to be
|
|---|
| 1158 | overriden. */
|
|---|
| 1159 | if(!strcmp(overridenMethodName, IDL_IDENT(IDL_OP_DCL(curop).ident).str)){
|
|---|
| 1160 | IDL_tree sub;
|
|---|
| 1161 |
|
|---|
| 1162 | fprintf(ioi->of, "#define %s_%s(nomSelf, ",
|
|---|
| 1163 | realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str);
|
|---|
| 1164 | for (sub = IDL_OP_DCL (curop).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 1165 | IDL_tree parm = IDL_LIST (sub).data;
|
|---|
| 1166 | fprintf (ioi->of, "%s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
|
|---|
| 1167 | }
|
|---|
| 1168 | fprintf(ioi->of, "ev) \\\n");
|
|---|
| 1169 | fprintf(ioi->of, " %s_%s((%s*) nomSelf, ",
|
|---|
| 1170 | id, IDL_IDENT(IDL_OP_DCL(curop).ident).str, id);
|
|---|
| 1171 | for (sub = IDL_OP_DCL (curop).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
|
|---|
| 1172 | IDL_tree parm = IDL_LIST (sub).data;
|
|---|
| 1173 | fprintf (ioi->of, "%s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
|
|---|
| 1174 | }
|
|---|
| 1175 | fprintf(ioi->of, "ev)\n");
|
|---|
| 1176 | }
|
|---|
| 1177 | break;
|
|---|
| 1178 | }
|
|---|
| 1179 | default:
|
|---|
| 1180 | break;
|
|---|
| 1181 | }
|
|---|
| 1182 | }
|
|---|
| 1183 |
|
|---|
| 1184 | g_free(id);
|
|---|
| 1185 | g_free(realid);
|
|---|
| 1186 | }
|
|---|
| 1187 |
|
|---|
| 1188 | /*
|
|---|
| 1189 | Output the typespecs and parameters of a new method.
|
|---|
| 1190 | Note that tree must be correctly chosen.
|
|---|
| 1191 | */
|
|---|
| 1192 | static void
|
|---|
| 1193 | doWriteTypespecAndParameters(FILE *of, IDL_tree tree)
|
|---|
| 1194 | {
|
|---|
| 1195 | IDL_tree curitem;
|
|---|
| 1196 |
|
|---|
| 1197 | for(curitem = IDL_OP_DCL(tree).parameter_dcls;
|
|---|
| 1198 | curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1199 | IDL_tree tr;
|
|---|
| 1200 | tr = IDL_LIST(curitem).data;
|
|---|
| 1201 | /* Write list of params */
|
|---|
| 1202 | if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL)
|
|---|
| 1203 | {
|
|---|
| 1204 | fprintf(of, " ");
|
|---|
| 1205 | orbit_cbe_write_param_typespec(of, tr);
|
|---|
| 1206 | fprintf(of, " %s,\n", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str);
|
|---|
| 1207 | }
|
|---|
| 1208 | }
|
|---|
| 1209 | }
|
|---|
| 1210 |
|
|---|
| 1211 | /*
|
|---|
| 1212 | Output the parameters only of a new method.
|
|---|
| 1213 | Note that tree must be correctly chosen.
|
|---|
| 1214 | */
|
|---|
| 1215 | static void
|
|---|
| 1216 | doWriteParametersOnly(FILE *of, IDL_tree tree)
|
|---|
| 1217 | {
|
|---|
| 1218 | IDL_tree curitem;
|
|---|
| 1219 |
|
|---|
| 1220 | for(curitem = IDL_OP_DCL(tree).parameter_dcls;
|
|---|
| 1221 | curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1222 | IDL_tree tr;
|
|---|
| 1223 | tr = IDL_LIST(curitem).data;
|
|---|
| 1224 | /* Write list of params */
|
|---|
| 1225 | if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL)
|
|---|
| 1226 | {
|
|---|
| 1227 | fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str);
|
|---|
| 1228 | }
|
|---|
| 1229 | }
|
|---|
| 1230 | }
|
|---|
| 1231 |
|
|---|
| 1232 | /*
|
|---|
| 1233 | This function does quite some real work. It puts all the info about an introduced method
|
|---|
| 1234 | into the *.h file. This includes convenience macros, strings specifying the method name
|
|---|
| 1235 | and macros for automatic checking of parameters.
|
|---|
| 1236 | */
|
|---|
| 1237 | static void
|
|---|
| 1238 | VoyagerOutputNewMethod(FILE *of, IDL_tree tree, const char *nom_prefix)
|
|---|
| 1239 | {
|
|---|
| 1240 | /* If you fix anything here, please also fix it in
|
|---|
| 1241 | cbe_ski_do_inherited_op_dcl(), which is almost a
|
|---|
| 1242 | cut-and-paste of this routine */
|
|---|
| 1243 |
|
|---|
| 1244 | char *id, *id2, *id3;
|
|---|
| 1245 | IDL_tree curitem, op;
|
|---|
| 1246 | int level;
|
|---|
| 1247 |
|
|---|
| 1248 | g_assert (IDL_NODE_TYPE(tree) == IDLN_OP_DCL);
|
|---|
| 1249 |
|
|---|
| 1250 | curitem = IDL_get_parent_node(tree, IDLN_INTERFACE, &level);
|
|---|
| 1251 | g_assert(curitem);
|
|---|
| 1252 |
|
|---|
| 1253 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(tree).ident), "_", 0);
|
|---|
| 1254 | id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curitem).ident), "_", 0);
|
|---|
| 1255 | id3 = IDL_IDENT (IDL_OP_DCL (tree).ident).str;
|
|---|
| 1256 |
|
|---|
| 1257 | fprintf(of, "/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 1258 | /* protect with #ifdef block */
|
|---|
| 1259 | fprintf(of, "#if !defined(_decl_");
|
|---|
| 1260 | fprintf(of, "%s_)\n", id);
|
|---|
| 1261 |
|
|---|
| 1262 | fprintf(of, "#define _decl_");
|
|---|
| 1263 | fprintf(of, "%s_ 1\n\n", id);
|
|---|
| 1264 |
|
|---|
| 1265 | fprintf(of, "typedef ");
|
|---|
| 1266 | orbit_cbe_write_param_typespec(of, tree);
|
|---|
| 1267 |
|
|---|
| 1268 | fprintf(of, " NOMLINK nomTP_%s(%s *nomSelf,\n", id, id2);
|
|---|
| 1269 |
|
|---|
| 1270 | op = tree;
|
|---|
| 1271 | for(curitem = IDL_OP_DCL(tree).parameter_dcls;
|
|---|
| 1272 | curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1273 | IDL_tree tr;
|
|---|
| 1274 | tr = IDL_LIST(curitem).data;
|
|---|
| 1275 |
|
|---|
| 1276 | /* Write list of params */
|
|---|
| 1277 | if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL)
|
|---|
| 1278 | {
|
|---|
| 1279 | fprintf(of, " ");
|
|---|
| 1280 | orbit_cbe_write_param_typespec(of, tr);
|
|---|
| 1281 | fprintf(of, " %s,\n", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str);
|
|---|
| 1282 | }
|
|---|
| 1283 | #if 0
|
|---|
| 1284 | subski.tree = IDL_LIST(curitem).data;
|
|---|
| 1285 | orbit_cbe_ski_process_piece(&subski);
|
|---|
| 1286 | #endif
|
|---|
| 1287 | }
|
|---|
| 1288 | tree=op;
|
|---|
| 1289 |
|
|---|
| 1290 | #ifdef NOT_YET
|
|---|
| 1291 | if(IDL_OP_DCL(op).context_expr)
|
|---|
| 1292 | fprintf(of, "CORBA_Context ctx,\n");
|
|---|
| 1293 | #endif
|
|---|
| 1294 |
|
|---|
| 1295 | fprintf(of, "CORBA_Environment *ev)");
|
|---|
| 1296 | fprintf(of, ";\n");
|
|---|
| 1297 |
|
|---|
| 1298 | fprintf(of, "typedef ");
|
|---|
| 1299 | fprintf(of, "nomTP_%s *nomTD_%s;\n", id, id);
|
|---|
| 1300 |
|
|---|
| 1301 | /* define the ID for this method */
|
|---|
| 1302 | fprintf(of, "/* define the name for this method */\n");
|
|---|
| 1303 | fprintf(of, "#define nomMNDef_%s \"%s\"\n", id, id3);
|
|---|
| 1304 | fprintf(of, "#define nomMNFullDef_%s \"%s:%s\"\n", id, id2, id3);
|
|---|
| 1305 |
|
|---|
| 1306 | /* define method call as a macro */
|
|---|
| 1307 | fprintf(of, "/* define method call as a macro */\n");
|
|---|
| 1308 | fprintf(of, "#ifndef NOM_NO_PARAM_CHECK /* Parameter chack at all? */\n");
|
|---|
| 1309 | fprintf(of, "#ifdef %s_ParmCheck_h /* Extended parameter check enabled */\n", id);
|
|---|
| 1310 |
|
|---|
| 1311 | /* Forward declaration of parameter test function */
|
|---|
| 1312 | fprintf(of, "NOMEXTERN ");
|
|---|
| 1313 | fprintf(of, "gboolean NOMLINK parmCheckFunc_%s(%s *nomSelf, \n",id, id2);
|
|---|
| 1314 | /* Write parameter list including the type spec */
|
|---|
| 1315 | doWriteTypespecAndParameters(of, tree);
|
|---|
| 1316 | fprintf(of, "CORBA_Environment *ev);\n");
|
|---|
| 1317 |
|
|---|
| 1318 | /* Macro to be used when several parameters are checked */
|
|---|
| 1319 | fprintf(of, "#define %s(nomSelf, ", id);
|
|---|
| 1320 | /* add the parms */
|
|---|
| 1321 | doWriteParametersOnly(of, tree);
|
|---|
| 1322 | fprintf(of, "ev) \\\n");
|
|---|
| 1323 | if(!strstr(id, "_nomIsObject"))
|
|---|
| 1324 | {
|
|---|
| 1325 | /* No check for _nomIsObject or otherwise we have a recursion */
|
|---|
| 1326 | fprintf(of, " (parmCheckFunc_%s(nomSelf, ", id);
|
|---|
| 1327 | /* Parameters for call */
|
|---|
| 1328 | doWriteParametersOnly(of, tree);
|
|---|
| 1329 | fprintf(of, "ev) ? \\\n");
|
|---|
| 1330 | fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3);
|
|---|
| 1331 | fprintf(of, " (nomSelf,");
|
|---|
| 1332 | /* add the parms */
|
|---|
| 1333 | doWriteParametersOnly(of, tree);
|
|---|
| 1334 | fprintf(of, "ev)) : %s_retval)\n", id);
|
|---|
| 1335 | }
|
|---|
| 1336 | else
|
|---|
| 1337 | {
|
|---|
| 1338 | fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3);
|
|---|
| 1339 | fprintf(of, " (nomSelf,");
|
|---|
| 1340 | /* add the parms */
|
|---|
| 1341 | doWriteParametersOnly(of, tree);
|
|---|
| 1342 | fprintf(of, "ev))\n");
|
|---|
| 1343 | }
|
|---|
| 1344 | /* else NOM_NO_PARAM_CHECK */
|
|---|
| 1345 | fprintf(of, "#else /* Extended parameter check */\n");
|
|---|
| 1346 |
|
|---|
| 1347 | /* Check object only */
|
|---|
| 1348 | fprintf(of, "#define %s(nomSelf, ", id);
|
|---|
| 1349 | /* add the parms */
|
|---|
| 1350 | doWriteParametersOnly(of, tree);
|
|---|
| 1351 | fprintf(of, "ev) \\\n");
|
|---|
| 1352 | if(!strstr(id, "_nomIsObject"))
|
|---|
| 1353 | {
|
|---|
| 1354 | /* No check for _nomIsObject or otherwise we have a recursion */
|
|---|
| 1355 | if(!strcmp(id2, "NOMObject"))
|
|---|
| 1356 | fprintf(of, " (nomCheckNOMObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,", id2);
|
|---|
| 1357 | else
|
|---|
| 1358 | fprintf(of, " (nomCheckObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,", id2);
|
|---|
| 1359 | fprintf(of, " \"%s\", ev) ? \\\n", id); /* method name */
|
|---|
| 1360 | fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3);
|
|---|
| 1361 | fprintf(of, " (nomSelf,");
|
|---|
| 1362 | /* add the parms */
|
|---|
| 1363 | doWriteParametersOnly(of, tree);
|
|---|
| 1364 | fprintf(of, "ev)) : (");
|
|---|
| 1365 | orbit_cbe_write_param_typespec(of, tree);
|
|---|
| 1366 | fprintf(of, ") NULL)\n");
|
|---|
| 1367 | }
|
|---|
| 1368 | else
|
|---|
| 1369 | {
|
|---|
| 1370 | fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3);
|
|---|
| 1371 | fprintf(of, " (nomSelf,");
|
|---|
| 1372 | /* add the parms */
|
|---|
| 1373 | doWriteParametersOnly(of, tree);
|
|---|
| 1374 | fprintf(of, "ev))\n");
|
|---|
| 1375 | }
|
|---|
| 1376 | fprintf(of, "#endif\n");
|
|---|
| 1377 |
|
|---|
| 1378 | /* No parameter check at all */
|
|---|
| 1379 | fprintf(of, "#else /* NOM_NO_PARAM_CHECK */\n");
|
|---|
| 1380 |
|
|---|
| 1381 | /* Normal macro */
|
|---|
| 1382 | fprintf(of, "#define %s(nomSelf, ", id);
|
|---|
| 1383 | doWriteParametersOnly(of, tree);
|
|---|
| 1384 | fprintf(of, "ev) \\\n");
|
|---|
| 1385 | fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3);
|
|---|
| 1386 | fprintf(of, " (nomSelf,");
|
|---|
| 1387 | /* add the parms */
|
|---|
| 1388 | doWriteParametersOnly(of, tree);
|
|---|
| 1389 | fprintf(of, "ev))\n");
|
|---|
| 1390 | fprintf(of, "#endif\n"); /* Parameter check*/
|
|---|
| 1391 |
|
|---|
| 1392 | /* Method macro */
|
|---|
| 1393 | fprintf(of, "#define _%s %s", id3 , id);
|
|---|
| 1394 |
|
|---|
| 1395 | fprintf(of, "\n#endif\n\n"); /* end of protective #ifdef block */
|
|---|
| 1396 | /* Don't dare to free id3 here ;) */
|
|---|
| 1397 | g_free(id); g_free(id2);
|
|---|
| 1398 | return ;
|
|---|
| 1399 | }
|
|---|
| 1400 |
|
|---|
| 1401 | /* CW: probably some cleanup isn't too bad here... */
|
|---|
| 1402 | static void
|
|---|
| 1403 | ch_output_stub_protos(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 1404 | {
|
|---|
| 1405 | if(!tree) return;
|
|---|
| 1406 |
|
|---|
| 1407 | switch(IDL_NODE_TYPE(tree)) {
|
|---|
| 1408 | case IDLN_MODULE:
|
|---|
| 1409 | ch_output_stub_protos(IDL_MODULE(tree).definition_list, rinfo, ci);
|
|---|
| 1410 | break;
|
|---|
| 1411 | case IDLN_LIST:
|
|---|
| 1412 | {
|
|---|
| 1413 | IDL_tree sub;
|
|---|
| 1414 |
|
|---|
| 1415 | for(sub = tree; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1416 | ch_output_stub_protos(IDL_LIST(sub).data, rinfo, ci);
|
|---|
| 1417 | }
|
|---|
| 1418 | }
|
|---|
| 1419 | break;
|
|---|
| 1420 | case IDLN_INTERFACE:
|
|---|
| 1421 | {
|
|---|
| 1422 | /* write stubs into c header file */
|
|---|
| 1423 | IDL_tree sub;
|
|---|
| 1424 | char *id;
|
|---|
| 1425 |
|
|---|
| 1426 | /* Get interface name */
|
|---|
| 1427 | sub = IDL_INTERFACE(tree).body;
|
|---|
| 1428 | sub = IDL_LIST(sub).data;
|
|---|
| 1429 | id = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_INTERFACE (IDL_get_parent_node (sub, IDLN_INTERFACE, NULL)).ident),
|
|---|
| 1430 | "_", 0);
|
|---|
| 1431 |
|
|---|
| 1432 | /* Inherited stuff */
|
|---|
| 1433 | if(IDL_INTERFACE(tree).inheritance_spec) {
|
|---|
| 1434 | InheritedOutputInfo ioi;
|
|---|
| 1435 | ioi.of = ci->fh;
|
|---|
| 1436 | ioi.realif = tree;
|
|---|
| 1437 | IDL_tree_traverse_parents(IDL_INTERFACE(tree).inheritance_spec, (GFunc)ch_output_inherited_protos, &ioi);
|
|---|
| 1438 | }
|
|---|
| 1439 |
|
|---|
| 1440 | /* Voyager special struct */
|
|---|
| 1441 | fprintf(ci->fh, "\n/** (%s, %s line %d) **/\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 1442 | fprintf(ci->fh, "\n/** Voyager class data structure **/\n");
|
|---|
| 1443 | fprintf(ci->fh, "NOMEXTERN struct %sClassDataStructure {\n NOMClass *classObject;\n",
|
|---|
| 1444 | id);
|
|---|
| 1445 |
|
|---|
| 1446 | /* For all */
|
|---|
| 1447 | for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1448 | IDL_tree cur;
|
|---|
| 1449 |
|
|---|
| 1450 | cur = IDL_LIST(sub).data;
|
|---|
| 1451 |
|
|---|
| 1452 | switch(IDL_NODE_TYPE(cur)) {
|
|---|
| 1453 | case IDLN_OP_DCL:
|
|---|
| 1454 | orbit_idl_check_oneway_op (cur);
|
|---|
| 1455 |
|
|---|
| 1456 | /* NOM allows method overriding. This is done using a macro which builds a method
|
|---|
| 1457 | name containing the string __OVERRIDE__. Make sure these methods are not put
|
|---|
| 1458 | into the class structure holding introduced methods. */
|
|---|
| 1459 | if(!strstr(IDL_IDENT (IDL_OP_DCL (cur).ident).str, "__OVERRIDE__"))
|
|---|
| 1460 | {
|
|---|
| 1461 | VoyagerOutputClassDataStructMember(ci->fh, cur, "");
|
|---|
| 1462 | fprintf(ci->fh, ";\n");
|
|---|
| 1463 | }
|
|---|
| 1464 | break;
|
|---|
| 1465 | case IDLN_ATTR_DCL:
|
|---|
| 1466 | {
|
|---|
| 1467 | OIDL_Attr_Info *ai;
|
|---|
| 1468 | IDL_tree curitem;
|
|---|
| 1469 |
|
|---|
| 1470 | for(curitem = IDL_ATTR_DCL(cur).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1471 | ai = IDL_LIST(curitem).data->data;
|
|---|
| 1472 | #ifdef USE_LIBIDL_CODE
|
|---|
| 1473 | /* Get methods for attributes */
|
|---|
| 1474 | orbit_cbe_op_write_proto(ci->fh, ai->op1, "", FALSE);
|
|---|
| 1475 | fprintf(ci->fh, ";\n");
|
|---|
| 1476 | /* Set method for attributes */
|
|---|
| 1477 | if(ai->op2) {
|
|---|
| 1478 | orbit_cbe_op_write_proto(ci->fh, ai->op2, "", FALSE);
|
|---|
| 1479 | fprintf(ci->fh, ";\n");
|
|---|
| 1480 | }
|
|---|
| 1481 | #else
|
|---|
| 1482 | #if 0
|
|---|
| 1483 | /* 11.03.2007: We don't use attributes for now! */
|
|---|
| 1484 | /* We put the attribute methods automatically into the *ClassStruct.
|
|---|
| 1485 | That's different to SOM where you have to put them in the releaseorder list
|
|---|
| 1486 | if desired. Maybe we should just ignore Attributes... */
|
|---|
| 1487 | VoyagerOutputClassDataStructAttributeMember(ci->fh, ai->op1, "", FALSE);
|
|---|
| 1488 | fprintf(ci->fh, ";\n");
|
|---|
| 1489 | if(ai->op2) {
|
|---|
| 1490 | VoyagerOutputClassDataStructAttributeMember(ci->fh, ai->op2, "", FALSE);
|
|---|
| 1491 | fprintf(ci->fh, ";\n");
|
|---|
| 1492 | }
|
|---|
| 1493 | #endif
|
|---|
| 1494 | #endif
|
|---|
| 1495 | }/* for() */
|
|---|
| 1496 | }
|
|---|
| 1497 | break;
|
|---|
| 1498 | default:
|
|---|
| 1499 | break;
|
|---|
| 1500 | }/* switch */
|
|---|
| 1501 | }/* for */
|
|---|
| 1502 | /* Voyager special struct */
|
|---|
| 1503 | fprintf(ci->fh, "} %sClassData;\n\n", id);
|
|---|
| 1504 |
|
|---|
| 1505 | /******* Print generic object check function *******/
|
|---|
| 1506 |
|
|---|
| 1507 | if(!strcmp(id, "NOMObject"))
|
|---|
| 1508 | fprintf(ci->fh, "NOMEXTERN gboolean NOMLINK nomCheckNOMObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n");
|
|---|
| 1509 | else
|
|---|
| 1510 | fprintf(ci->fh, "NOMEXTERN gboolean NOMLINK nomCheckObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n");
|
|---|
| 1511 |
|
|---|
| 1512 | /******* Print introduced methods *******/
|
|---|
| 1513 | for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1514 | IDL_tree cur;
|
|---|
| 1515 |
|
|---|
| 1516 | cur = IDL_LIST(sub).data;
|
|---|
| 1517 |
|
|---|
| 1518 | switch(IDL_NODE_TYPE(cur)) {
|
|---|
| 1519 | case IDLN_OP_DCL:
|
|---|
| 1520 | orbit_idl_check_oneway_op (cur);
|
|---|
| 1521 |
|
|---|
| 1522 | if(!strstr(IDL_IDENT (IDL_OP_DCL (cur).ident).str, "__OVERRIDE__"))
|
|---|
| 1523 | {
|
|---|
| 1524 | fprintf(ci->fh, "/* %s, %s line %d */\n ", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 1525 | fprintf(ci->fh, "/*\n * NEW_METHOD: ");
|
|---|
| 1526 | fprintf(ci->fh, "%s %s\n */\n", IDL_IDENT (IDL_OP_DCL (cur).ident).str, id );
|
|---|
| 1527 | /* Do print... */
|
|---|
| 1528 | VoyagerOutputNewMethod(ci->fh, cur, "");
|
|---|
| 1529 | }
|
|---|
| 1530 | break;
|
|---|
| 1531 | default:
|
|---|
| 1532 | break;
|
|---|
| 1533 | }/* switch */
|
|---|
| 1534 | }/* for */
|
|---|
| 1535 | fprintf(ci->fh, "\n");
|
|---|
| 1536 | /******* Print introduced method for possible postprocessing *******/
|
|---|
| 1537 |
|
|---|
| 1538 | /******* Output overriden methods *******/
|
|---|
| 1539 | for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1540 | IDL_tree cur;
|
|---|
| 1541 |
|
|---|
| 1542 | cur = IDL_LIST(sub).data;
|
|---|
| 1543 |
|
|---|
| 1544 | switch(IDL_NODE_TYPE(cur)) {
|
|---|
| 1545 | case IDLN_OP_DCL:
|
|---|
| 1546 | {
|
|---|
| 1547 | char* ptr;
|
|---|
| 1548 | orbit_idl_check_oneway_op (cur);
|
|---|
| 1549 |
|
|---|
| 1550 | if((ptr=strstr(IDL_IDENT (IDL_OP_DCL (cur).ident).str, "__OVERRIDE__"))!=NULL)
|
|---|
| 1551 | {
|
|---|
| 1552 | /* There's an overriden method here */
|
|---|
| 1553 | *ptr='\0';
|
|---|
| 1554 | fprintf(ci->fh, "/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 1555 | fprintf(ci->fh, "/* OVERRIDE_METHOD: ");
|
|---|
| 1556 | fprintf(ci->fh, "%s %s */\n", IDL_IDENT (IDL_OP_DCL (cur).ident).str, id );
|
|---|
| 1557 | fprintf(ci->fh, "#ifdef %s_%s\n", id, IDL_IDENT (IDL_OP_DCL (cur).ident).str);
|
|---|
| 1558 | fprintf(ci->fh, "#undef %s_%s\n", id, IDL_IDENT (IDL_OP_DCL (cur).ident).str);
|
|---|
| 1559 | fprintf(ci->fh, "#endif\n");
|
|---|
| 1560 |
|
|---|
| 1561 | /* Try to find the interface introducing this method */
|
|---|
| 1562 |
|
|---|
| 1563 | /* Inherited */
|
|---|
| 1564 | if(IDL_INTERFACE(tree).inheritance_spec) {
|
|---|
| 1565 | InheritedOutputInfo ioi;
|
|---|
| 1566 | ioi.of = ci->fh;
|
|---|
| 1567 | ioi.realif = tree;
|
|---|
| 1568 | ioi.chrOverridenMethodName=IDL_IDENT (IDL_OP_DCL (cur).ident).str;
|
|---|
| 1569 | IDL_tree_traverse_parents(IDL_INTERFACE(tree).inheritance_spec,
|
|---|
| 1570 | (GFunc)VoyagerOutputOverridenMethod, &ioi);
|
|---|
| 1571 | }
|
|---|
| 1572 | *ptr='_';
|
|---|
| 1573 | }
|
|---|
| 1574 | break;
|
|---|
| 1575 | }
|
|---|
| 1576 | default:
|
|---|
| 1577 | break;
|
|---|
| 1578 | }/* switch */
|
|---|
| 1579 | }/* for */
|
|---|
| 1580 | fprintf(ci->fh, "\n");
|
|---|
| 1581 | /******* Output overriden methods *******/
|
|---|
| 1582 |
|
|---|
| 1583 | /* */
|
|---|
| 1584 | g_free (id);
|
|---|
| 1585 | }/* case */
|
|---|
| 1586 | break;
|
|---|
| 1587 | default:
|
|---|
| 1588 | break;
|
|---|
| 1589 | }
|
|---|
| 1590 | }
|
|---|
| 1591 |
|
|---|
| 1592 | /*
|
|---|
| 1593 | This function writes the params of methods. The typespec is not written.
|
|---|
| 1594 | This function is useful for putting parameters into macros.
|
|---|
| 1595 | */
|
|---|
| 1596 | static void
|
|---|
| 1597 | VoyagerOutputMethodParamsNoTypeSpec(FILE *of, IDL_tree tree, const char *nom_prefix)
|
|---|
| 1598 | {
|
|---|
| 1599 | IDL_tree curitem;
|
|---|
| 1600 |
|
|---|
| 1601 | g_assert (IDL_NODE_TYPE(tree) == IDLN_OP_DCL);
|
|---|
| 1602 |
|
|---|
| 1603 | /* add the parms */
|
|---|
| 1604 | for(curitem = IDL_OP_DCL(tree).parameter_dcls;
|
|---|
| 1605 | curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1606 | IDL_tree tr;
|
|---|
| 1607 |
|
|---|
| 1608 | tr = IDL_LIST(curitem).data;
|
|---|
| 1609 | /* Write list of params */
|
|---|
| 1610 | if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL)
|
|---|
| 1611 | {
|
|---|
| 1612 | fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str);
|
|---|
| 1613 | }
|
|---|
| 1614 | }
|
|---|
| 1615 | return ;
|
|---|
| 1616 | }
|
|---|
| 1617 |
|
|---|
| 1618 | static void
|
|---|
| 1619 | ch_output_inherited_protos(IDL_tree curif, InheritedOutputInfo *ioi)
|
|---|
| 1620 | {
|
|---|
| 1621 | char *id, *realid;
|
|---|
| 1622 | IDL_tree curitem;
|
|---|
| 1623 |
|
|---|
| 1624 | if(curif == ioi->realif)
|
|---|
| 1625 | return;
|
|---|
| 1626 |
|
|---|
| 1627 | realid = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(ioi->realif).ident), "_", 0);
|
|---|
| 1628 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curif).ident), "_", 0);
|
|---|
| 1629 |
|
|---|
| 1630 | for(curitem = IDL_INTERFACE(curif).body; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1631 | IDL_tree curop = IDL_LIST(curitem).data;
|
|---|
| 1632 |
|
|---|
| 1633 | switch(IDL_NODE_TYPE(curop)) {
|
|---|
| 1634 | case IDLN_OP_DCL:
|
|---|
| 1635 | /* Only output methods which are not overriden. Overriden methods are also
|
|---|
| 1636 | put into the data but they're marked with __OVERRIDE__. */
|
|---|
| 1637 | if(!strstr(IDL_IDENT (IDL_OP_DCL (curop).ident).str, "__OVERRIDE__"))
|
|---|
| 1638 | {
|
|---|
| 1639 | fprintf(ioi->of, "/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__);
|
|---|
| 1640 | // fprintf(ioi->of, "#define %s_%s %s_%s\n",
|
|---|
| 1641 | // realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str,
|
|---|
| 1642 | // id, IDL_IDENT(IDL_OP_DCL(curop).ident).str);
|
|---|
| 1643 | fprintf(ioi->of, "#define %s_%s(nomSelf,",realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str);
|
|---|
| 1644 | VoyagerOutputMethodParamsNoTypeSpec(ioi->of, curop, "");
|
|---|
| 1645 | fprintf(ioi->of, " ev) \\\n %s_%s((%s*) nomSelf,",
|
|---|
| 1646 | id, IDL_IDENT(IDL_OP_DCL(curop).ident).str, id);
|
|---|
| 1647 | VoyagerOutputMethodParamsNoTypeSpec(ioi->of, curop, "");
|
|---|
| 1648 | fprintf(ioi->of, " ev)\n");
|
|---|
| 1649 | }
|
|---|
| 1650 | break;
|
|---|
| 1651 | #if 0
|
|---|
| 1652 | /* We don't use _Set*() and _Get*() methods with attributes in Voyager */
|
|---|
| 1653 | case IDLN_ATTR_DCL:
|
|---|
| 1654 | {
|
|---|
| 1655 | IDL_tree curitem;
|
|---|
| 1656 |
|
|---|
| 1657 | /* We don't use OIDL_Attr_Info here because inherited ops may go back into trees that are output-inhibited
|
|---|
| 1658 | and therefore don't have the OIDL_Attr_Info generated on them */
|
|---|
| 1659 |
|
|---|
| 1660 | for(curitem = IDL_ATTR_DCL(curop).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1661 | IDL_tree ident;
|
|---|
| 1662 |
|
|---|
| 1663 | ident = IDL_LIST(curitem).data;
|
|---|
| 1664 |
|
|---|
| 1665 | fprintf(ioi->of, "#define %s__get_%s %s__get_%s\n",
|
|---|
| 1666 | realid, IDL_IDENT(ident).str,
|
|---|
| 1667 | id, IDL_IDENT(ident).str);
|
|---|
| 1668 |
|
|---|
| 1669 | if(!IDL_ATTR_DCL(curop).f_readonly)
|
|---|
| 1670 | fprintf(ioi->of, "#define %s__set_%s %s__set_%s\n",
|
|---|
| 1671 | realid, IDL_IDENT(ident).str,
|
|---|
| 1672 | id, IDL_IDENT(ident).str);
|
|---|
| 1673 | }/* for() */
|
|---|
| 1674 | }
|
|---|
| 1675 | break;
|
|---|
| 1676 | #endif
|
|---|
| 1677 | default:
|
|---|
| 1678 | break;
|
|---|
| 1679 | }
|
|---|
| 1680 | }
|
|---|
| 1681 |
|
|---|
| 1682 | g_free(id);
|
|---|
| 1683 | g_free(realid);
|
|---|
| 1684 | }
|
|---|
| 1685 |
|
|---|
| 1686 | static void
|
|---|
| 1687 | doskel(IDL_tree cur, OIDL_Run_Info *rinfo, char *ifid, OIDL_C_Info *ci)
|
|---|
| 1688 | {
|
|---|
| 1689 | char *id;
|
|---|
| 1690 |
|
|---|
| 1691 | id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(cur).ident), "_", 0);
|
|---|
| 1692 |
|
|---|
| 1693 | fprintf(ci->fh, "void _ORBIT_skel_small_%s("
|
|---|
| 1694 | "POA_%s *_ORBIT_servant, "
|
|---|
| 1695 | "gpointer _ORBIT_retval, "
|
|---|
| 1696 | "gpointer *_ORBIT_args, "
|
|---|
| 1697 | "CORBA_Context ctx,"
|
|---|
| 1698 | "CORBA_Environment *ev, ", id, ifid);
|
|---|
| 1699 | orbit_cbe_op_write_proto(ci->fh, cur, "_impl_", TRUE);
|
|---|
| 1700 | fprintf(ci->fh, ");\n");
|
|---|
| 1701 |
|
|---|
| 1702 | g_free(id);
|
|---|
| 1703 | }
|
|---|
| 1704 |
|
|---|
| 1705 | static void
|
|---|
| 1706 | ch_output_skel_protos(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci)
|
|---|
| 1707 | {
|
|---|
| 1708 | if(!tree) return;
|
|---|
| 1709 |
|
|---|
| 1710 | if ( tree->declspec & IDLF_DECLSPEC_PIDL )
|
|---|
| 1711 | return;
|
|---|
| 1712 |
|
|---|
| 1713 | switch(IDL_NODE_TYPE(tree)) {
|
|---|
| 1714 | case IDLN_MODULE:
|
|---|
| 1715 | ch_output_skel_protos(IDL_MODULE(tree).definition_list, rinfo, ci);
|
|---|
| 1716 | break;
|
|---|
| 1717 | case IDLN_LIST:
|
|---|
| 1718 | {
|
|---|
| 1719 | IDL_tree sub;
|
|---|
| 1720 |
|
|---|
| 1721 | for(sub = tree; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1722 | ch_output_skel_protos(IDL_LIST(sub).data, rinfo, ci);
|
|---|
| 1723 | }
|
|---|
| 1724 | }
|
|---|
| 1725 | break;
|
|---|
| 1726 | case IDLN_INTERFACE:
|
|---|
| 1727 | {
|
|---|
| 1728 | IDL_tree sub;
|
|---|
| 1729 | char *ifid;
|
|---|
| 1730 |
|
|---|
| 1731 | ifid = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(tree).ident), "_", 0);
|
|---|
| 1732 |
|
|---|
| 1733 | for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) {
|
|---|
| 1734 | IDL_tree cur;
|
|---|
| 1735 |
|
|---|
| 1736 | cur = IDL_LIST(sub).data;
|
|---|
| 1737 |
|
|---|
| 1738 | switch(IDL_NODE_TYPE(cur)) {
|
|---|
| 1739 | case IDLN_OP_DCL:
|
|---|
| 1740 | doskel(cur, rinfo, ifid, ci);
|
|---|
| 1741 | break;
|
|---|
| 1742 | case IDLN_ATTR_DCL:
|
|---|
| 1743 | {
|
|---|
| 1744 | OIDL_Attr_Info *ai = cur->data;
|
|---|
| 1745 | IDL_tree curitem;
|
|---|
| 1746 |
|
|---|
| 1747 | for(curitem = IDL_ATTR_DCL(cur).simple_declarations; curitem; curitem = IDL_LIST(curitem).next) {
|
|---|
| 1748 | ai = IDL_LIST(curitem).data->data;
|
|---|
| 1749 |
|
|---|
| 1750 | doskel(ai->op1, rinfo, ifid, ci);
|
|---|
| 1751 | if(ai->op2)
|
|---|
| 1752 | doskel(ai->op2, rinfo, ifid, ci);
|
|---|
| 1753 | }
|
|---|
| 1754 | }
|
|---|
| 1755 | break;
|
|---|
| 1756 | default:
|
|---|
| 1757 | break;
|
|---|
| 1758 | }
|
|---|
| 1759 | }
|
|---|
| 1760 | g_free(ifid);
|
|---|
| 1761 | }
|
|---|
| 1762 | break;
|
|---|
| 1763 | default:
|
|---|
| 1764 | break;
|
|---|
| 1765 | }
|
|---|
| 1766 | }
|
|---|
| 1767 |
|
|---|
| 1768 | static void
|
|---|
| 1769 | ch_output_itypes (IDL_tree tree, OIDL_C_Info *ci)
|
|---|
| 1770 | {
|
|---|
| 1771 | static int num_methods = 0;
|
|---|
| 1772 |
|
|---|
| 1773 | if (!tree)
|
|---|
| 1774 | return;
|
|---|
| 1775 |
|
|---|
| 1776 | switch(IDL_NODE_TYPE(tree)) {
|
|---|
| 1777 | case IDLN_MODULE:
|
|---|
| 1778 | ch_output_itypes (IDL_MODULE(tree).definition_list, ci);
|
|---|
| 1779 | break;
|
|---|
| 1780 | case IDLN_LIST: {
|
|---|
| 1781 | IDL_tree sub;
|
|---|
| 1782 | for (sub = tree; sub; sub = IDL_LIST(sub).next)
|
|---|
| 1783 | ch_output_itypes (IDL_LIST(sub).data, ci);
|
|---|
| 1784 | }
|
|---|
| 1785 | break;
|
|---|
| 1786 | case IDLN_ATTR_DCL: {
|
|---|
| 1787 | OIDL_Attr_Info *ai = tree->data;
|
|---|
| 1788 |
|
|---|
| 1789 | IDL_tree curitem;
|
|---|
| 1790 |
|
|---|
| 1791 | for(curitem = IDL_ATTR_DCL(tree).simple_declarations; curitem;
|
|---|
| 1792 | curitem = IDL_LIST(curitem).next) {
|
|---|
| 1793 | ai = IDL_LIST(curitem).data->data;
|
|---|
| 1794 |
|
|---|
| 1795 | ch_output_itypes (ai->op1, ci);
|
|---|
| 1796 | if(ai->op2)
|
|---|
| 1797 | ch_output_itypes (ai->op2, ci);
|
|---|
| 1798 | }
|
|---|
| 1799 | }
|
|---|
| 1800 | break;
|
|---|
| 1801 |
|
|---|
| 1802 | case IDLN_INTERFACE: {
|
|---|
| 1803 | char *id;
|
|---|
| 1804 |
|
|---|
| 1805 | id = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (
|
|---|
| 1806 | IDL_INTERFACE (tree).ident), "_", 0);
|
|---|
| 1807 |
|
|---|
| 1808 | ch_output_itypes (IDL_INTERFACE(tree).body, ci);
|
|---|
| 1809 |
|
|---|
| 1810 | fprintf (ci->fh, "#ifdef ORBIT_IDL_C_IMODULE_%s\n",
|
|---|
| 1811 | ci->c_base_name);
|
|---|
| 1812 | fprintf (ci->fh, "static \n");
|
|---|
| 1813 | fprintf (ci->fh, "#else\n");
|
|---|
| 1814 | fprintf (ci->fh, "extern \n");
|
|---|
| 1815 | fprintf (ci->fh, "#endif\n");
|
|---|
| 1816 | fprintf (ci->fh, "ORBit_IInterface %s__iinterface;\n", id);
|
|---|
| 1817 |
|
|---|
| 1818 | fprintf (ci->fh, "#define %s_IMETHODS_LEN %d\n", id, num_methods);
|
|---|
| 1819 |
|
|---|
| 1820 | if (num_methods == 0)
|
|---|
| 1821 | fprintf (ci->fh, "#define %s__imethods (ORBit_IMethod*) NULL\n", id);
|
|---|
| 1822 | else {
|
|---|
| 1823 | fprintf (ci->fh, "#ifdef ORBIT_IDL_C_IMODULE_%s\n",
|
|---|
| 1824 | ci->c_base_name);
|
|---|
| 1825 | fprintf (ci->fh, "static \n");
|
|---|
| 1826 | fprintf (ci->fh, "#else\n");
|
|---|
| 1827 | fprintf (ci->fh, "extern \n");
|
|---|
| 1828 | fprintf (ci->fh, "#endif\n");
|
|---|
| 1829 | fprintf (ci->fh, "ORBit_IMethod %s__imethods[%s_IMETHODS_LEN];\n", id, id);
|
|---|
| 1830 | }
|
|---|
| 1831 |
|
|---|
| 1832 |
|
|---|
| 1833 | num_methods = 0;
|
|---|
| 1834 |
|
|---|
| 1835 | break;
|
|---|
| 1836 | }
|
|---|
| 1837 |
|
|---|
| 1838 | case IDLN_OP_DCL:
|
|---|
| 1839 | num_methods++;
|
|---|
| 1840 | break;
|
|---|
| 1841 | default:
|
|---|
| 1842 | break;
|
|---|
| 1843 | }
|
|---|
| 1844 | }
|
|---|