1 /************************************************************************** 2 3 IDL.h (IDL parse tree and namespace components) 4 5 Copyright (C) 1998, 1999 Andrew T. Veliath 6 7 This library is free software; you can redistribute it and/or 8 modify it under the terms of the GNU Library General Public 9 License as published by the Free Software Foundation; either 10 version 2 of the License, or (at your option) any later version. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Library General Public License for more details. 16 17 You should have received a copy of the GNU Library General Public 18 License along with this library; if not, write to the Free 19 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 21 $Id: IDL.h.in,v 1.31 2003/04/12 08:38:27 msakai Exp $ 22 23 ***************************************************************************/ 24 #ifndef __IDL_H 25 #define __IDL_H 26 27 #include <glib.h> 28 29 /* Try to find wchar_t support */ 30 #include <stdlib.h> 31 #if 1 /* HAVE_WCHAR_H */ 32 # include <wchar.h> 33 #endif 34 #if 0 /* HAVE_WCSTR_H */ 35 # include <wcstr.h> 36 #endif 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #include <stdio.h> 43 44 /* version */ 45 #define LIBIDL_GEN_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 46 #define LIBIDL_MAJOR_VERSION 0 47 #define LIBIDL_MINOR_VERSION 8 48 #define LIBIDL_MICRO_VERSION 14 49 #define LIBIDL_VERSION_CODE LIBIDL_GEN_VERSION(0,8,14) 50 51 /* miscellaneous constants */ 52 #define IDL_SUCCESS 0 53 #define IDL_ERROR 1 54 #define IDL_WARNING1 2 55 #define IDL_WARNING2 3 56 #define IDL_WARNING3 4 57 #define IDL_WARNINGMAX IDL_WARNING3 58 59 /* general parse flags */ 60 #define IDLF_VERBOSE (1UL << 0) 61 #define IDLF_NO_EVAL_CONST (1UL << 1) 62 #define IDLF_COMBINE_REOPENED_MODULES (1UL << 2) 63 #define IDLF_PREFIX_FILENAME (1UL << 3) 64 #define IDLF_IGNORE_FORWARDS (1UL << 4) 65 #define IDLF_PEDANTIC (1UL << 5) 66 #define IDLF_INHIBIT_TAG_ONLY (1UL << 6) 67 #define IDLF_INHIBIT_INCLUDES (1UL << 7) 68 #define IDLF_SHOW_CPP_ERRORS (1UL << 8) 69 70 /* syntax extension parse flags */ 71 #define IDLF_TYPECODES (1UL << 16) 72 #define IDLF_XPIDL (1UL << 17) 73 #define IDLF_PROPERTIES (1UL << 18) 74 #define IDLF_CODEFRAGS (1UL << 19) 75 #define IDLF_SRCFILES (1UL << 20) 76 77 /* declaration specification flags */ 78 #define IDLF_DECLSPEC_EXIST (1UL << 0) 79 #define IDLF_DECLSPEC_INHIBIT (1UL << 1) 80 #define IDLF_DECLSPEC_PIDL (1UL << 2) 81 82 /* output flags */ 83 #define IDLF_OUTPUT_NO_NEWLINES (1UL << 0) 84 #define IDLF_OUTPUT_NO_QUALIFY_IDENTS (1UL << 1) 85 #define IDLF_OUTPUT_PROPERTIES (1UL << 2) 86 #define IDLF_OUTPUT_CODEFRAGS (1UL << 3) 87 88 #ifdef G_PLATFORM_WIN32 89 # ifdef LIBIDL_COMPILATION 90 # define LIBIDL_VAR extern /* exported from .def file */ 91 # else 92 # define LIBIDL_VAR extern __declspec(dllimport) 93 # endif 94 #else 95 # define LIBIDL_VAR extern /* empty */ 96 #endif 97 98 /* type casting checks */ 99 #define IDL_check_cast_enable(boolean) do { \ 100 LIBIDL_VAR int __IDL_check_type_casts; \ 101 __IDL_check_type_casts = (boolean); \ 102 } while (0) 103 #define IDL_CHECK_CAST(tree, thetype, name) \ 104 (IDL_check_type_cast(tree, thetype, \ 105 __FILE__, __LINE__, \ 106 G_STRFUNC)->u.name) 107 108 /* GLib 2.0 requires 64-bit types */ 109 #define IDL_LL "ll" 110 typedef gint64 IDL_longlong_t; 111 typedef guint64 IDL_ulonglong_t; 112 113 typedef unsigned int IDL_declspec_t; 114 typedef struct _IDL_tree_node IDL_tree_node; 115 typedef struct _IDL_tree_node * IDL_tree; 116 117 struct _IDL_LIST { 118 IDL_tree data; 119 IDL_tree prev; 120 IDL_tree next; 121 IDL_tree _tail; /* Internal use, may not be valid */ 122 }; 123 124 #define IDL_LIST(a) IDL_CHECK_CAST(a, IDLN_LIST, idl_list) 125 extern IDL_tree IDL_list_new (IDL_tree data); 126 extern IDL_tree IDL_list_concat (IDL_tree orig, 127 IDL_tree append); 128 extern IDL_tree IDL_list_remove (IDL_tree list, 129 IDL_tree p); 130 extern int IDL_list_length (IDL_tree list); 131 extern IDL_tree IDL_list_nth (IDL_tree list, 132 int n); 133 134 struct _IDL_GENTREE { 135 IDL_tree data; 136 GHashTable *siblings; 137 GHashTable *children; 138 GHashFunc hash_func; 139 GCompareFunc key_compare_func; 140 IDL_tree _import; /* Internal use, do not recurse */ 141 char *_cur_prefix; /* Internal use */ 142 }; 143 #define IDL_GENTREE(a) IDL_CHECK_CAST(a, IDLN_GENTREE, idl_gentree) 144 extern IDL_tree IDL_gentree_new (GHashFunc hash_func, 145 GCompareFunc key_compare_func, 146 IDL_tree data); 147 extern IDL_tree IDL_gentree_new_sibling (IDL_tree from, 148 IDL_tree data); 149 extern IDL_tree IDL_gentree_chain_sibling (IDL_tree from, 150 IDL_tree data); 151 extern IDL_tree IDL_gentree_chain_child (IDL_tree from, 152 IDL_tree data); 153 154 struct _IDL_INTEGER { 155 IDL_longlong_t value; 156 }; 157 #define IDL_INTEGER(a) IDL_CHECK_CAST(a, IDLN_INTEGER, idl_integer) 158 extern IDL_tree IDL_integer_new (IDL_longlong_t value); 159 160 struct _IDL_STRING { 161 char *value; 162 }; 163 #define IDL_STRING(a) IDL_CHECK_CAST(a, IDLN_STRING, idl_string) 164 extern IDL_tree IDL_string_new (char *value); 165 166 struct _IDL_WIDE_STRING { 167 wchar_t *value; 168 }; 169 #define IDL_WIDE_STRING(a) IDL_CHECK_CAST(a, IDLN_WIDE_STRING, idl_wide_string) 170 extern IDL_tree IDL_wide_string_new (wchar_t *value); 171 172 struct _IDL_CHAR { 173 char *value; 174 }; 175 #define IDL_CHAR(a) IDL_CHECK_CAST(a, IDLN_CHAR, idl_char) 176 extern IDL_tree IDL_char_new (char *value); 177 178 struct _IDL_WIDE_CHAR { 179 wchar_t *value; 180 }; 181 #define IDL_WIDE_CHAR(a) IDL_CHECK_CAST(a, IDLN_WIDE_CHAR, idl_wide_char) 182 extern IDL_tree IDL_wide_char_new (wchar_t *value); 183 184 struct _IDL_FIXED { 185 char *value; 186 }; 187 #define IDL_FIXED(a) IDL_CHECK_CAST(a, IDLN_FIXED, idl_fixed) 188 extern IDL_tree IDL_fixed_new (char *value); 189 190 struct _IDL_FLOAT { 191 double value; 192 }; 193 #define IDL_FLOAT(a) IDL_CHECK_CAST(a, IDLN_FLOAT, idl_float) 194 extern IDL_tree IDL_float_new (double value); 195 196 struct _IDL_BOOLEAN { 197 unsigned value; 198 }; 199 #define IDL_BOOLEAN(a) IDL_CHECK_CAST(a, IDLN_BOOLEAN, idl_boolean) 200 extern IDL_tree IDL_boolean_new (unsigned value); 201 202 struct _IDL_IDENT { 203 char *str; 204 char *repo_id; 205 GSList *comments; 206 IDL_tree _ns_ref; /* Internal use, do not recurse */ 207 unsigned _flags; /* Internal use */ 208 #define IDLF_IDENT_CASE_MISMATCH_HIT (1UL << 0) 209 }; 210 #define IDL_IDENT(a) IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident) 211 #define IDL_IDENT_TO_NS(a) IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident._ns_ref) 212 #define IDL_IDENT_REPO_ID(a) IDL_CHECK_CAST(a, IDLN_IDENT, idl_ident.repo_id) 213 extern IDL_tree IDL_ident_new (char *str); 214 extern void IDL_queue_new_ident_comment (const char *str); 215 216 enum IDL_float_type { 217 IDL_FLOAT_TYPE_FLOAT, 218 IDL_FLOAT_TYPE_DOUBLE, 219 IDL_FLOAT_TYPE_LONGDOUBLE 220 }; 221 222 struct _IDL_TYPE_FLOAT { 223 enum IDL_float_type f_type; 224 }; 225 #define IDL_TYPE_FLOAT(a) IDL_CHECK_CAST(a, IDLN_TYPE_FLOAT, idl_type_float) 226 extern IDL_tree IDL_type_float_new (enum IDL_float_type f_type); 227 228 struct _IDL_TYPE_FIXED { 229 IDL_tree positive_int_const; 230 IDL_tree integer_lit; 231 }; 232 #define IDL_TYPE_FIXED(a) IDL_CHECK_CAST(a, IDLN_TYPE_FIXED, idl_type_fixed) 233 extern IDL_tree IDL_type_fixed_new (IDL_tree positive_int_const, 234 IDL_tree integer_lit); 235 236 enum IDL_integer_type { 237 IDL_INTEGER_TYPE_SHORT, 238 IDL_INTEGER_TYPE_LONG, 239 IDL_INTEGER_TYPE_LONGLONG 240 }; 241 242 struct _IDL_TYPE_INTEGER { 243 unsigned f_signed : 1; 244 enum IDL_integer_type f_type; 245 }; 246 #define IDL_TYPE_INTEGER(a) IDL_CHECK_CAST(a, IDLN_TYPE_INTEGER, idl_type_integer) 247 extern IDL_tree IDL_type_integer_new (unsigned f_signed, 248 enum IDL_integer_type f_type); 249 250 extern IDL_tree IDL_type_char_new (void); 251 extern IDL_tree IDL_type_wide_char_new (void); 252 extern IDL_tree IDL_type_boolean_new (void); 253 extern IDL_tree IDL_type_octet_new (void); 254 extern IDL_tree IDL_type_any_new (void); 255 extern IDL_tree IDL_type_object_new (void); 256 extern IDL_tree IDL_type_typecode_new (void); 257 258 struct _IDL_TYPE_STRING { 259 IDL_tree positive_int_const; 260 }; 261 #define IDL_TYPE_STRING(a) IDL_CHECK_CAST(a, IDLN_TYPE_STRING, idl_type_string) 262 extern IDL_tree IDL_type_string_new (IDL_tree positive_int_const); 263 264 struct _IDL_TYPE_WIDE_STRING { 265 IDL_tree positive_int_const; 266 }; 267 #define IDL_TYPE_WIDE_STRING(a) IDL_CHECK_CAST(a, IDLN_TYPE_WIDE_STRING, idl_type_wide_string) 268 extern IDL_tree IDL_type_wide_string_new (IDL_tree positive_int_const); 269 270 struct _IDL_TYPE_ENUM { 271 IDL_tree ident; 272 IDL_tree enumerator_list; 273 }; 274 #define IDL_TYPE_ENUM(a) IDL_CHECK_CAST(a, IDLN_TYPE_ENUM, idl_type_enum) 275 extern IDL_tree IDL_type_enum_new (IDL_tree ident, 276 IDL_tree enumerator_list); 277 278 struct _IDL_TYPE_ARRAY { 279 IDL_tree ident; 280 IDL_tree size_list; 281 }; 282 #define IDL_TYPE_ARRAY(a) IDL_CHECK_CAST(a, IDLN_TYPE_ARRAY, idl_type_array) 283 extern IDL_tree IDL_type_array_new (IDL_tree ident, 284 IDL_tree size_list); 285 286 struct _IDL_TYPE_SEQUENCE { 287 IDL_tree simple_type_spec; 288 IDL_tree positive_int_const; 289 }; 290 #define IDL_TYPE_SEQUENCE(a) IDL_CHECK_CAST(a, IDLN_TYPE_SEQUENCE, idl_type_sequence) 291 extern IDL_tree IDL_type_sequence_new (IDL_tree simple_type_spec, 292 IDL_tree positive_int_const); 293 294 struct _IDL_TYPE_STRUCT { 295 IDL_tree ident; 296 IDL_tree member_list; 297 }; 298 #define IDL_TYPE_STRUCT(a) IDL_CHECK_CAST(a, IDLN_TYPE_STRUCT, idl_type_struct) 299 extern IDL_tree IDL_type_struct_new (IDL_tree ident, 300 IDL_tree member_list); 301 302 struct _IDL_TYPE_UNION { 303 IDL_tree ident; 304 IDL_tree switch_type_spec; 305 IDL_tree switch_body; 306 }; 307 #define IDL_TYPE_UNION(a) IDL_CHECK_CAST(a, IDLN_TYPE_UNION, idl_type_union) 308 extern IDL_tree IDL_type_union_new (IDL_tree ident, 309 IDL_tree switch_type_spec, 310 IDL_tree switch_body); 311 struct _IDL_MEMBER { 312 IDL_tree type_spec; 313 IDL_tree dcls; 314 }; 315 #define IDL_MEMBER(a) IDL_CHECK_CAST(a, IDLN_MEMBER, idl_member) 316 extern IDL_tree IDL_member_new (IDL_tree type_spec, 317 IDL_tree dcls); 318 319 struct _IDL_NATIVE { 320 IDL_tree ident; 321 char *user_type; /* XPIDL extension */ 322 }; 323 #define IDL_NATIVE(a) IDL_CHECK_CAST(a, IDLN_NATIVE, idl_native) 324 extern IDL_tree IDL_native_new (IDL_tree ident); 325 326 327 struct _IDL_TYPE_DCL { 328 IDL_tree type_spec; 329 IDL_tree dcls; 330 }; 331 #define IDL_TYPE_DCL(a) IDL_CHECK_CAST(a, IDLN_TYPE_DCL, idl_type_dcl) 332 extern IDL_tree IDL_type_dcl_new (IDL_tree type_spec, 333 IDL_tree dcls); 334 335 struct _IDL_CONST_DCL { 336 IDL_tree const_type; 337 IDL_tree ident; 338 IDL_tree const_exp; 339 }; 340 #define IDL_CONST_DCL(a) IDL_CHECK_CAST(a, IDLN_CONST_DCL, idl_const_dcl) 341 extern IDL_tree IDL_const_dcl_new (IDL_tree const_type, 342 IDL_tree ident, 343 IDL_tree const_exp); 344 345 struct _IDL_EXCEPT_DCL { 346 IDL_tree ident; 347 IDL_tree members; 348 }; 349 #define IDL_EXCEPT_DCL(a) IDL_CHECK_CAST(a, IDLN_EXCEPT_DCL, idl_except_dcl) 350 extern IDL_tree IDL_except_dcl_new (IDL_tree ident, 351 IDL_tree members); 352 353 struct _IDL_ATTR_DCL { 354 unsigned f_readonly : 1; 355 IDL_tree param_type_spec; 356 IDL_tree simple_declarations; 357 }; 358 #define IDL_ATTR_DCL(a) IDL_CHECK_CAST(a, IDLN_ATTR_DCL, idl_attr_dcl) 359 extern IDL_tree IDL_attr_dcl_new (unsigned f_readonly, 360 IDL_tree param_type_spec, 361 IDL_tree simple_declarations); 362 363 struct _IDL_OP_DCL { 364 unsigned __f_noscript : 1; /* Deprecated */ 365 unsigned f_oneway : 1; 366 /* XPIDL extension (varags) */ 367 unsigned f_varargs : 1; 368 IDL_tree op_type_spec; 369 IDL_tree ident; 370 IDL_tree parameter_dcls; 371 IDL_tree raises_expr; 372 IDL_tree context_expr; 373 }; 374 #define IDL_OP_DCL(a) IDL_CHECK_CAST(a, IDLN_OP_DCL, idl_op_dcl) 375 extern IDL_tree IDL_op_dcl_new (unsigned f_oneway, 376 IDL_tree op_type_spec, 377 IDL_tree ident, 378 IDL_tree parameter_dcls, 379 IDL_tree raises_expr, 380 IDL_tree context_expr); 381 382 enum IDL_param_attr { 383 IDL_PARAM_IN, 384 IDL_PARAM_OUT, 385 IDL_PARAM_INOUT 386 }; 387 388 struct _IDL_PARAM_DCL { 389 enum IDL_param_attr attr; 390 IDL_tree param_type_spec; 391 IDL_tree simple_declarator; 392 }; 393 #define IDL_PARAM_DCL(a) IDL_CHECK_CAST(a, IDLN_PARAM_DCL, idl_param_dcl) 394 extern IDL_tree IDL_param_dcl_new (enum IDL_param_attr attr, 395 IDL_tree param_type_spec, 396 IDL_tree simple_declarator); 397 398 struct _IDL_CASE_STMT { 399 IDL_tree labels; 400 IDL_tree element_spec; 401 }; 402 #define IDL_CASE_STMT(a) IDL_CHECK_CAST(a, IDLN_CASE_STMT, idl_case_stmt) 403 extern IDL_tree IDL_case_stmt_new (IDL_tree labels, 404 IDL_tree element_spec); 405 406 struct _IDL_INTERFACE { 407 IDL_tree ident; 408 IDL_tree inheritance_spec; 409 IDL_tree body; 410 }; 411 #define IDL_INTERFACE(a) IDL_CHECK_CAST(a, IDLN_INTERFACE, idl_interface) 412 extern IDL_tree IDL_interface_new (IDL_tree ident, 413 IDL_tree inheritance_spec, 414 IDL_tree body); 415 416 struct _IDL_FORWARD_DCL { 417 IDL_tree ident; 418 }; 419 #define IDL_FORWARD_DCL(a) IDL_CHECK_CAST(a, IDLN_FORWARD_DCL, idl_forward_dcl) 420 extern IDL_tree IDL_forward_dcl_new (IDL_tree ident); 421 422 struct _IDL_MODULE { 423 IDL_tree ident; 424 IDL_tree definition_list; 425 }; 426 #define IDL_MODULE(a) IDL_CHECK_CAST(a, IDLN_MODULE, idl_module) 427 extern IDL_tree IDL_module_new (IDL_tree ident, 428 IDL_tree definition_list); 429 430 enum IDL_binop { 431 IDL_BINOP_OR, 432 IDL_BINOP_XOR, 433 IDL_BINOP_AND, 434 IDL_BINOP_SHR, 435 IDL_BINOP_SHL, 436 IDL_BINOP_ADD, 437 IDL_BINOP_SUB, 438 IDL_BINOP_MULT, 439 IDL_BINOP_DIV, 440 IDL_BINOP_MOD 441 }; 442 443 struct _IDL_BINOP { 444 enum IDL_binop op; 445 IDL_tree left, right; 446 }; 447 #define IDL_BINOP(a) IDL_CHECK_CAST(a, IDLN_BINOP, idl_binop) 448 extern IDL_tree IDL_binop_new (enum IDL_binop op, 449 IDL_tree left, 450 IDL_tree right); 451 452 enum IDL_unaryop { 453 IDL_UNARYOP_PLUS, 454 IDL_UNARYOP_MINUS, 455 IDL_UNARYOP_COMPLEMENT 456 }; 457 458 struct _IDL_UNARYOP { 459 enum IDL_unaryop op; 460 IDL_tree operand; 461 }; 462 #define IDL_UNARYOP(a) IDL_CHECK_CAST(a, IDLN_UNARYOP, idl_unaryop) 463 extern IDL_tree IDL_unaryop_new (enum IDL_unaryop op, 464 IDL_tree operand); 465 466 /* XPIDL code fragments extension. */ 467 struct _IDL_CODEFRAG { 468 char *desc; 469 GSList *lines; 470 }; 471 #define IDL_CODEFRAG(a) IDL_CHECK_CAST(a, IDLN_CODEFRAG, idl_codefrag) 472 extern IDL_tree IDL_codefrag_new (char *desc, 473 GSList *lines); 474 475 /* source/include file marking extension. */ 476 struct _IDL_SRCFILE { 477 char *filename; 478 int seenCnt; 479 gboolean isTop; 480 gboolean wasInhibit; 481 }; 482 #define IDL_SRCFILE(a) IDL_CHECK_CAST(a, IDLN_SRCFILE, idl_srcfile) 483 extern IDL_tree IDL_srcfile_new (char *filename, int seenCnt, gboolean isTop, gboolean wasInhibit); 484 485 /* 486 * IDL_tree_type - Enumerations of node types 487 * 488 * Note this enumerator list is subject to change in the future. A program should not need 489 * more than a recompilation to adjust for a change in this list, so instead of using a 490 * statically initialized jumptable, allocate an array of size IDLN_LAST and assign the 491 * elements manually. 492 */ 493 typedef enum { 494 IDLN_NONE, 495 IDLN_ANY, 496 497 IDLN_LIST, 498 IDLN_GENTREE, 499 IDLN_INTEGER, 500 IDLN_STRING, 501 IDLN_WIDE_STRING, 502 IDLN_CHAR, 503 IDLN_WIDE_CHAR, 504 IDLN_FIXED, 505 IDLN_FLOAT, 506 IDLN_BOOLEAN, 507 IDLN_IDENT, 508 IDLN_TYPE_DCL, 509 IDLN_CONST_DCL, 510 IDLN_EXCEPT_DCL, 511 IDLN_ATTR_DCL, 512 IDLN_OP_DCL, 513 IDLN_PARAM_DCL, 514 IDLN_FORWARD_DCL, 515 IDLN_TYPE_INTEGER, 516 IDLN_TYPE_FLOAT, 517 IDLN_TYPE_FIXED, 518 IDLN_TYPE_CHAR, 519 IDLN_TYPE_WIDE_CHAR, 520 IDLN_TYPE_STRING, 521 IDLN_TYPE_WIDE_STRING, 522 IDLN_TYPE_BOOLEAN, 523 IDLN_TYPE_OCTET, 524 IDLN_TYPE_ANY, 525 IDLN_TYPE_OBJECT, 526 IDLN_TYPE_TYPECODE, 527 IDLN_TYPE_ENUM, 528 IDLN_TYPE_SEQUENCE, 529 IDLN_TYPE_ARRAY, 530 IDLN_TYPE_STRUCT, 531 IDLN_TYPE_UNION, 532 IDLN_MEMBER, 533 IDLN_NATIVE, 534 IDLN_CASE_STMT, 535 IDLN_INTERFACE, 536 IDLN_MODULE, 537 IDLN_BINOP, 538 IDLN_UNARYOP, 539 IDLN_CODEFRAG, 540 IDLN_SRCFILE, 541 542 IDLN_LAST 543 } IDL_tree_type; 544 545 LIBIDL_VAR const char * IDL_tree_type_names[]; 546 547 struct _IDL_tree_node { 548 IDL_tree_type _type; 549 IDL_tree up; /* Do not recurse */ 550 IDL_declspec_t declspec; 551 GHashTable *properties; 552 int refs; 553 char *_file; /* Internal use */ 554 int _line; /* Internal use */ 555 union { 556 struct _IDL_LIST idl_list; 557 struct _IDL_GENTREE idl_gentree; 558 struct _IDL_INTEGER idl_integer; 559 struct _IDL_STRING idl_string; 560 struct _IDL_WIDE_STRING idl_wide_string; 561 struct _IDL_CHAR idl_char; 562 struct _IDL_WIDE_CHAR idl_wide_char; 563 struct _IDL_FIXED idl_fixed; 564 struct _IDL_FLOAT idl_float; 565 struct _IDL_BOOLEAN idl_boolean; 566 struct _IDL_IDENT idl_ident; 567 struct _IDL_TYPE_DCL idl_type_dcl; 568 struct _IDL_CONST_DCL idl_const_dcl; 569 struct _IDL_EXCEPT_DCL idl_except_dcl; 570 struct _IDL_ATTR_DCL idl_attr_dcl; 571 struct _IDL_OP_DCL idl_op_dcl; 572 struct _IDL_PARAM_DCL idl_param_dcl; 573 struct _IDL_FORWARD_DCL idl_forward_dcl; 574 struct _IDL_TYPE_FLOAT idl_type_float; 575 struct _IDL_TYPE_FIXED idl_type_fixed; 576 struct _IDL_TYPE_INTEGER idl_type_integer; 577 struct _IDL_TYPE_ENUM idl_type_enum; 578 struct _IDL_TYPE_STRING idl_type_string; 579 struct _IDL_TYPE_WIDE_STRING idl_type_wide_string; 580 struct _IDL_TYPE_SEQUENCE idl_type_sequence; 581 struct _IDL_TYPE_ARRAY idl_type_array; 582 struct _IDL_TYPE_STRUCT idl_type_struct; 583 struct _IDL_TYPE_UNION idl_type_union; 584 struct _IDL_MEMBER idl_member; 585 struct _IDL_NATIVE idl_native; 586 struct _IDL_CASE_STMT idl_case_stmt; 587 struct _IDL_INTERFACE idl_interface; 588 struct _IDL_MODULE idl_module; 589 struct _IDL_BINOP idl_binop; 590 struct _IDL_UNARYOP idl_unaryop; 591 struct _IDL_CODEFRAG idl_codefrag; 592 struct _IDL_SRCFILE idl_srcfile; 593 } u; 594 595 /* Fields for application use */ 596 guint32 flags; 597 gpointer data; 598 }; 599 #define IDL_NODE_TYPE(a) ((a)->_type) 600 #define IDL_NODE_TYPE_NAME(a) ((a)?IDL_tree_type_names[IDL_NODE_TYPE(a)]:"NULL") 601 #define IDL_NODE_UP(a) ((a)->up) 602 #define IDL_NODE_PROPERTIES(a) ((a)->properties) 603 #define IDL_NODE_DECLSPEC(a) ((a)->declspec) 604 #define IDL_NODE_REFS(a) ((a)->refs) 605 #define IDL_NODE_IS_LITERAL(a) \ 606 (IDL_NODE_TYPE(a) == IDLN_INTEGER || \ 607 IDL_NODE_TYPE(a) == IDLN_STRING || \ 608 IDL_NODE_TYPE(a) == IDLN_WIDE_STRING || \ 609 IDL_NODE_TYPE(a) == IDLN_CHAR || \ 610 IDL_NODE_TYPE(a) == IDLN_WIDE_CHAR || \ 611 IDL_NODE_TYPE(a) == IDLN_FIXED || \ 612 IDL_NODE_TYPE(a) == IDLN_FLOAT || \ 613 IDL_NODE_TYPE(a) == IDLN_BOOLEAN) 614 #define IDL_NODE_IS_TYPE(a) \ 615 (IDL_NODE_TYPE(a) == IDLN_TYPE_INTEGER || \ 616 IDL_NODE_TYPE(a) == IDLN_TYPE_STRING || \ 617 IDL_NODE_TYPE(a) == IDLN_TYPE_WIDE_STRING || \ 618 IDL_NODE_TYPE(a) == IDLN_TYPE_CHAR || \ 619 IDL_NODE_TYPE(a) == IDLN_TYPE_WIDE_CHAR || \ 620 IDL_NODE_TYPE(a) == IDLN_TYPE_FIXED || \ 621 IDL_NODE_TYPE(a) == IDLN_TYPE_FLOAT || \ 622 IDL_NODE_TYPE(a) == IDLN_TYPE_BOOLEAN || \ 623 IDL_NODE_TYPE(a) == IDLN_TYPE_OCTET || \ 624 IDL_NODE_TYPE(a) == IDLN_TYPE_ANY || \ 625 IDL_NODE_TYPE(a) == IDLN_TYPE_OBJECT || \ 626 IDL_NODE_TYPE(a) == IDLN_TYPE_TYPECODE || \ 627 IDL_NODE_TYPE(a) == IDLN_TYPE_ENUM || \ 628 IDL_NODE_TYPE(a) == IDLN_TYPE_ARRAY || \ 629 IDL_NODE_TYPE(a) == IDLN_TYPE_SEQUENCE || \ 630 IDL_NODE_TYPE(a) == IDLN_TYPE_STRUCT || \ 631 IDL_NODE_TYPE(a) == IDLN_TYPE_UNION) 632 #define IDL_NODE_IS_SCOPED(a) \ 633 (IDL_NODE_TYPE(a) == IDLN_IDENT || \ 634 IDL_NODE_TYPE(a) == IDLN_INTERFACE || \ 635 IDL_NODE_TYPE(a) == IDLN_MODULE || \ 636 IDL_NODE_TYPE(a) == IDLN_EXCEPT_DCL || \ 637 IDL_NODE_TYPE(a) == IDLN_OP_DCL || \ 638 IDL_NODE_TYPE(a) == IDLN_TYPE_ENUM || \ 639 IDL_NODE_TYPE(a) == IDLN_TYPE_STRUCT || \ 640 IDL_NODE_TYPE(a) == IDLN_TYPE_UNION) 641 642 typedef struct _IDL_ns * IDL_ns; 643 644 struct _IDL_ns { 645 IDL_tree global; 646 IDL_tree file; 647 IDL_tree current; 648 GHashTable *inhibits; 649 GHashTable *filename_hash; 650 }; 651 #define IDL_NS(a) (*(a)) 652 653 typedef enum { 654 IDL_INPUT_REASON_INIT, 655 IDL_INPUT_REASON_FILL, 656 IDL_INPUT_REASON_ABORT, 657 IDL_INPUT_REASON_FINISH 658 } IDL_input_reason; 659 660 union IDL_input_data { 661 struct { 662 const char *filename; 663 } init; 664 struct { 665 char *buffer; 666 size_t max_size; 667 } fill; 668 }; 669 670 typedef int (*IDL_input_callback) (IDL_input_reason reason, 671 union IDL_input_data *data, 672 gpointer user_data); 673 674 typedef int (*IDL_msg_callback) (int level, 675 int num, 676 int line, 677 const char *filename, 678 const char *message); 679 680 typedef struct _IDL_tree_func_state IDL_tree_func_state; 681 typedef struct _IDL_tree_func_data IDL_tree_func_data; 682 683 #define IDL_WalkF_TypespecOnly (1<<0) 684 685 /* Traversal state data. Recursive walks chain states. */ 686 struct _IDL_tree_func_state { 687 IDL_tree_func_state *up; 688 IDL_tree start; 689 IDL_tree_func_data *bottom; 690 glong flags; 691 }; 692 693 /* This holds a list of the up hierarchy traversed, beginning from traversal. This is 694 * useful since nodes referenced after initial definition will have a different traversal 695 * path than the actual up path. */ 696 struct _IDL_tree_func_data { 697 IDL_tree_func_state *state; 698 IDL_tree_func_data *up; 699 IDL_tree tree; 700 gint step; 701 gpointer data; /* Application data */ 702 gint level; 703 }; 704 705 typedef gboolean (*IDL_tree_func) (IDL_tree_func_data *tnfd, 706 gpointer user_data); 707 708 extern IDL_tree IDL_check_type_cast (const IDL_tree var, 709 IDL_tree_type type, 710 const char *file, 711 int line, 712 const char *function); 713 714 extern const char * IDL_get_libver_string (void); 715 716 extern const char * IDL_get_IDLver_string (void); 717 718 extern int IDL_parse_filename (const char *filename, 719 const char *cpp_args, 720 IDL_msg_callback msg_cb, 721 IDL_tree *tree, IDL_ns *ns, 722 unsigned long parse_flags, 723 int max_msg_level); 724 725 extern int IDL_parse_filename_with_input (const char *filename, 726 IDL_input_callback input_cb, 727 gpointer input_cb_user_data, 728 IDL_msg_callback msg_cb, 729 IDL_tree *tree, IDL_ns *ns, 730 unsigned long parse_flags, 731 int max_msg_level); 732 733 extern int IDL_ns_prefix (IDL_ns ns, 734 const char *s); 735 736 extern void IDL_ns_ID (IDL_ns ns, 737 const char *s); 738 739 extern void IDL_ns_version (IDL_ns ns, 740 const char *s); 741 742 extern int IDL_inhibit_get (void); 743 744 extern void IDL_inhibit_push (void); 745 746 extern void IDL_inhibit_pop (void); 747 748 extern IDL_tree IDL_file_set (const char *filename, 749 int line); 750 751 extern void IDL_file_get (const char **filename, 752 int *line); 753 754 extern IDL_tree IDL_get_parent_node (IDL_tree p, 755 IDL_tree_type type, 756 int *scope_levels); 757 758 extern IDL_tree IDL_tree_get_scope (IDL_tree p); 759 760 extern int IDL_tree_get_node_info (IDL_tree tree, 761 char **who, 762 char **what); 763 764 extern void IDL_tree_error (IDL_tree p, 765 const char *fmt, 766 ...) 767 G_GNUC_PRINTF (2, 3); 768 769 extern void IDL_tree_warning (IDL_tree p, 770 int level, 771 const char *fmt, 772 ...) 773 G_GNUC_PRINTF (3, 4); 774 775 extern const char * IDL_tree_property_get (IDL_tree tree, 776 const char *key); 777 778 extern void IDL_tree_property_set (IDL_tree tree, 779 const char *key, 780 const char *value); 781 782 extern gboolean IDL_tree_property_remove (IDL_tree tree, 783 const char *key); 784 785 extern void IDL_tree_properties_copy (IDL_tree from_tree, 786 IDL_tree to_tree); 787 788 extern void IDL_tree_remove_inhibits (IDL_tree *tree, 789 IDL_ns ns); 790 791 extern void IDL_tree_walk (IDL_tree p, 792 IDL_tree_func_data *current, 793 IDL_tree_func pre_tree_func, 794 IDL_tree_func post_tree_func, 795 gpointer user_data); 796 797 extern void IDL_tree_walk2 (IDL_tree p, 798 IDL_tree_func_data *current, 799 glong flags, 800 IDL_tree_func pre_tree_func, 801 IDL_tree_func post_tree_func, 802 gpointer user_data); 803 804 extern void IDL_tree_walk_in_order (IDL_tree p, 805 IDL_tree_func tree_func, 806 gpointer user_data); 807 808 extern void IDL_tree_free (IDL_tree root); 809 810 extern void IDL_tree_to_IDL (IDL_tree p, 811 IDL_ns ns, 812 FILE *output, 813 unsigned long output_flags); 814 815 extern GString * IDL_tree_to_IDL_string (IDL_tree p, 816 IDL_ns ns, 817 unsigned long output_flags); 818 819 extern gboolean IDL_tree_contains_node (IDL_tree p, 820 IDL_tree searchNode); 821 822 extern gboolean IDL_tree_is_recursive (IDL_tree tree, 823 gpointer dummy); 824 825 extern gchar * IDL_do_escapes (const char *s); 826 827 extern IDL_tree IDL_resolve_const_exp (IDL_tree p, 828 IDL_tree_type type); 829 830 extern IDL_ns IDL_ns_new (void); 831 832 extern void IDL_ns_free (IDL_ns ns); 833 834 extern IDL_tree IDL_ns_resolve_this_scope_ident (IDL_ns ns, 835 IDL_tree scope, 836 IDL_tree ident); 837 838 extern IDL_tree IDL_ns_resolve_ident (IDL_ns ns, 839 IDL_tree ident); 840 841 extern IDL_tree IDL_ns_lookup_this_scope (IDL_ns ns, 842 IDL_tree scope, 843 IDL_tree ident, 844 gboolean *conflict); 845 846 extern IDL_tree IDL_ns_lookup_cur_scope (IDL_ns ns, 847 IDL_tree ident, 848 gboolean *conflict); 849 850 extern IDL_tree IDL_ns_place_new (IDL_ns ns, 851 IDL_tree ident); 852 853 extern void IDL_ns_push_scope (IDL_ns ns, 854 IDL_tree ident); 855 856 extern void IDL_ns_pop_scope (IDL_ns ns); 857 858 extern IDL_tree IDL_ns_qualified_ident_new (IDL_tree nsid); 859 860 extern gchar * IDL_ns_ident_to_qstring (IDL_tree ns_ident, 861 const char *join, 862 int scope_levels); 863 864 extern int IDL_ns_scope_levels_from_here (IDL_ns ns, 865 IDL_tree ident, 866 IDL_tree parent); 867 868 extern gchar * IDL_ns_ident_make_repo_id (IDL_ns ns, 869 IDL_tree p, 870 const char *p_prefix, 871 int *major, 872 int *minor); 873 874 #ifdef __cplusplus 875 } 876 #endif 877 878 #endif /* __IDL_H */ 879