Changeset 29118 in vbox for trunk/src/libs/xpcom18a4/xpcom
- Timestamp:
- May 6, 2010 3:05:29 AM (15 years ago)
- Location:
- trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl.h
r1 r29118 15 15 * The Original Code is mozilla.org code. 16 16 * 17 * The Initial Developer of the Original Code is 17 * The Initial Developer of the Original Code is 18 18 * Netscape Communications Corporation. 19 19 * Portions created by the Initial Developer are Copyright (C) 1998 … … 23 23 * 24 24 * Alternatively, the contents of this file may be used under the terms of 25 * either the GNU General Public License Version 2 or later (the "GPL"), or 25 * either the GNU General Public License Version 2 or later (the "GPL"), or 26 26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 27 * in which case the provisions of the GPL or the LGPL are applicable instead … … 108 108 /* Function that produces a struct of output-generation functions */ 109 109 typedef backend *(*backendFactory)(); 110 110 111 111 extern backend *xpidl_header_dispatch(void); 112 112 extern backend *xpidl_typelib_dispatch(void); … … 135 135 nodeHandler *dispatch; 136 136 void *priv; /* mode-private data */ 137 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 138 char *real_outname; 139 #endif 140 137 141 }; 138 142 … … 257 261 /* 258 262 * Verifies the interface declaration 259 */ 263 */ 260 264 gboolean 261 265 verify_interface_declaration(IDL_tree method_tree); -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_idl.c
r1 r29118 15 15 * The Original Code is mozilla.org code. 16 16 * 17 * The Initial Developer of the Original Code is 17 * The Initial Developer of the Original Code is 18 18 * Netscape Communications Corporation. 19 19 * Portions created by the Initial Developer are Copyright (C) 1998 … … 24 24 * 25 25 * Alternatively, the contents of this file may be used under the terms of 26 * either the GNU General Public License Version 2 or later (the "GPL"), or 26 * either the GNU General Public License Version 2 or later (the "GPL"), or 27 27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 28 28 * in which case the provisions of the GPL or the LGPL are applicable instead … … 117 117 */ 118 118 typedef struct input_callback_state { 119 struct input_data *input_stack; /* linked list of input_data */ 119 struct input_data *input_stack; /* linked list of input_data */ 120 120 GHashTable *already_included; /* to prevent redundant includes */ 121 121 IncludePathEntry *include_path; /* search path for included files */ … … 266 266 if (!(data->point[0] == '%' && data->point[1] == '{')) 267 267 return 0; 268 268 269 269 start = *startp = data->point; 270 270 271 271 end = NULL; 272 272 while (start < data->max && (end = strstr(start, "%}"))) { … … 305 305 int skippedLines = 0; 306 306 char *tempPoint; 307 307 308 308 /* get current lineno */ 309 309 IDL_file_get(NULL,(int *)&data->lineno); … … 317 317 data->lineno += skippedLines; 318 318 IDL_file_set(data->filename, (int)data->lineno); 319 319 320 320 *startp = end + 2; 321 321 … … 355 355 return 0; 356 356 } 357 357 358 358 filename = data->point + 10; /* skip #include " */ 359 359 XPT_ASSERT(filename < data->max); … … 379 379 } 380 380 *end = '\0'; 381 381 382 382 /* make sure we have accurate line info */ 383 383 IDL_file_get(&scratch, (int *)&data->lineno); … … 400 400 */ 401 401 char *filename_cp = xpidl_strdup(filename); 402 402 403 403 /* note that g_slist_append accepts and likes null as list-start. */ 404 404 callback_state->base_includes = … … 436 436 *lenp = 0; /* this is magic, see the comment below */ 437 437 return 1; 438 } 438 } 439 439 440 440 static void … … 454 454 (point > data->point && \ 455 455 (point[-1] == '\r' || point[-1] == '\n'))) 456 456 457 457 while (point < data->max) { 458 458 if (point[0] == '/' && point[1] == '*') … … 536 536 IDL_inhibit_pop(); 537 537 } 538 538 539 539 /* 540 540 * Now we scan for sequences which require special attention: … … 542 542 * \n%{ begins a raw-source block 543 543 * /\* begins a comment 544 * 544 * 545 545 * We used to be fancier here, so make sure that we sent the most 546 546 * data possible at any given time. To that end, we skipped over 547 547 * \n%{ raw \n%} blocks and then _continued_ the search for special 548 548 * sequences like \n#include or /\* comments . 549 * 549 * 550 550 * It was really ugly, though -- liberal use of goto! lots of implicit 551 551 * state! what fun! -- so now we just do this: … … 739 739 real_outname = g_strdup(outname); 740 740 } else { 741 /* 741 /* 742 742 *This combination seems a little strange, what about OS/2? 743 743 * Assume it's some build issue … … 766 766 } 767 767 state.tree = top; 768 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 769 state.real_outname = real_outname; 770 #endif 768 771 769 772 if (emitter->emit_prolog) -
trunk/src/libs/xpcom18a4/xpcom/typelib/xpidl/xpidl_java.c
r1 r29118 13 13 * The Original Code is mozilla.org code. 14 14 * 15 * The Initial Developer of the Original Code is Sun Microsystems, 15 * The Initial Developer of the Original Code is Sun Microsystems, 16 16 * Inc. Portions created by Sun are 17 17 * Copyright (C) 1999 Sun Microsystems, Inc. All 18 18 * Rights Reserved. 19 19 * 20 * Contributor(s): 20 * Contributor(s): 21 21 * Michael Allen ([email protected]) 22 22 * Frank Mitchell ([email protected]) … … 61 61 java_prolog(TreeState *state) 62 62 { 63 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 64 const char *basename; 65 const char *ext; 66 #endif 67 63 68 state->priv = calloc(1, sizeof(struct java_priv_data)); 64 69 if (!state->priv) … … 71 76 return FALSE; 72 77 } 73 78 74 79 /* 75 80 * First pass 76 81 */ 77 82 83 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 84 basename = xpidl_basename(state->real_outname ? state->real_outname : state->basename); 85 ext = strrchr(basename, '.'); 86 if (!ext) 87 ext = strchr(basename, '\0'); 88 fprintf(state->file, 89 "/**\n" 90 " * NOTE: THIS IS A GENERATED FILE. PLEASE CONSULT THE ORIGINAL IDL FILE\n" 91 " * FOR THE FULL DOCUMENTION AND LICENSE.\n" 92 " *\n" 93 " * @see <a href=\"http://lxr.mozilla.org/mozilla/search?string=interface+%.*s\">\n" 94 " **/\n" 95 "\n" 96 "package org.mozilla.interfaces;\n" 97 "\n" 98 , ext - basename >= 19 ? 19 : (int)(ext - basename), basename); 99 #else 78 100 fputs("/*\n * ************* DO NOT EDIT THIS FILE ***********\n", 79 101 state->file); 80 81 fprintf(state->file, 82 " *\n * This file was automatically generated from %s.idl.\n", 102 103 fprintf(state->file, 104 " *\n * This file was automatically generated from %s.idl.\n", 83 105 state->basename); 84 106 85 107 fputs(" */\n\n", state->file); 86 87 return TRUE; 88 } 89 90 static gboolean 108 #endif 109 110 return TRUE; 111 } 112 113 static gboolean 91 114 java_epilog(TreeState *state) 92 115 { … … 95 118 free(state->priv); 96 119 state->priv = NULL; 97 120 121 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 98 122 /* 99 123 * Last pass 100 124 */ 101 125 102 126 fprintf(state->file, "\n/*\n * end\n */\n"); 103 104 return TRUE; 105 } 106 107 static gboolean 108 forward_declaration(TreeState *state) 109 { 110 /* 111 * Java doesn't need forward declarations unless the declared 127 #endif 128 129 return TRUE; 130 } 131 132 static gboolean 133 forward_declaration(TreeState *state) 134 { 135 /* 136 * Java doesn't need forward declarations unless the declared 112 137 * class resides in a different package. 113 138 */ … … 126 151 127 152 static gboolean 128 interface_declaration(TreeState *state) 153 interface_declaration(TreeState *state) 129 154 { 130 155 IDL_tree interface = state->tree; … … 135 160 if (!verify_interface_declaration(interface)) 136 161 return FALSE; 162 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 137 163 /* 138 164 * Write out JavaDoc comment … … 140 166 141 167 fprintf(state->file, "\n/**\n * Interface %s\n", interface_name); 168 #endif 142 169 143 170 #ifndef LIBIDL_MAJOR_VERSION … … 147 174 #endif 148 175 176 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 149 177 if (iid != NULL) { 150 178 fprintf(state->file, " *\n * IID: 0x%s\n */\n\n", iid); … … 152 180 fputs(" */\n\n", state->file); 153 181 } 154 182 #endif 155 183 156 184 /* … … 170 198 do { 171 199 172 fprintf(state->file, "%s", 200 fprintf(state->file, "%s", 173 201 IDL_IDENT(IDL_LIST(iterator).data).str); 174 202 175 203 if (IDL_LIST(iterator).next) { 176 204 fputs(", ", state->file); … … 181 209 182 210 fputs("\n{\n", state->file); 183 211 184 212 if (iid) { 185 213 /* … … 187 215 */ 188 216 217 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 218 fputs(" public static final String ", state->file); 219 #else 189 220 fputs(" public static final String ", state->file); 221 #endif 190 222 191 223 /* XXX s.b just "IID" ? */ … … 194 226 } 195 227 228 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 229 fprintf(state->file, " =\n \"{%s}\";\n", iid); 230 231 #else 196 232 fprintf(state->file, "_STRING =\n \"%s\";\n\n", iid); 197 233 … … 204 240 205 241 fprintf(state->file, " =\n new nsID(\"%s\");\n\n", iid); 242 #endif 206 243 } 207 244 … … 209 246 * Advance the state of the tree, go on to process more 210 247 */ 211 248 212 249 state->tree = IDL_INTERFACE(interface).body; 213 250 … … 225 262 process_list(TreeState *state) 226 263 { 264 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 265 /* To make the diffing simple, group the constants, methods and attributes. */ 266 IDL_tree list = state->tree; 267 IDL_tree iter; 268 for (iter = list; iter; iter = IDL_LIST(iter).next) { 269 if (IDL_NODE_TYPE(IDL_LIST(iter).data) == IDLN_CONST_DCL) { 270 state->tree = IDL_LIST(iter).data; 271 if (!xpidl_process_node(state)) 272 return FALSE; 273 } 274 } 275 for (iter = list; iter; iter = IDL_LIST(iter).next) { 276 if (IDL_NODE_TYPE(IDL_LIST(iter).data) == IDLN_ATTR_DCL) { 277 state->tree = IDL_LIST(iter).data; 278 if (!xpidl_process_node(state)) 279 return FALSE; 280 } 281 } 282 for (iter = list; iter; iter = IDL_LIST(iter).next) { 283 if (IDL_NODE_TYPE(IDL_LIST(iter).data) == IDLN_OP_DCL) { 284 state->tree = IDL_LIST(iter).data; 285 if (!xpidl_process_node(state)) 286 return FALSE; 287 } 288 } 289 for (iter = list; iter; iter = IDL_LIST(iter).next) { 290 if ( IDL_NODE_TYPE(IDL_LIST(iter).data) != IDLN_CONST_DCL 291 && IDL_NODE_TYPE(IDL_LIST(iter).data) != IDLN_OP_DCL 292 && IDL_NODE_TYPE(IDL_LIST(iter).data) != IDLN_ATTR_DCL ) { 293 state->tree = IDL_LIST(iter).data; 294 if (!xpidl_process_node(state)) 295 return FALSE; 296 } 297 } 298 299 #else 227 300 IDL_tree iter; 228 301 for (iter = state->tree; iter; iter = IDL_LIST(iter).next) { … … 231 304 return FALSE; 232 305 } 233 return TRUE; 234 } 235 236 static gboolean 237 xpcom_to_java_type (TreeState *state) 306 #endif 307 return TRUE; 308 } 309 310 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 311 static gboolean 312 interface_declaration_wrapper(TreeState *state) 313 { 314 IDL_tree interface = state->tree; 315 char *interface_name = IDL_IDENT(IDL_INTERFACE(interface).ident).str; 316 FILE *org_file = state->file; 317 char *org_name = state->real_outname; 318 void *org_priv = state->priv; 319 gboolean rc; 320 321 /* 322 * Skip non-scriptable interfaces. 323 */ 324 if ( !IDL_tree_property_get(IDL_INTERFACE(interface).ident, "scriptable") 325 && strcmp(interface_name, "nsIAppShell") ) 326 return TRUE; 327 328 /* 329 * GROSS HACK: If the interface isn't the same as the file name, 330 * temporarily switch output file. 331 */ 332 if (state->real_outname) { 333 const char *basename = xpidl_basename(state->real_outname); 334 const char *ext = strrchr(basename, '.'); 335 if ( ext 336 && !strcmp(ext, ".java") 337 && ( strncmp(interface_name, basename, ext - basename) 338 || interface_name[ext - basename] != '.') ) { 339 size_t needed = strlen(state->real_outname) + strlen(interface_name) + strlen(".java") + 4; 340 char *tmp = malloc(needed); 341 if (basename != state->real_outname) 342 sprintf(tmp,"%.*s/%s.java", (int)(basename - state->real_outname - 1), state->real_outname, interface_name); 343 else 344 sprintf(tmp,"%s.java", interface_name); 345 state->file = fopen(tmp, "w"); 346 if (!state->file) { 347 perror("error opening output file"); 348 state->file = org_file; 349 free(tmp); 350 return FALSE; 351 } 352 state->real_outname = tmp; 353 java_prolog(state); 354 } 355 } 356 357 rc = interface_declaration(state); 358 359 if (state->file != org_file) { 360 java_epilog(state); 361 fclose(state->file); 362 free(state->real_outname); 363 state->file = org_file; 364 state->real_outname = org_name; 365 state->priv = org_priv; 366 } 367 return rc; 368 } 369 #endif /* VBOX_XPIDL_EMULATE_GENJIFACES */ 370 371 static gboolean 372 xpcom_to_java_type (TreeState *state) 238 373 { 239 374 if (!state->tree) { … … 249 384 250 385 case IDL_INTEGER_TYPE_SHORT: 386 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 387 if (IDL_TYPE_INTEGER(state->tree).f_signed) 388 fputs("short", state->file); 389 else 390 fputs("int", state->file); 391 #else 251 392 fputs("short", state->file); 393 #endif 252 394 break; 253 395 254 396 case IDL_INTEGER_TYPE_LONG: 397 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 398 if (IDL_TYPE_INTEGER(state->tree).f_signed) 399 fputs("int", state->file); 400 else 401 fputs("long", state->file); 402 #else 255 403 fputs("int", state->file); 404 #endif 256 405 break; 257 406 258 407 case IDL_INTEGER_TYPE_LONGLONG: 408 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 409 if (IDL_TYPE_INTEGER(state->tree).f_signed) 410 fputs("long", state->file); 411 else 412 fputs("double", state->file); 413 #else 259 414 fputs("long", state->file); 415 #endif 260 416 break; 261 417 262 418 default: 263 419 g_error(" Unknown integer type: %d\n", … … 285 441 286 442 case IDLN_TYPE_OCTET: 443 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 444 fputs("short", state->file); 445 #else 287 446 fputs("byte", state->file); 447 #endif 288 448 break; 289 449 … … 298 458 fputs("double", state->file); 299 459 break; 300 460 301 461 default: 302 462 g_error(" Unknown floating point typ: %d\n", … … 312 472 const char *user_type = IDL_NATIVE(IDL_NODE_UP(state->tree)).user_type; 313 473 if (strcmp(user_type, "void") == 0) { 474 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 475 fputs("nsISupports", state->file); 476 #else 314 477 fputs("Object", state->file); 478 #endif 315 479 } 316 480 else if (strcmp(user_type, "nsID") == 0 || … … 319 483 /* XXX: s.b test for "iid" attribute */ 320 484 /* XXX: special class for nsIDs */ 485 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 486 fputs("String", state->file); 487 #else 321 488 fputs("nsID", state->file); 489 #endif 322 490 } 323 491 else { 324 492 /* XXX: special class for opaque types */ 493 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 494 fputs("String", state->file); 495 #else 325 496 fputs("OpaqueValue", state->file); 497 #endif 326 498 } 327 499 } else { … … 329 501 330 502 /* XXX: big kludge; s.b. way to match to typedefs */ 503 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 504 if (strcmp(ident_str, "PRInt8") == 0) { 505 fputs("byte", state->file); 506 } 507 else if (strcmp(ident_str, "PRInt16") == 0 || 508 strcmp(ident_str, "PRUint8") == 0) { 509 fputs("short", state->file); 510 } 511 else if (strcmp(ident_str, "PRInt32") == 0 || 512 strcmp(ident_str, "PRUint16") == 0) { 513 fputs("int", state->file); 514 } 515 else if (strcmp(ident_str, "PRInt64") == 0 || 516 strcmp(ident_str, "PRUint32") == 0 || 517 strcmp(ident_str, "PRThreadPriority") == 0 || 518 strcmp(ident_str, "PRThreadScope") == 0 || 519 strcmp(ident_str, "PRThreadState") == 0) { 520 fputs("long", state->file); 521 } 522 else if (strcmp(ident_str, "PRUint64") == 0) { 523 fputs("double", state->file); 524 } 525 #else 331 526 if (strcmp(ident_str, "PRInt8") == 0 || 332 527 strcmp(ident_str, "PRUint8") == 0) { … … 345 540 fputs("long", state->file); 346 541 } 542 #endif 347 543 else if (strcmp(ident_str, "PRBool") == 0) { 348 544 fputs("boolean", state->file); … … 351 547 fputs("int", state->file); 352 548 } 549 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 550 /* XXX: Use find_underlying_type instead? */ 551 else if ( strcmp(ident_str, "nsresult") == 0 552 || strcmp(ident_str, "size_t") == 0) { 553 fputs("long", state->file); 554 } 555 else if ( strcmp(ident_str, "PRTime") == 0) { 556 fputs("double", state->file); 557 } 558 /* In Javaconnect, we handle weak references internally; no need for the 559 |nsIWeakReference| interface. So just return |nsISupports|. */ 560 else if (strcmp(ident_str, "nsIWeakReference") == 0) { 561 fputs("nsISupports", state->file); 562 } 563 #endif 353 564 else { 354 IDL_tree real_type = 565 IDL_tree real_type = 355 566 g_hash_table_lookup(TYPEDEFS(state), ident_str); 356 567 … … 384 595 385 596 static gboolean 386 xpcom_to_java_param(TreeState *state) 597 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 598 xpcom_to_java_param(TreeState *state, unsigned nparam) 599 #else 600 xpcom_to_java_param(TreeState *state) 601 #endif 387 602 { 388 603 IDL_tree param = state->tree; … … 402 617 */ 403 618 619 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 620 /* XXX: Causes nsILineInputStream::readLine(String[] arg1) where genjifaces drops the []. */ 621 #endif 404 622 if (IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) { 405 623 fputs("[]", state->file); 406 624 } 407 408 /* 409 * Put in name of parameter 625 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 626 /*XXX: nsIConsoleService::getMessageArray ends up with [][] arg1... */ 627 /*else*/ if (IDL_tree_property_get(IDL_PARAM_DCL(param).simple_declarator, "array")) { 628 fputs("[]", state->file); 629 } 630 #endif 631 632 /* 633 * Put in name of parameter 410 634 */ 411 635 412 636 fputc(' ', state->file); 413 637 638 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 639 fprintf(state->file, "arg%u", nparam+1); 640 #else 414 641 fputs(IDL_IDENT(IDL_PARAM_DCL(param).simple_declarator).str, state->file); 415 416 return TRUE; 417 } 418 419 420 static gboolean 421 type_declaration(TreeState *state) 642 #endif 643 644 return TRUE; 645 } 646 647 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 648 static gboolean is_java_keyword(char ch0, const char *name) 649 { 650 static const char * const kJavaKeywords[] = { 651 "abstract", "default", "if" , "private" , "this" , 652 "boolean" , "do" , "implements", "protected" , "throw" , 653 "break" , "double" , "import", "public" , "throws" , 654 "byte" , "else" , "instanceof", "return" , "transient", 655 "case" , "extends", "int" , "short" , "try" , 656 "catch" , "final" , "interface" , "static" , "void" , 657 "char" , "finally", "long" , "strictfp" , "volatile" , 658 "class" , "float" , "native" , "super" , "while" , 659 "const" , "for" , "new" , "switch" , 660 "continue", "goto" , "package" , "synchronized", 661 "assert" , /* added in Java 1.4 */ 662 "enum" , /* added in Java 5.0 */ 663 "clone" , /* clone is a member function of java.lang.Object */ 664 "finalize" /* finalize is a member function of java.lang.Object */ 665 }; 666 unsigned i; 667 for (i = 0; i < sizeof(kJavaKeywords) / sizeof(kJavaKeywords[0]); i++) { 668 if (kJavaKeywords[i][0] == ch0 && !strcmp(&kJavaKeywords[i][1], &name[1])) { 669 return TRUE; 670 } 671 } 672 return FALSE; 673 } 674 #endif 675 676 static gboolean 677 type_declaration(TreeState *state) 422 678 { 423 679 /* … … 439 695 440 696 static gboolean 441 method_declaration(TreeState *state) 697 method_declaration(TreeState *state) 442 698 { 443 699 /* IDL_tree method_tree = state->tree; */ 444 700 struct _IDL_OP_DCL *method = &IDL_OP_DCL(state->tree); 445 gboolean method_notxpcom = 701 gboolean method_notxpcom = 446 702 (IDL_tree_property_get(method->ident, "notxpcom") != NULL); 447 gboolean method_noscript = 703 gboolean method_noscript = 448 704 (IDL_tree_property_get(method->ident, "noscript") != NULL); 449 705 IDL_tree iterator = NULL; 450 706 IDL_tree retval_param = NULL; 451 707 const char *method_name = IDL_IDENT(method->ident).str; 708 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 709 unsigned nparam = 0; 710 #endif 452 711 453 712 if (!verify_method_declaration(state->tree)) 454 713 return FALSE; 455 714 715 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 716 /* 717 * Skip most (todo) non-scriptable and not-xpcom methods. 718 */ 719 if (method_noscript || method_notxpcom) { 720 return TRUE; 721 } 722 #endif 723 456 724 fputc('\n', state->file); 725 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 457 726 xpidl_write_comment(state, 4); 727 #endif 458 728 459 729 /* 460 730 * Write beginning of method declaration 461 731 */ 732 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 733 fputs(" ", state->file); 734 #else 462 735 fputs(" ", state->file); 736 #endif 463 737 if (!method_noscript) { 464 738 /* Nonscriptable methods become package-protected */ … … 468 742 /* 469 743 * Write return type 470 * Unlike C++ headers, Java interfaces return the declared 744 * Unlike C++ headers, Java interfaces return the declared 471 745 * return value; an exception indicates XPCOM method failure. 472 746 */ … … 478 752 } else { 479 753 /* Check for retval attribute */ 480 for (iterator = method->parameter_dcls; iterator != NULL; 754 for (iterator = method->parameter_dcls; iterator != NULL; 481 755 iterator = IDL_LIST(iterator).next) { 482 756 … … 485 759 state->tree = IDL_LIST(iterator).data; 486 760 487 if (IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator, 761 if (IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator, 488 762 "retval")) { 489 763 retval_param = iterator; … … 498 772 return FALSE; 499 773 } 774 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 775 if (IDL_tree_property_get(IDL_PARAM_DCL(IDL_LIST(iterator).data).simple_declarator, "array")) { 776 fputs("[]", state->file); 777 } 778 #endif 500 779 } 501 780 … … 507 786 } 508 787 } 509 788 510 789 /* 511 790 * Write method name 512 791 */ 792 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 793 if (is_java_keyword(tolower(method_name[0]), method_name)) { 794 fprintf(state->file, " %c%s_(", tolower(method_name[0]), method_name + 1); 795 } else { 796 fprintf(state->file, " %c%s(", tolower(method_name[0]), method_name + 1); 797 } 798 #else 513 799 fprintf(state->file, " %c%s(", tolower(method_name[0]), method_name + 1); 800 #endif 514 801 515 802 /* 516 803 * Write parameters 517 804 */ 518 for (iterator = method->parameter_dcls; iterator != NULL; 805 for (iterator = method->parameter_dcls; iterator != NULL; 519 806 iterator = IDL_LIST(iterator).next) { 520 807 … … 527 814 fputs(", ", state->file); 528 815 } 529 816 530 817 state->tree = IDL_LIST(iterator).data; 531 818 819 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 820 if (!xpcom_to_java_param(state, nparam++)) { 821 #else 532 822 if (!xpcom_to_java_param(state)) { 823 #endif 533 824 return FALSE; 534 825 } … … 555 846 556 847 return TRUE; 557 848 558 849 } 559 850 … … 565 856 const char *name = IDL_IDENT(declaration->ident).str; 566 857 IDL_tree real_type; 858 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 859 IDL_tree saved_tree; 860 #endif 567 861 568 862 if (!verify_const_declaration(state->tree)) … … 574 868 575 869 fputc('\n', state->file); 870 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 576 871 xpidl_write_comment(state, 4); 577 872 #endif 873 874 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 875 /* XXX: We get the WRONG signedness of stuff here. PRInt32 -> unsigned long and stuff like that. */ 876 fputs(" public static final ", state->file); 877 switch(IDL_NODE_TYPE(real_type)) { 878 879 case IDLN_TYPE_INTEGER: { 880 switch(IDL_TYPE_INTEGER(real_type).f_type) { 881 882 case IDL_INTEGER_TYPE_SHORT: 883 if (IDL_TYPE_INTEGER(real_type).f_signed) 884 fprintf(state->file, "int %s = %d;\n", name, (int)IDL_INTEGER(declaration->const_exp).value); 885 else 886 fprintf(state->file, "int %s = %u;\n", name, (unsigned)IDL_INTEGER(declaration->const_exp).value); 887 break; 888 889 case IDL_INTEGER_TYPE_LONG: 890 if (IDL_TYPE_INTEGER(state->tree).f_signed) 891 fprintf(state->file, "int %s = %d;\n", name, (int)IDL_INTEGER(declaration->const_exp).value); 892 else 893 fprintf(state->file, "long %s = %uL;\n", name, (unsigned)IDL_INTEGER(declaration->const_exp).value); 894 break; 895 896 case IDL_INTEGER_TYPE_LONGLONG: 897 if (IDL_TYPE_INTEGER(state->tree).f_signed) 898 fprintf(state->file, "long %lldL;\n", name, (long long)IDL_INTEGER(declaration->const_exp).value); 899 else 900 fprintf(state->file, "double %lluL;\n", name, (unsigned long long)IDL_INTEGER(declaration->const_exp).value); 901 break; 902 903 default: 904 g_error(" Unknown integer type: %d\n", 905 IDL_TYPE_INTEGER(state->tree).f_type); 906 return FALSE; 907 908 } 909 break; 910 } 911 default: 912 g_error(" Unknown constant type: %d\n", IDL_NODE_TYPE(real_type)); 913 return FALSE; 914 } 915 #else 578 916 fprintf(state->file, " public static final %s %s = %d;\n", 579 917 (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG 580 918 ? "long" : "short"), 581 919 name, (int) IDL_INTEGER(declaration->const_exp).value); 920 #endif 582 921 583 922 return TRUE; … … 596 935 char *attribute_name = ATTR_IDENT(state->tree).str; 597 936 598 gboolean method_noscript = 937 gboolean method_noscript = 599 938 (IDL_tree_property_get(ATTR_PROPS(state->tree), "noscript") != NULL); 939 940 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 941 /* 942 * Skip most non-scriptable attributes. 943 */ 944 if (method_noscript) { 945 return TRUE; 946 } 947 #endif 600 948 601 949 #if 0 … … 610 958 /* Comment */ 611 959 fputc('\n', state->file); 960 #ifndef VBOX_XPIDL_EMULATE_GENJIFACES 612 961 xpidl_write_comment(state, 4); 962 #endif 613 963 614 964 state->tree = ATTR_TYPE_DECL(state->tree); … … 617 967 * Write access permission ("public" unless nonscriptable) 618 968 */ 969 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 970 fputs(" ", state->file); 971 #else 619 972 fputs(" ", state->file); 973 #endif 620 974 if (!method_noscript) { 621 975 fputs("public ", state->file); … … 628 982 return FALSE; 629 983 } 630 984 631 985 /* 632 986 * Write the name of the accessor ("get") method. … … 638 992 if (!read_only) { 639 993 /* Nonscriptable methods become package-protected */ 994 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 995 fputs("\n ", state->file); 996 #else 640 997 fputs(" ", state->file); 998 #endif 641 999 if (!method_noscript) { 642 1000 fputs("public ", state->file); … … 647 1005 */ 648 1006 fprintf(state->file, "void set%c%s(", 649 toupper(attribute_name[0]), 1007 toupper(attribute_name[0]), 650 1008 attribute_name+1); 651 1009 652 1010 /* 653 1011 * Write the proper Java type for the set operation … … 660 1018 * Write the name of the formal parameter. 661 1019 */ 1020 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 1021 fputs(" arg1);\n", state->file); 1022 #else 662 1023 fputs(" value);\n", state->file); 1024 #endif 663 1025 } 664 1026 … … 687 1049 688 1050 if (!initialized) { 1051 #ifdef VBOX_XPIDL_EMULATE_GENJIFACES 1052 table[IDLN_INTERFACE] = interface_declaration_wrapper; 1053 #else 689 1054 table[IDLN_INTERFACE] = interface_declaration; 1055 #endif 690 1056 table[IDLN_LIST] = process_list; 691 1057 … … 705 1071 return &result; 706 1072 } 1073
Note:
See TracChangeset
for help on using the changeset viewer.