6 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
7 States of America. All Rights Reserved.
9 This product is protected by copyright and distributed under the following
10 license restricting its use.
12 The Interface Definition Language Compiler Front End (CFE) is made
13 available for your use provided that you include this license and copyright
14 notice on all media and documentation and the software program in which
15 this product is incorporated in whole or part. You may copy and extend
16 functionality (but may not remove functionality) of the Interface
17 Definition Language CFE without charge, but you are not authorized to
18 license or distribute it to anyone else except as part of a product or
19 program developed by you or with the express written consent of Sun
20 Microsystems, Inc. ("Sun").
22 The names of Sun Microsystems, Inc. and any of its subsidiaries or
23 affiliates may not be used in advertising or publicity pertaining to
24 distribution of Interface Definition Language CFE as permitted herein.
26 This license is effective until terminated by Sun for failure to comply
27 with this license. Upon termination, you shall destroy or return all code
28 and documentation for the Interface Definition Language CFE.
30 IDL_INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
31 IDL_ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
33 DEALING, USAGE OR TRADE PRACTICE.
35 IDL_INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
36 IDL_ANY OBLIGATION ON THE PART OF Sun OR IDL_ANY OF ITS SUBSIDIARIES OR AFFILIATES
37 TO ASSIST IDL_IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
39 SUN OR IDL_ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
40 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR IDL_ANY PATENTS BY
41 IDL_INTERFACE DEFINITION LANGUAGE CFE OR IDL_ANY PART THEREOF.
43 IDL_IN NO EVENT WILL SUN OR IDL_ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
44 IDL_ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
45 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
47 Use, duplication, or disclosure by the government is subject to
48 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
49 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
52 Sun, Sun Microsystems and the Sun logo are trademarks or registered
53 trademarks of Sun Microsystems, Inc.
57 Mountain View, California 94043
61 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
62 trademarks or registered trademarks of Sun Microsystems, Inc.
67 * idl.ll - Lexical scanner for IDL
70 #include "global_extern.h"
71 #include "nr_extern.h"
72 #include "utl_strlist.h"
73 #include "utl_exprlist.h"
74 #include "utl_labellist.h"
75 #include "utl_decllist.h"
76 #include "utl_string.h"
78 #include "ast_union_label.h"
79 #include "ast_field.h"
80 #include "ast_expression.h"
81 #include "ast_argument.h"
82 #include "ast_operation.h"
84 #include "fe_interface_header.h"
85 #include "fe_obv_header.h"
86 #include "fe_component_header.h"
87 #include "fe_home_header.h"
88 #include "fe_private.h"
89 #include "fe_extern.h"
90 #include "ast_annotation_appl.h"
91 #include "idl.tab.hpp"
93 static char * idl_wstring_escape_reader (char *);
94 static ACE_CDR::WChar idl_wchar_escape_reader (char *);
95 static ACE_CDR::Char idl_escape_reader (char *);
96 static ACE_CDR::Double idl_atof (char *);
97 static ACE_CDR::LongLong idl_atoi (char *, long);
98 static ACE_CDR::ULongLong idl_atoui (char *, long);
99 static void idl_parse_line_and_file (char *);
100 static void idl_store_pragma (char *);
101 static char * idl_get_pragma_string (char *);
102 static bool idl_valid_version (char *);
103 static AST_Decl * idl_find_node (const char *);
105 #define ace_yytext yytext
107 #ifdef USE_MCPP_BUFFER_LEXING
108 #include "mcpp_yyinput.h"
109 #endif /*USE_MCPP_BUFFER_LEXING*/
111 #if defined __ANDROID__ && defined ECHO
117 /* SO we don't choke on files that use \r\n */
121 %option never-interactive
126 Object return IDL_OBJECT;
127 module return IDL_MODULE;
128 raises return IDL_RAISES;
129 readonly return IDL_READONLY;
130 attribute return IDL_ATTRIBUTE;
131 exception return IDL_EXCEPTION;
132 context return IDL_CONTEXT;
133 interface return IDL_INTERFACE;
134 const return IDL_CONST;
135 typedef return IDL_TYPEDEF;
136 struct return IDL_STRUCT;
137 enum return IDL_ENUM;
138 string return IDL_STRING;
139 wstring return IDL_WSTRING;
140 sequence return IDL_SEQUENCE;
141 union return IDL_UNION;
142 fixed return IDL_FIXED;
143 switch return IDL_SWITCH;
144 case return IDL_CASE;
145 default return IDL_DEFAULT;
146 float return IDL_FLOAT;
147 double return IDL_DOUBLE;
148 long return IDL_LONG;
149 short return IDL_SHORT;
150 unsigned return IDL_UNSIGNED;
151 char return IDL_CHAR;
152 wchar return IDL_WCHAR;
153 boolean return IDL_BOOLEAN;
154 octet return IDL_OCTET;
155 void return IDL_VOID;
156 native return IDL_NATIVE;
157 local return IDL_LOCAL;
158 abstract return IDL_ABSTRACT;
161 if (idl_global->idl_version_ >= IDL_VERSION_4)
169 if (idl_global->idl_version_ >= IDL_VERSION_4)
177 if (idl_global->idl_version_ >= IDL_VERSION_4)
185 if (idl_global->idl_version_ >= IDL_VERSION_4)
193 if (idl_global->idl_version_ >= IDL_VERSION_4)
201 if (idl_global->idl_version_ >= IDL_VERSION_4)
209 if (idl_global->idl_version_ >= IDL_VERSION_4)
217 if (idl_global->idl_version_ >= IDL_VERSION_4)
225 custom return IDL_CUSTOM;
226 factory return IDL_FACTORY;
227 private return IDL_PRIVATE;
228 public return IDL_PUBLIC;
229 supports return IDL_SUPPORTS;
230 truncatable return IDL_TRUNCATABLE;
231 valuetype return IDL_VALUETYPE;
233 component return IDL_COMPONENT;
234 consumes return IDL_CONSUMES;
235 emits return IDL_EMITS;
236 eventtype return IDL_EVENTTYPE;
237 finder return IDL_FINDER;
238 getraises return IDL_GETRAISES;
239 home return IDL_HOME;
240 import return IDL_IMPORT;
241 multiple return IDL_MULTIPLE;
242 primarykey return IDL_PRIMARYKEY;
243 provides return IDL_PROVIDES;
244 publishes return IDL_PUBLISHES;
245 setraises return IDL_SETRAISES;
246 typeid return IDL_TYPEID;
247 typeprefix return IDL_TYPEPREFIX;
248 uses return IDL_USES;
249 manages return IDL_MANAGES;
251 typename return IDL_TYPENAME;
252 port return IDL_PORT;
253 mirrorport return IDL_MIRRORPORT;
254 porttype return IDL_PORTTYPE;
255 connector return IDL_CONNECTOR;
256 alias return IDL_ALIAS;
258 TRUE return IDL_TRUETOK;
259 FALSE return IDL_FALSETOK;
261 inout return IDL_INOUT;
264 oneway return IDL_ONEWAY;
266 \<\< return IDL_LEFT_SHIFT;
267 \>\> return IDL_RIGHT_SHIFT;
269 tao_yylval.strval = ACE::strnew ("::");
270 return IDL_SCOPE_DELIMITOR;
273 @annotation[^A-Za-z0-9_] return IDL_ANNOTATION_DECL; // Allow annotation names that start with "annotation"
274 @ return IDL_ANNOTATION_SYMBOL;
276 [a-ij-rs-zA-IJ-RS-Z_][a-ij-rs-zA-IJ-RS-Z0-9_]* {
277 // Make sure that this identifier is not a C++ keyword. If it is,
278 // prepend it with a _cxx_. Lookup in the perfect hash table for C++
279 // keyword and grab the mapping. BTW, the reason for the odd
280 // regular expression is to handle EBCDIC, as well as ASCII.
282 TAO_IDL_CPP_Keyword_Table cpp_key_tbl;
283 const TAO_IDL_CPP_Keyword_Entry *entry = 0;
284 if (!idl_global->preserve_cpp_keywords())
286 // This check will ensure that escaped C++ keywords will be
287 // caught and prepended with '_cxx' as non-escaped keywords
288 // are now prepended with '_cxx_'.
290 ace_yytext[0] == '_' ? ace_yytext + 1 : ace_yytext;
293 cpp_key_tbl.lookup (tmp,
294 static_cast<unsigned int> (ACE_OS::strlen (tmp)));
299 tao_yylval.strval = ACE::strnew (entry->mapping_);
303 tao_yylval.strval = ACE::strnew (ace_yytext);
309 "-"?(([0-9]+"."[0-9]*)|("."[0-9]+))([eE][+-]?[0-9]+)?[lLfF]? {
310 tao_yylval.dval = idl_atof (ace_yytext);
311 return IDL_FLOATING_PT_LITERAL;
313 "-"?[0-9]+[eE][+-]?[0-9]+[lLfF]? {
314 tao_yylval.dval = idl_atof (ace_yytext);
315 return IDL_FLOATING_PT_LITERAL;
318 "-"?(([0-9]+"."[0-9]*)|("."?[0-9]+))[dD] {
319 tao_yylval.fixval = ACE_CDR::Fixed::from_string (ace_yytext);
320 return IDL_FIXED_PT_LITERAL;
324 tao_yylval.ival = idl_atoi (ace_yytext, 10);
325 return IDL_INTEGER_LITERAL;
328 tao_yylval.uival = idl_atoui (ace_yytext, 10);
329 return IDL_UINTEGER_LITERAL;
331 "-"0[xX][a-fA-F0-9]+ {
332 tao_yylval.ival = idl_atoi (ace_yytext, 16);
333 return IDL_INTEGER_LITERAL;
336 tao_yylval.uival = idl_atoui (ace_yytext, 16);
337 return IDL_UINTEGER_LITERAL;
340 tao_yylval.ival = idl_atoi (ace_yytext, 8);
341 return IDL_INTEGER_LITERAL;
344 tao_yylval.uival = idl_atoui (ace_yytext, 8);
345 return IDL_UINTEGER_LITERAL;
348 (\"([^\\\"]*|\\[ntvbrfax\\\?\'\"]|\\[0-7]{1,3})*\"[ \t]*)+ {
349 /* Skip the quotes */
350 char * const tmp = ace_yytext;
351 for (size_t i = ACE_OS::strlen (tmp); i-- != 0; )
353 if (isspace (tmp[i]))
362 tmp[ACE_OS::strlen (tmp) - 1] = '\0';
363 ACE_NEW_RETURN (tao_yylval.sval,
364 UTL_String (tmp + 1, true),
366 return IDL_STRING_LITERAL;
368 (L\"([^\\\"]*|\\[ntvbrfax\\\?\'\"]|\\[0-7]{1,3}|\\u([0-9a-fA-F]{1,4}))*\"[ \t]*)+ {
369 /* Skip the bookends */
370 char * const tmp = ACE_OS::strdup (ace_yytext);
371 for (size_t i = ACE_OS::strlen (tmp); i-- != 0; )
373 if (isspace (tmp[i]))
382 tmp[ACE_OS::strlen (tmp) - 1] = '\0';
383 tao_yylval.wsval = ACE_OS::strdup (idl_wstring_escape_reader (tmp + 2));
385 return IDL_WSTRING_LITERAL;
388 tao_yylval.cval = ace_yytext[1];
389 return IDL_CHARACTER_LITERAL;
391 "'"\\([0-7]{1,3})"'" {
392 // octal character constant
393 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
394 return IDL_CHARACTER_LITERAL;
396 "'"\\[xX]([0-9a-fA-F]{1,2})"'" {
397 // hexadecimal character constant
398 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
399 return IDL_CHARACTER_LITERAL;
402 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
403 return IDL_CHARACTER_LITERAL;
406 // wide character constant
407 tao_yylval.wcval = ace_yytext[2];
408 return IDL_WCHAR_LITERAL;
410 L"'"\\u([0-9a-fA-F]{1,4})"'" {
411 // hexadecimal wide character constant
412 tao_yylval.wcval = idl_wchar_escape_reader (ace_yytext + 2);
413 return IDL_WCHAR_LITERAL;
415 ^[ \t]*#[ \t]*pragma[ \t].*{NL} |
416 ^\?\?=[ \t]*pragma[ \t].*{NL} {/* remember pragma */
417 idl_global->set_lineno (idl_global->lineno () + 1);
418 idl_store_pragma (ace_yytext);
421 ^[ \t]*#file[ \t].*{NL} |
422 ^\?\?=[ \t]*file[ \t].*{NL} {/* ignore file */
423 idl_global->set_lineno(idl_global->lineno () + 1);
426 ^[ \t]*#[ \t]*[0-9]*" ""\""[^\"]*"\""" "[0-9]*([ \t]*[0-9]*)*{NL} |
427 ^\?\?=[ \t]*[0-9]*" ""\""[^\"]*"\""" "[0-9]*([ \t]*[0-9]*)?{NL} {
428 idl_parse_line_and_file (ace_yytext);
431 ^[ \t]*#[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} |
432 ^\?\?=[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} {
433 idl_parse_line_and_file (ace_yytext);
436 ^[ \t]*#line[ \t]*[0-9]+[ \t]*("\""[^\"]*"\""([ \t]*[0-9]*([ \t]*[0-9]*)?)?)?{NL} |
437 ^\?\?=line[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} {
438 idl_parse_line_and_file (ace_yytext);
441 ^[ \t]*#[ \t]*[0-9]*{NL} |
442 ^\?\?=[ \t]*[0-9]*{NL} {
443 idl_parse_line_and_file (ace_yytext);
446 ^[ \t]*#[ \t]*ident[ \t].*{NL} |
447 ^\?\?=[ \t]*ident[ \t].*{NL} {
448 /* ignore cpp ident */
449 idl_global->set_lineno (idl_global->lineno () + 1);
453 /* ignore comments */
454 idl_global->set_lineno(idl_global->lineno () + 1);
460 char const c = yyinput ();
463 char const next = yyinput ();
471 idl_global->set_lineno (idl_global->lineno () + 1);
478 idl_global->set_lineno (idl_global->lineno () + 1);
481 . return ace_yytext[0];
487 same_file (char *path1, char *path2)
489 char fullpath1 [MAXPATHLEN + 1] = {0};
490 char fullpath2 [MAXPATHLEN + 1] = {0};
492 char *fp1 = ACE_OS::realpath (path1, fullpath1);
493 char *fp2 = ACE_OS::realpath (path2, fullpath2);
496 (fp1 == 0 || fp2 == 0)
498 : FE_Utils::path_cmp (fullpath1,fullpath2) == 0;
501 // Parse a #line statement generated by the C preprocessor
503 idl_parse_line_and_file (char *buf)
519 // Check to see if we're running under the screwy Microsoft scheme
520 // of putting #line num instead of #num.
522 if (ACE_OS::strncmp (r, "line", 4) == 0)
535 for (; isdigit (*r); ++r)
541 idl_global->set_lineno ((long) idl_atoui (h, 10));
543 // Find file name, if present.
544 for (; *r != '"'; ++r)
546 if (*r == '\n' || *r == '\0')
554 for (; *r != '"'; ++r)
564 ACE_ERROR ((LM_ERROR,
565 ACE_TEXT ("IDL: No input files\n")));
574 // Put Microsoft-style pathnames into a canonical form.
575 for (i = 0, j = 0; h[j] != '\0'; i++, j++)
577 if (h[j] == '\\' && h[j + 1] == '\\')
586 #if defined (ACE_OPENVMS)
587 // translate this into *nix format as the OpenVMS preprocessor
588 // possibly produced VMS-style paths here.
589 char trans_path[MAXPATHLEN] = "";
590 char *temp_h = IDL_GlobalData::translateName (h, trans_path);
595 ACE_ERROR ((LM_ERROR,
596 ACE_TEXT ("Unable to construct full file pathname\n")));
601 UTL_String (h, true));
602 idl_global->update_prefix (tmp->get_string ());
603 idl_global->set_filename (tmp);
606 UTL_String *fname = idl_global->filename ();
607 bool in_main_file = false;
609 bool is_real_filename =
610 fname->compare (idl_global->real_filename ())
611 || same_file (fname->get_string(),
612 idl_global->real_filename ()->get_string ());
614 bool is_main_filename = false;
616 if (!is_real_filename)
618 #if defined (ACE_OPENVMS)
619 char full_path[MAXPATHLEN] = "";
620 char *full_fname = ACE_OS::realpath (fname->get_string (), full_path);
621 // I don't see the benefit of using ->compare since this is targeted at IDL identifiers
622 // not at filenames and in the case of OpenVMS (case-insensitive filesystem) gets really
623 // problematic as filenames retrieved through different mechanisms may give different
625 is_main_filename = FE_Utils::path_cmp (idl_global->main_filename ()->get_string (),
629 fname->compare (idl_global->main_filename ())
630 || same_file (fname->get_string (),
631 idl_global->main_filename ()->get_string ());
635 if (is_real_filename || is_main_filename)
640 idl_global->set_in_main_file (in_main_file);
642 // Strip off any command line -I prefix that may have been added
643 // by the preprocessor.
644 if (!(idl_global->in_main_file ()) && idl_global->import ())
648 FE_Utils::stripped_preproc_include (
649 fname->get_string ()), true));
651 // This call also manages the #pragma prefix.
652 idl_global->store_include_file_name (nm);
656 // Store a #pragma line into the list of pragmas
658 idl_store_pragma (char *buf)
663 // Remove all the blanks between the '#' and the 'pragma'.
672 // This copies the crunched string back to the original, and
673 // also compensates for the behavior of the Sun preprocessor,
674 // which put spaces around the double colons of a non-quoted
675 // scoped name, a case which is possible in #pragma version.
676 // Also eats whitespace, which some preprocessors (for example
677 // Intel) don't automatically do.
680 if (*sp == ' ' && (*(sp + 1) == ':' || *(sp + 1) == ' '))
684 else if (*sp == ':' && *(sp + 1) == ' ')
700 // The '\n' is still <crunched> spaces too far away, with
701 // garbage characters in between.
705 if (ACE_OS::strstr (buf + 8, "import") != 0)
707 idl_global->set_import (true);
711 if (ACE_OS::strstr (buf + 8, "include") != 0)
713 idl_global->set_import (false);
717 if (ACE_OS::strncmp (buf + 8, "prefix", 6) == 0)
719 char *new_prefix = idl_get_pragma_string (buf);
723 unsigned long depth = idl_global->scopes ().depth ();
725 // We replace the prefix only if there is a prefix already
726 // associated with this file, otherwise we add the prefix.
727 char *ext_id = idl_global->filename ()->get_string ();
728 ACE_Hash_Map_Entry<char *, char *> *entry = 0;
730 idl_global->file_prefixes ().find (ext_id, entry);
734 if (ACE_OS::strcmp (entry->int_id_, "") != 0)
737 idl_global->pragma_prefixes ().pop (trash);
742 // Remove the default "" and bind the new prefix.
743 ACE::strdelete (entry->ext_id_);
744 ACE::strdelete (entry->int_id_);
745 (void) idl_global->file_prefixes ().unbind (entry);
746 (void) idl_global->file_prefixes ().bind (ACE::strnew (ext_id),
747 ACE::strnew (new_prefix));
751 UTL_Scope *top_scope = idl_global->scopes ().top ();
755 top_scope->has_prefix (true);
756 ScopeAsDecl (top_scope)->prefix_scope (top_scope);
759 idl_global->pragma_prefixes ().push (new_prefix);
763 idl_global->root ()->prefix (new_prefix);
766 if (idl_global->in_main_file ())
768 idl_global->root ()->set_imported (false);
769 top_scope->has_prefix (true);
774 (void) idl_global->file_prefixes ().bind (ACE::strnew (ext_id),
775 ACE::strnew (new_prefix));
779 else if (ACE_OS::strncmp (buf + 8, "version", 7) == 0)
781 char *tmp = buf + 16;
783 while (*tmp == ' ' || *tmp == '\t')
788 char *number = ACE_OS::strchr (tmp, ' ');
792 number = ACE_OS::strchr (tmp, '\t');
795 // Used later to trim the type string.
796 ptrdiff_t cutoff = number - tmp;
798 // Most likely this means there is only a version number
799 // without an identifier to apply it to.
802 const char *msg = "no identifier or scoped name";
803 idl_global->err ()->version_syntax_error (msg);
807 while (*number == ' ' || *number == '\t')
812 size_t len = ACE_OS::strlen (number);
814 // For some reason, the SunCC preprocessor adds a trailing space, which
815 // messes with idl_valid_version() below, so we check and remove.
816 while (number[len - 1] == ' ')
818 number[len - 1] = '\0';
819 len = ACE_OS::strlen (number);
822 // Trim the type string after trimming the number string.
825 // This call adds a proper null terminator to tmp, so no need to
827 AST_Decl *d = idl_find_node (tmp);
834 if (!idl_valid_version (number))
836 idl_global->err ()->version_number_error (number);
840 d->version (ACE::strnew (number));
842 else if (ACE_OS::strncmp (buf + 8, "ident", 5) == 0)
844 idl_global->ident_string (buf + 8);
846 else if (ACE_OS::strncmp (buf + 8, "ID", 2) == 0)
848 char *tmp = buf + 11;
855 ACE_CString work (tmp);
856 work = work.substr (0, work.find (' '));
858 AST_Decl *d = idl_find_node (work.c_str ());
865 char *new_id = idl_get_pragma_string (buf);
869 if (d->typeid_set ())
871 idl_global->err ()->id_reset_error (d->repoID (),
877 d->typeid_set (true);
880 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_TYPE", 14) == 0)
882 char *sample_type = idl_get_pragma_string (buf);
883 idl_global->add_dcps_data_type (sample_type);
885 // Delete sample_type since add_dcps_data_type() doesn't take its ownership.
886 delete [] sample_type;
888 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_KEY", 13) == 0)
890 char *tmp = idl_get_pragma_string (buf);
892 // Split up data type and key strings
893 char *sample_type = tmp;
895 while (*tmp && !isspace (*tmp))
900 while (isspace (*tmp))
908 if (!idl_global->add_dcps_data_key (sample_type, key))
910 ACE_ERROR((LM_ERROR, "DCPS_DATA_TYPE \"%C\" not found for key \"%C\"\n",
914 // Delete sample_type since add_dcps_data_key() doesn't take its ownership.
915 delete [] sample_type;
917 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_SEQUENCE_TYPE", 23) == 0)
919 char *seq_type = idl_get_pragma_string (buf);
920 idl_global->set_dcps_sequence_type (seq_type);
924 else if (ACE_OS::strncmp (buf + 8, "DCPS_SUPPORT_ZERO_COPY_READ", 27) == 0)
926 idl_global->dcps_support_zero_copy_read (true);
928 else if (ACE_OS::strncmp (buf + 8, "DCPS_GEN_ZERO_COPY_READ", 23) == 0)
930 idl_global->dcps_gen_zero_copy_read (true);
932 else if (ACE_OS::strncmp (buf + 8, "ciao lem", 8) == 0)
934 char *tmp = idl_get_pragma_string (buf);
935 idl_global->add_ciao_lem_file_names (tmp);
937 // Delete tmp since add_ciao_lem_file_names() doesn't take its ownership.
940 else if (ACE_OS::strncmp (buf + 8, "ndds typesupport", 16) == 0)
942 char *tmp = idl_get_pragma_string (buf);
943 idl_global->add_ciao_rti_ts_file_names (tmp);
945 // Delete tmp since add_ciao_rti_ts_file_names() doesn't take its ownership.
948 else if (ACE_OS::strncmp (buf + 8, "coredx typesupport", 18) == 0)
950 char *tmp = idl_get_pragma_string (buf);
951 idl_global->add_ciao_coredx_ts_file_names (tmp);
953 // Delete tmp since add_ciao_coredx_ts_file_names() doesn't take its ownership.
956 else if (ACE_OS::strncmp (buf + 8, "opendds typesupport", 19) == 0)
958 char *tmp = idl_get_pragma_string (buf);
959 idl_global->add_ciao_oci_ts_file_names (tmp);
961 // Delete tmp since add_ciao_oci_ts_file_names() doesn't take its ownership.
964 else if (ACE_OS::strncmp (buf + 8, "splice typesupport", 18) == 0)
966 char *tmp = idl_get_pragma_string (buf);
967 idl_global->add_ciao_spl_ts_file_names (tmp);
969 // Delete tmp since add_ciao_spl_ts_file_names() doesn't take its ownership.
972 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm interface", 22) == 0) ||
973 (ACE_OS::strncmp (buf + 8, "ami4ccm interface", 17) == 0))
975 if (idl_global->in_main_file ())
977 char *tmp = idl_get_pragma_string (buf);
978 idl_global->add_ciao_ami_iface_names (tmp);
980 // Delete tmp since add_ciao_ami_iface_names() doesn't take its ownership.
984 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm receptacle", 23) == 0) ||
985 (ACE_OS::strncmp (buf + 8, "ami4ccm receptacle", 18) == 0))
987 char *tmp = idl_get_pragma_string (buf);
989 if (idl_global->in_main_file ())
991 idl_global->add_ciao_ami_recep_names (tmp);
995 /// This is intended for the executor IDL file,
996 /// when a pragma is seen in the main file, but
997 /// it will do no harm in other cases.
998 idl_global->add_included_ami_recep_names (tmp);
1001 // Delete tmp since add_ciao_spl_ts_file_names() doesn't take its ownership.
1004 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm idl", 16) == 0) ||
1005 (ACE_OS::strncmp (buf + 8, "ami4ccm idl", 11) == 0))
1007 char *tmp = idl_get_pragma_string (buf);
1009 /// These pragmas are found in the file where the interface
1010 /// that has a AMI4CCM_* counterpart in the *A.idl file
1011 /// is declared. We add the filename to the list in all
1012 /// IDL files *except* the one where it is found, to
1013 /// eliminate a circular include of xxxC.h and xxxAC.h.
1014 if (!idl_global->in_main_file ())
1016 idl_global->add_ciao_ami_idl_fnames (tmp);
1019 // Delete tmp since add_ciao_ami_idl_fnames() doesn't take its ownership.
1022 else if (ACE_OS::strncmp (buf + 8, "dds4ccm impl", 12) == 0)
1024 char *tmp = idl_get_pragma_string (buf);
1026 idl_global->add_dds4ccm_impl_fnames (tmp);
1028 // Delete tmp since add_dds4ccm_impl_fnames() doesn't take its ownership.
1034 * idl_atoi - Convert a string of digits into a negative integer according to base b
1036 static ACE_CDR::LongLong
1037 idl_atoi (char *s, long b)
1039 ACE_CDR::LongLong r = 0;
1041 // Skip over the dash and possibly spaces after the dash
1042 while (*s == '-' || *s == ' ' || *s == '\t')
1047 if (b == 8 && *s == '0')
1051 else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
1058 if (*s <= '9' && *s >= '0')
1060 r = (r * b) + (*s - '0');
1062 else if (b > 10 && *s <= 'f' && *s >= 'a')
1064 r = (r * b) + (*s - 'a' + 10);
1066 else if (b > 10 && *s <= 'F' && *s >= 'A')
1068 r = (r * b) + (*s - 'A' + 10);
1080 * idl_atoui - Convert a string of digits into an unsigned integer according to base b
1082 static ACE_CDR::ULongLong
1083 idl_atoui (char *s, long b)
1085 ACE_CDR::ULongLong r = 0;
1087 if (b == 8 && *s == '0')
1091 else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
1098 if (*s <= '9' && *s >= '0')
1100 r = (r * b) + (*s - '0');
1102 else if (b > 10 && *s <= 'f' && *s >= 'a')
1104 r = (r * b) + (*s - 'a' + 10);
1106 else if (b > 10 && *s <= 'F' && *s >= 'A')
1108 r = (r * b) + (*s - 'A' + 10);
1120 * Convert a string to a float; atof doesn't seem to work, always.
1122 static ACE_CDR::Double
1127 long neg = 0, negexp = 0;
1133 // Skip over the dash and possibly spaces after the dash
1134 while (*s == '-' || *s == ' ' || *s == '\t')
1140 while (*s >= '0' && *s <= '9')
1142 d = (d * 10) + *s - '0';
1151 while (*s >= '0' && *s <= '9')
1153 d += (*s - '0') / (e * 1.0);
1159 if (*s == 'e' || *s == 'E')
1175 while (*s >= '0' && *s <= '9')
1177 e = (e * 10) + *s - '0';
1183 for (k = 1; e > 0; k *= 10, e--) ;
1205 * Convert (some) escaped characters into their ascii values
1208 idl_escape_reader (char *str)
1244 for (i = 2; str[i] != '\0' && isxdigit (str[i]); ++i)
1251 char out = (char)idl_atoui(&str[2], 16);
1255 ACE_NOTREACHED (break;)
1257 // check for octal value
1258 if (str[1] >= '0' && str[1] <= '7')
1262 for (i = 1; str[i] >= '0' && str[i] <= '7'; ++i)
1269 char out = (char)idl_atoui(&str[1], 8);
1275 return str[1] - 'a';
1277 ACE_NOTREACHED (break;)
1281 * Convert escaped hex digits into a wchar
1283 static ACE_CDR::WChar
1284 idl_wchar_escape_reader (char *str)
1286 if (str[0] != '\\' || str[1] != 'u')
1292 // get the hex digits
1293 for (i = 2; str[i] != '\0' && isxdigit (str[i]); i++)
1299 ACE_CDR::WChar out = (ACE_CDR::WChar) idl_atoui (&str[2], 16);
1305 * Checks wstring for validity
1308 idl_wstring_escape_reader (char *str)
1314 idl_get_pragma_string (char *pragma)
1316 // Get pointers to each end of the substring between the quotes.
1317 const char *firstquote = ACE_OS::strchr (pragma, '"');
1319 if (firstquote == 0)
1321 idl_global->err ()->syntax_error (
1322 IDL_GlobalData::PS_PragmaPrefixSyntax
1328 const char *start = firstquote + 1;
1329 const char *end = ACE_OS::strchr (start, '"');
1333 idl_global->err ()->syntax_error (
1334 IDL_GlobalData::PS_PragmaPrefixSyntax
1340 int len = static_cast<int> (end - start);
1343 ACE_NEW_RETURN (retval,
1347 ACE_OS::strncpy (retval,
1356 idl_valid_version (char *s)
1358 // Nothing preceding decimal point.
1364 char *minor = ACE_OS::strchr (s, '.');
1369 // No decimal point.
1373 if (*(minor + 1) == '\0')
1375 // Nothing following decimal point.
1379 char *tmp = minor + 1;
1381 for (i = 0; tmp[i] != '\0'; ++i)
1383 if (!isdigit (tmp[i]))
1389 ptrdiff_t const len = minor - s;
1391 for (i = 0; i < len; ++i)
1393 if (!isdigit (s[i]))
1399 // Major and minor version numbers must be unsigned shorts.
1400 if (ACE_OS::atoi (minor + 1) > ACE_UINT16_MAX
1401 || ACE_OS::atoi (s) > ACE_UINT16_MAX)
1410 idl_find_node (const char *s)
1412 UTL_ScopedName * node = FE_Utils::string_to_scoped_name (s);
1417 d = idl_global->scopes ().top_non_null ()->lookup_by_name (node);
1421 idl_global->err ()->lookup_error (node);