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
115 #define IDL4_KEYWORD(TOKEN_NAME) if (idl_global->idl_version_ >= IDL_VERSION_4) return TOKEN_NAME;
119 /* SO we don't choke on files that use \r\n */
123 %option never-interactive
128 Object return IDL_OBJECT;
129 module return IDL_MODULE;
130 raises return IDL_RAISES;
131 readonly return IDL_READONLY;
132 attribute return IDL_ATTRIBUTE;
133 exception return IDL_EXCEPTION;
134 context return IDL_CONTEXT;
135 interface return IDL_INTERFACE;
136 const return IDL_CONST;
137 typedef return IDL_TYPEDEF;
138 struct return IDL_STRUCT;
139 enum return IDL_ENUM;
140 string return IDL_STRING;
141 wstring return IDL_WSTRING;
142 sequence return IDL_SEQUENCE;
143 union return IDL_UNION;
144 fixed return IDL_FIXED;
145 switch return IDL_SWITCH;
146 case return IDL_CASE;
147 default return IDL_DEFAULT;
148 float return IDL_FLOAT;
149 double return IDL_DOUBLE;
150 long return IDL_LONG;
151 short return IDL_SHORT;
152 unsigned return IDL_UNSIGNED;
153 char return IDL_CHAR;
154 wchar return IDL_WCHAR;
155 boolean return IDL_BOOLEAN;
156 octet return IDL_OCTET;
157 void return IDL_VOID;
158 native return IDL_NATIVE;
159 local return IDL_LOCAL;
160 abstract return IDL_ABSTRACT;
162 custom return IDL_CUSTOM;
163 factory return IDL_FACTORY;
164 private return IDL_PRIVATE;
165 public return IDL_PUBLIC;
166 supports return IDL_SUPPORTS;
167 truncatable return IDL_TRUNCATABLE;
168 valuetype return IDL_VALUETYPE;
170 component return IDL_COMPONENT;
171 consumes return IDL_CONSUMES;
172 emits return IDL_EMITS;
173 eventtype return IDL_EVENTTYPE;
174 finder return IDL_FINDER;
175 getraises return IDL_GETRAISES;
176 home return IDL_HOME;
177 import return IDL_IMPORT;
178 multiple return IDL_MULTIPLE;
179 primarykey return IDL_PRIMARYKEY;
180 provides return IDL_PROVIDES;
181 publishes return IDL_PUBLISHES;
182 setraises return IDL_SETRAISES;
183 typeid return IDL_TYPEID;
184 typeprefix return IDL_TYPEPREFIX;
185 uses return IDL_USES;
186 manages return IDL_MANAGES;
188 typename return IDL_TYPENAME;
189 port return IDL_PORT;
190 mirrorport return IDL_MIRRORPORT;
191 porttype return IDL_PORTTYPE;
192 connector return IDL_CONNECTOR;
193 alias return IDL_ALIAS;
195 TRUE return IDL_TRUETOK;
196 FALSE return IDL_FALSETOK;
198 inout return IDL_INOUT;
201 oneway return IDL_ONEWAY;
203 \<\< return IDL_LEFT_SHIFT;
204 \>\> return IDL_RIGHT_SHIFT;
206 tao_yylval.strval = ACE::strnew ("::");
207 return IDL_SCOPE_DELIMITOR;
210 @annotation[^A-Za-z0-9_] return IDL_ANNOTATION_DECL; // Allow annotation names that start with "annotation"
211 @ return IDL_ANNOTATION_SYMBOL;
213 int8 IDL4_KEYWORD(IDL_INT8); REJECT;
214 uint8 IDL4_KEYWORD(IDL_UINT8); REJECT;
215 int16 IDL4_KEYWORD(IDL_INT16); REJECT;
216 uint16 IDL4_KEYWORD(IDL_UINT16); REJECT;
217 int32 IDL4_KEYWORD(IDL_INT32); REJECT;
218 uint32 IDL4_KEYWORD(IDL_UINT32); REJECT;
219 int64 IDL4_KEYWORD(IDL_INT64); REJECT;
220 uint64 IDL4_KEYWORD(IDL_UINT64); REJECT;
222 bitfield IDL4_KEYWORD(IDL_BITFIELD); REJECT;
223 bitmask IDL4_KEYWORD(IDL_BITMASK); REJECT;
224 bitset IDL4_KEYWORD(IDL_BITSET); REJECT;
225 map IDL4_KEYWORD(IDL_MAP); REJECT;
227 [a-ij-rs-zA-IJ-RS-Z_][a-ij-rs-zA-IJ-RS-Z0-9_]* {
228 // Make sure that this identifier is not a C++ keyword. If it is,
229 // prepend it with a _cxx_. Lookup in the perfect hash table for C++
230 // keyword and grab the mapping. BTW, the reason for the odd
231 // regular expression is to handle EBCDIC, as well as ASCII.
233 TAO_IDL_CPP_Keyword_Table cpp_key_tbl;
234 const TAO_IDL_CPP_Keyword_Entry *entry = 0;
235 if (!idl_global->preserve_cpp_keywords())
237 // This check will ensure that escaped C++ keywords will be
238 // caught and prepended with '_cxx' as non-escaped keywords
239 // are now prepended with '_cxx_'.
241 ace_yytext[0] == '_' ? ace_yytext + 1 : ace_yytext;
244 cpp_key_tbl.lookup (tmp,
245 static_cast<unsigned int> (ACE_OS::strlen (tmp)));
250 tao_yylval.strval = ACE::strnew (entry->mapping_);
254 tao_yylval.strval = ACE::strnew (ace_yytext);
260 "-"?(([0-9]+"."[0-9]*)|("."[0-9]+))([eE][+-]?[0-9]+)?[lLfF]? {
261 tao_yylval.dval = idl_atof (ace_yytext);
262 return IDL_FLOATING_PT_LITERAL;
264 "-"?[0-9]+[eE][+-]?[0-9]+[lLfF]? {
265 tao_yylval.dval = idl_atof (ace_yytext);
266 return IDL_FLOATING_PT_LITERAL;
269 "-"?(([0-9]+"."[0-9]*)|("."?[0-9]+))[dD] {
270 tao_yylval.fixval = ACE_CDR::Fixed::from_string (ace_yytext);
271 return IDL_FIXED_PT_LITERAL;
275 tao_yylval.ival = idl_atoi (ace_yytext, 10);
276 return IDL_INTEGER_LITERAL;
279 tao_yylval.uival = idl_atoui (ace_yytext, 10);
280 return IDL_UINTEGER_LITERAL;
282 "-"0[xX][a-fA-F0-9]+ {
283 tao_yylval.ival = idl_atoi (ace_yytext, 16);
284 return IDL_INTEGER_LITERAL;
287 tao_yylval.uival = idl_atoui (ace_yytext, 16);
288 return IDL_UINTEGER_LITERAL;
291 tao_yylval.ival = idl_atoi (ace_yytext, 8);
292 return IDL_INTEGER_LITERAL;
295 tao_yylval.uival = idl_atoui (ace_yytext, 8);
296 return IDL_UINTEGER_LITERAL;
299 (\"([^\\\"]*|\\[ntvbrfax\\\?\'\"]|\\[0-7]{1,3})*\"[ \t]*)+ {
300 /* Skip the quotes */
301 char * const tmp = ace_yytext;
302 for (size_t i = ACE_OS::strlen (tmp); i-- != 0; )
304 if (isspace (tmp[i]))
313 tmp[ACE_OS::strlen (tmp) - 1] = '\0';
314 ACE_NEW_RETURN (tao_yylval.sval,
315 UTL_String (tmp + 1, true),
317 return IDL_STRING_LITERAL;
319 (L\"([^\\\"]*|\\[ntvbrfax\\\?\'\"]|\\[0-7]{1,3}|\\u([0-9a-fA-F]{1,4}))*\"[ \t]*)+ {
320 /* Skip the bookends */
321 char * const tmp = ACE_OS::strdup (ace_yytext);
322 for (size_t i = ACE_OS::strlen (tmp); i-- != 0; )
324 if (isspace (tmp[i]))
333 tmp[ACE_OS::strlen (tmp) - 1] = '\0';
334 tao_yylval.wsval = ACE_OS::strdup (idl_wstring_escape_reader (tmp + 2));
336 return IDL_WSTRING_LITERAL;
339 tao_yylval.cval = ace_yytext[1];
340 return IDL_CHARACTER_LITERAL;
342 "'"\\([0-7]{1,3})"'" {
343 // octal character constant
344 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
345 return IDL_CHARACTER_LITERAL;
347 "'"\\[xX]([0-9a-fA-F]{1,2})"'" {
348 // hexadecimal character constant
349 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
350 return IDL_CHARACTER_LITERAL;
353 tao_yylval.cval = idl_escape_reader (ace_yytext + 1);
354 return IDL_CHARACTER_LITERAL;
357 // wide character constant
358 tao_yylval.wcval = ace_yytext[2];
359 return IDL_WCHAR_LITERAL;
361 L"'"\\u([0-9a-fA-F]{1,4})"'" {
362 // hexadecimal wide character constant
363 tao_yylval.wcval = idl_wchar_escape_reader (ace_yytext + 2);
364 return IDL_WCHAR_LITERAL;
366 ^[ \t]*#[ \t]*pragma[ \t].*{NL} |
367 ^\?\?=[ \t]*pragma[ \t].*{NL} {/* remember pragma */
368 idl_global->set_lineno (idl_global->lineno () + 1);
369 idl_store_pragma (ace_yytext);
372 ^[ \t]*#file[ \t].*{NL} |
373 ^\?\?=[ \t]*file[ \t].*{NL} {/* ignore file */
374 idl_global->set_lineno(idl_global->lineno () + 1);
377 ^[ \t]*#[ \t]*[0-9]*" ""\""[^\"]*"\""" "[0-9]*([ \t]*[0-9]*)*{NL} |
378 ^\?\?=[ \t]*[0-9]*" ""\""[^\"]*"\""" "[0-9]*([ \t]*[0-9]*)?{NL} {
379 idl_parse_line_and_file (ace_yytext);
382 ^[ \t]*#[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} |
383 ^\?\?=[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} {
384 idl_parse_line_and_file (ace_yytext);
387 ^[ \t]*#line[ \t]*[0-9]+[ \t]*("\""[^\"]*"\""([ \t]*[0-9]*([ \t]*[0-9]*)?)?)?{NL} |
388 ^\?\?=line[ \t]*[0-9]*" ""\""[^\"]*"\""{NL} {
389 idl_parse_line_and_file (ace_yytext);
392 ^[ \t]*#[ \t]*[0-9]*{NL} |
393 ^\?\?=[ \t]*[0-9]*{NL} {
394 idl_parse_line_and_file (ace_yytext);
397 ^[ \t]*#[ \t]*ident[ \t].*{NL} |
398 ^\?\?=[ \t]*ident[ \t].*{NL} {
399 /* ignore cpp ident */
400 idl_global->set_lineno (idl_global->lineno () + 1);
404 /* ignore comments */
405 idl_global->set_lineno(idl_global->lineno () + 1);
411 char const c = yyinput ();
414 char const next = yyinput ();
422 idl_global->set_lineno (idl_global->lineno () + 1);
429 idl_global->set_lineno (idl_global->lineno () + 1);
432 . return ace_yytext[0];
438 same_file (char *path1, char *path2)
440 char fullpath1 [MAXPATHLEN + 1] = {0};
441 char fullpath2 [MAXPATHLEN + 1] = {0};
443 char *fp1 = ACE_OS::realpath (path1, fullpath1);
444 char *fp2 = ACE_OS::realpath (path2, fullpath2);
447 (fp1 == 0 || fp2 == 0)
449 : FE_Utils::path_cmp (fullpath1,fullpath2) == 0;
452 // Parse a #line statement generated by the C preprocessor
454 idl_parse_line_and_file (char *buf)
470 // Check to see if we're running under the screwy Microsoft scheme
471 // of putting #line num instead of #num.
473 if (ACE_OS::strncmp (r, "line", 4) == 0)
486 for (; isdigit (*r); ++r)
492 idl_global->set_lineno ((long) idl_atoui (h, 10));
494 // Find file name, if present.
495 for (; *r != '"'; ++r)
497 if (*r == '\n' || *r == '\0')
505 for (; *r != '"'; ++r)
515 ACE_ERROR ((LM_ERROR,
516 ACE_TEXT ("IDL: No input files\n")));
525 // Put Microsoft-style pathnames into a canonical form.
526 for (i = 0, j = 0; h[j] != '\0'; i++, j++)
528 if (h[j] == '\\' && h[j + 1] == '\\')
538 UTL_String (h, true));
539 idl_global->update_prefix (tmp->get_string ());
540 idl_global->set_filename (tmp);
543 UTL_String *fname = idl_global->filename ();
544 bool in_main_file = false;
546 bool is_real_filename =
547 fname->compare (idl_global->real_filename ())
548 || same_file (fname->get_string(),
549 idl_global->real_filename ()->get_string ());
551 bool is_main_filename = false;
553 if (!is_real_filename)
556 fname->compare (idl_global->main_filename ())
557 || same_file (fname->get_string (),
558 idl_global->main_filename ()->get_string ());
561 if (is_real_filename || is_main_filename)
566 idl_global->set_in_main_file (in_main_file);
568 // Strip off any command line -I prefix that may have been added
569 // by the preprocessor.
570 if (!(idl_global->in_main_file ()) && idl_global->import ())
574 FE_Utils::stripped_preproc_include (
575 fname->get_string ()), true));
577 // This call also manages the #pragma prefix.
578 idl_global->store_include_file_name (nm);
582 // Store a #pragma line into the list of pragmas
584 idl_store_pragma (char *buf)
589 // Remove all the blanks between the '#' and the 'pragma'.
598 // This copies the crunched string back to the original, and
599 // also compensates for the behavior of the Sun preprocessor,
600 // which put spaces around the double colons of a non-quoted
601 // scoped name, a case which is possible in #pragma version.
602 // Also eats whitespace, which some preprocessors (for example
603 // Intel) don't automatically do.
606 if (*sp == ' ' && (*(sp + 1) == ':' || *(sp + 1) == ' '))
610 else if (*sp == ':' && *(sp + 1) == ' ')
626 // The '\n' is still <crunched> spaces too far away, with
627 // garbage characters in between.
631 if (ACE_OS::strstr (buf + 8, "import") != 0)
633 idl_global->set_import (true);
637 if (ACE_OS::strstr (buf + 8, "include") != 0)
639 idl_global->set_import (false);
643 if (ACE_OS::strncmp (buf + 8, "prefix", 6) == 0)
645 char *new_prefix = idl_get_pragma_string (buf);
649 unsigned long depth = idl_global->scopes ().depth ();
651 // We replace the prefix only if there is a prefix already
652 // associated with this file, otherwise we add the prefix.
653 char *ext_id = idl_global->filename ()->get_string ();
654 ACE_Hash_Map_Entry<char *, char *> *entry = 0;
656 idl_global->file_prefixes ().find (ext_id, entry);
660 if (ACE_OS::strcmp (entry->int_id_, "") != 0)
663 idl_global->pragma_prefixes ().pop (trash);
668 // Remove the default "" and bind the new prefix.
669 ACE::strdelete (entry->ext_id_);
670 ACE::strdelete (entry->int_id_);
671 (void) idl_global->file_prefixes ().unbind (entry);
672 (void) idl_global->file_prefixes ().bind (ACE::strnew (ext_id),
673 ACE::strnew (new_prefix));
677 UTL_Scope *top_scope = idl_global->scopes ().top ();
681 top_scope->has_prefix (true);
682 ScopeAsDecl (top_scope)->prefix_scope (top_scope);
685 idl_global->pragma_prefixes ().push (new_prefix);
689 idl_global->root ()->prefix (new_prefix);
692 if (idl_global->in_main_file ())
694 idl_global->root ()->set_imported (false);
695 top_scope->has_prefix (true);
700 (void) idl_global->file_prefixes ().bind (ACE::strnew (ext_id),
701 ACE::strnew (new_prefix));
705 else if (ACE_OS::strncmp (buf + 8, "version", 7) == 0)
707 char *tmp = buf + 16;
709 while (*tmp == ' ' || *tmp == '\t')
714 char *number = ACE_OS::strchr (tmp, ' ');
718 number = ACE_OS::strchr (tmp, '\t');
721 // Used later to trim the type string.
722 ptrdiff_t cutoff = number - tmp;
724 // Most likely this means there is only a version number
725 // without an identifier to apply it to.
728 const char *msg = "no identifier or scoped name";
729 idl_global->err ()->version_syntax_error (msg);
733 while (*number == ' ' || *number == '\t')
738 size_t len = ACE_OS::strlen (number);
740 // For some reason, the SunCC preprocessor adds a trailing space, which
741 // messes with idl_valid_version() below, so we check and remove.
742 while (number[len - 1] == ' ')
744 number[len - 1] = '\0';
745 len = ACE_OS::strlen (number);
748 // Trim the type string after trimming the number string.
751 // This call adds a proper null terminator to tmp, so no need to
753 AST_Decl *d = idl_find_node (tmp);
760 if (!idl_valid_version (number))
762 idl_global->err ()->version_number_error (number);
766 d->version (ACE::strnew (number));
768 else if (ACE_OS::strncmp (buf + 8, "ident", 5) == 0)
770 idl_global->ident_string (buf + 8);
772 else if (ACE_OS::strncmp (buf + 8, "ID", 2) == 0)
774 char *tmp = buf + 11;
781 ACE_CString work (tmp);
782 work = work.substr (0, work.find (' '));
784 AST_Decl *d = idl_find_node (work.c_str ());
791 char *new_id = idl_get_pragma_string (buf);
795 if (d->typeid_set ())
797 idl_global->err ()->id_reset_error (d->repoID (),
803 d->typeid_set (true);
806 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_TYPE", 14) == 0)
808 char *sample_type = idl_get_pragma_string (buf);
809 idl_global->add_dcps_data_type (sample_type);
811 // Delete sample_type since add_dcps_data_type() doesn't take its ownership.
812 delete [] sample_type;
814 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_KEY", 13) == 0)
816 char *tmp = idl_get_pragma_string (buf);
818 // Split up data type and key strings
819 char *sample_type = tmp;
821 while (*tmp && !isspace (*tmp))
826 while (isspace (*tmp))
834 if (!idl_global->add_dcps_data_key (sample_type, key))
836 ACE_ERROR((LM_ERROR, "DCPS_DATA_TYPE \"%C\" not found for key \"%C\"\n",
840 // Delete sample_type since add_dcps_data_key() doesn't take its ownership.
841 delete [] sample_type;
843 else if (ACE_OS::strncmp (buf + 8, "DCPS_DATA_SEQUENCE_TYPE", 23) == 0)
845 char *seq_type = idl_get_pragma_string (buf);
846 idl_global->set_dcps_sequence_type (seq_type);
850 else if (ACE_OS::strncmp (buf + 8, "DCPS_SUPPORT_ZERO_COPY_READ", 27) == 0)
852 idl_global->dcps_support_zero_copy_read (true);
854 else if (ACE_OS::strncmp (buf + 8, "DCPS_GEN_ZERO_COPY_READ", 23) == 0)
856 idl_global->dcps_gen_zero_copy_read (true);
858 else if (ACE_OS::strncmp (buf + 8, "ciao lem", 8) == 0)
860 char *tmp = idl_get_pragma_string (buf);
861 idl_global->add_ciao_lem_file_names (tmp);
863 // Delete tmp since add_ciao_lem_file_names() doesn't take its ownership.
866 else if (ACE_OS::strncmp (buf + 8, "ndds typesupport", 16) == 0)
868 char *tmp = idl_get_pragma_string (buf);
869 idl_global->add_ciao_rti_ts_file_names (tmp);
871 // Delete tmp since add_ciao_rti_ts_file_names() doesn't take its ownership.
874 else if (ACE_OS::strncmp (buf + 8, "coredx typesupport", 18) == 0)
876 char *tmp = idl_get_pragma_string (buf);
877 idl_global->add_ciao_coredx_ts_file_names (tmp);
879 // Delete tmp since add_ciao_coredx_ts_file_names() doesn't take its ownership.
882 else if (ACE_OS::strncmp (buf + 8, "opendds typesupport", 19) == 0)
884 char *tmp = idl_get_pragma_string (buf);
885 idl_global->add_ciao_oci_ts_file_names (tmp);
887 // Delete tmp since add_ciao_oci_ts_file_names() doesn't take its ownership.
890 else if (ACE_OS::strncmp (buf + 8, "splice typesupport", 18) == 0)
892 char *tmp = idl_get_pragma_string (buf);
893 idl_global->add_ciao_spl_ts_file_names (tmp);
895 // Delete tmp since add_ciao_spl_ts_file_names() doesn't take its ownership.
898 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm interface", 22) == 0) ||
899 (ACE_OS::strncmp (buf + 8, "ami4ccm interface", 17) == 0))
901 if (idl_global->in_main_file ())
903 char *tmp = idl_get_pragma_string (buf);
904 idl_global->add_ciao_ami_iface_names (tmp);
906 // Delete tmp since add_ciao_ami_iface_names() doesn't take its ownership.
910 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm receptacle", 23) == 0) ||
911 (ACE_OS::strncmp (buf + 8, "ami4ccm receptacle", 18) == 0))
913 char *tmp = idl_get_pragma_string (buf);
915 if (idl_global->in_main_file ())
917 idl_global->add_ciao_ami_recep_names (tmp);
921 /// This is intended for the executor IDL file,
922 /// when a pragma is seen in the main file, but
923 /// it will do no harm in other cases.
924 idl_global->add_included_ami_recep_names (tmp);
927 // Delete tmp since add_ciao_spl_ts_file_names() doesn't take its ownership.
930 else if ((ACE_OS::strncmp (buf + 8, "ciao ami4ccm idl", 16) == 0) ||
931 (ACE_OS::strncmp (buf + 8, "ami4ccm idl", 11) == 0))
933 char *tmp = idl_get_pragma_string (buf);
935 /// These pragmas are found in the file where the interface
936 /// that has a AMI4CCM_* counterpart in the *A.idl file
937 /// is declared. We add the filename to the list in all
938 /// IDL files *except* the one where it is found, to
939 /// eliminate a circular include of xxxC.h and xxxAC.h.
940 if (!idl_global->in_main_file ())
942 idl_global->add_ciao_ami_idl_fnames (tmp);
945 // Delete tmp since add_ciao_ami_idl_fnames() doesn't take its ownership.
948 else if (ACE_OS::strncmp (buf + 8, "dds4ccm impl", 12) == 0)
950 char *tmp = idl_get_pragma_string (buf);
952 idl_global->add_dds4ccm_impl_fnames (tmp);
954 // Delete tmp since add_dds4ccm_impl_fnames() doesn't take its ownership.
960 * idl_atoi - Convert a string of digits into a negative integer according to base b
962 static ACE_CDR::LongLong
963 idl_atoi (char *s, long b)
965 ACE_CDR::LongLong r = 0;
967 // Skip over the dash and possibly spaces after the dash
968 while (*s == '-' || *s == ' ' || *s == '\t')
973 if (b == 8 && *s == '0')
977 else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
984 if (*s <= '9' && *s >= '0')
986 r = (r * b) + (*s - '0');
988 else if (b > 10 && *s <= 'f' && *s >= 'a')
990 r = (r * b) + (*s - 'a' + 10);
992 else if (b > 10 && *s <= 'F' && *s >= 'A')
994 r = (r * b) + (*s - 'A' + 10);
1006 * idl_atoui - Convert a string of digits into an unsigned integer according to base b
1008 static ACE_CDR::ULongLong
1009 idl_atoui (char *s, long b)
1011 ACE_CDR::ULongLong r = 0;
1013 if (b == 8 && *s == '0')
1017 else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
1024 if (*s <= '9' && *s >= '0')
1026 r = (r * b) + (*s - '0');
1028 else if (b > 10 && *s <= 'f' && *s >= 'a')
1030 r = (r * b) + (*s - 'a' + 10);
1032 else if (b > 10 && *s <= 'F' && *s >= 'A')
1034 r = (r * b) + (*s - 'A' + 10);
1046 * Convert a string to a float; atof doesn't seem to work, always.
1048 static ACE_CDR::Double
1053 long neg = 0, negexp = 0;
1059 // Skip over the dash and possibly spaces after the dash
1060 while (*s == '-' || *s == ' ' || *s == '\t')
1066 while (*s >= '0' && *s <= '9')
1068 d = (d * 10) + *s - '0';
1077 while (*s >= '0' && *s <= '9')
1079 d += (*s - '0') / (e * 1.0);
1085 if (*s == 'e' || *s == 'E')
1101 while (*s >= '0' && *s <= '9')
1103 e = (e * 10) + *s - '0';
1109 for (k = 1; e > 0; k *= 10, e--) ;
1131 * Convert (some) escaped characters into their ascii values
1134 idl_escape_reader (char *str)
1170 for (i = 2; str[i] != '\0' && isxdigit (str[i]); ++i)
1177 char out = (char)idl_atoui(&str[2], 16);
1181 ACE_NOTREACHED (break;)
1183 // check for octal value
1184 if (str[1] >= '0' && str[1] <= '7')
1188 for (i = 1; str[i] >= '0' && str[i] <= '7'; ++i)
1195 char out = (char)idl_atoui(&str[1], 8);
1201 return str[1] - 'a';
1203 ACE_NOTREACHED (break;)
1207 * Convert escaped hex digits into a wchar
1209 static ACE_CDR::WChar
1210 idl_wchar_escape_reader (char *str)
1212 if (str[0] != '\\' || str[1] != 'u')
1218 // get the hex digits
1219 for (i = 2; str[i] != '\0' && isxdigit (str[i]); i++)
1225 ACE_CDR::WChar out = (ACE_CDR::WChar) idl_atoui (&str[2], 16);
1231 * Checks wstring for validity
1234 idl_wstring_escape_reader (char *str)
1240 idl_get_pragma_string (char *pragma)
1242 // Get pointers to each end of the substring between the quotes.
1243 const char *firstquote = ACE_OS::strchr (pragma, '"');
1247 idl_global->err ()->syntax_error (IDL_GlobalData::PS_PragmaPrefixSyntax);
1252 const char *start = firstquote + 1;
1253 const char *end = ACE_OS::strchr (start, '"');
1257 idl_global->err ()->syntax_error (IDL_GlobalData::PS_PragmaPrefixSyntax);
1262 size_t const len = end - start;
1265 ACE_NEW_RETURN (retval,
1269 ACE_OS::strncpy (retval,
1278 idl_valid_version (char *s)
1280 // Nothing preceding decimal point.
1286 char *minor = ACE_OS::strchr (s, '.');
1291 // No decimal point.
1295 if (*(minor + 1) == '\0')
1297 // Nothing following decimal point.
1301 char *tmp = minor + 1;
1303 for (i = 0; tmp[i] != '\0'; ++i)
1305 if (!isdigit (tmp[i]))
1311 ptrdiff_t const len = minor - s;
1313 for (i = 0; i < len; ++i)
1315 if (!isdigit (s[i]))
1321 // Major and minor version numbers must be unsigned shorts.
1322 if (ACE_OS::atoi (minor + 1) > ACE_UINT16_MAX
1323 || ACE_OS::atoi (s) > ACE_UINT16_MAX)
1332 idl_find_node (const char *s)
1334 UTL_ScopedName * node = FE_Utils::string_to_scoped_name (s);
1339 d = idl_global->scopes ().top_non_null ()->lookup_by_name (node);
1343 idl_global->err ()->lookup_error (node);