4#pragma warning ( disable : 4786 )
7#define WIN32_LEAN_AND_MEAN
29 printf("ASSERT FAILURE: (%s) at %s:%i\n", #x, __FILE__, __LINE__);\
30 printf("WHILE PROCESSING: \n");\
31 for ( int ajf83pfj = 0; ajf83pfj < tokens.size(); ajf83pfj++ )\
32 printf("%s ", tokens[ajf83pfj].c_str() );\
42char*
findend (
char*
p,
bool& externc );
93 File f (
"input.lst",
"r" );
96 printf (
"Couldn't open \"input.lst\" for input\nPress any key to exit\n" );
110 printf (
"Done!\nPress any key to exit!\n" );
125 if ( !File::LoadIntoString (
s,
filename ) )
156 while (
end &&
end[-1] ==
'\\' )
166 else if ( *
p ==
'}' &&
h->externc )
171 if ( *
p ==
';' )
p++;
175 bool externc =
false;
198 while ( (p2 =
strchr(
p,
'\\')) )
206 string hdrguardtext (
p,
end-
p );
207 strupr ( &hdrguardtext[0] );
222 string preproc (
p,
end-
p );
226 const string dbg_filename =
"napi/lpc.h DISABLE DISABLE DISABLE";
228 if ( preproc ==
"include" )
240 string include_filename (
p,
end-
p );
242 h.libc_includes.push_back ( include_filename );
252 printf (
"circular dependency between '%s' and '%s'\n",
filename, include_filename.
c_str() );
260 printf (
"(diverting to '%s')\n", include_filename.
c_str() );
264 h.includes.push_back ( include_filename );
267 else if ( preproc ==
"define" )
287 s->names.push_back (
string(
p,
end-
p) );
291 h.symbols.push_back (
s );
293 else if ( preproc ==
"undef" )
297 else if ( preproc ==
"if" || preproc ==
"ifdef" || preproc ==
"ifndef" )
299 if ( dbg_filename ==
h.filename )
300 printf (
"(%s) PRE-PUSH preproc stack = %lu\n", preproc.
c_str(),
h.ifs.size() );
306 h.ifs.push_back (
string(
"") );
309 h.ifspreproc.push_back ( preproc );
310 if ( dbg_filename ==
h.filename )
311 printf (
"POST-PUSH preproc stack = %lu\n",
h.ifs.size() );
313 else if ( preproc ==
"endif" )
315 if ( dbg_filename ==
h.filename )
316 printf (
"(%s) PRE-POP preproc stack = %lu\n", preproc.
c_str(),
h.ifs.size() );
317 ASSERT (
h.ifs.size() > 0 &&
h.ifs.size() ==
h.ifspreproc.size() );
319 h.ifspreproc.pop_back();
320 if ( dbg_filename ==
h.filename )
321 printf (
"POST-POP preproc stack = %lu\n",
h.ifs.size() );
323 else if ( preproc ==
"elif" )
325 if ( dbg_filename ==
h.filename )
326 printf (
"(%s) PRE-PUSHPOP preproc stack = %lu\n", preproc.
c_str(),
h.ifs.size() );
327 string& oldpre =
h.ifspreproc.back();
328 string old =
h.ifs.back();
330 if ( oldpre ==
"ifdef" )
331 condold =
string(
"!defined(") + old +
")";
332 else if ( oldpre ==
"ifndef" )
333 condold =
string(
"defined(") + old +
")";
334 else if ( oldpre ==
"if" )
335 condold =
string(
"!(") + old +
")";
338 printf (
"unrecognized preproc '%s'\n", oldpre.
c_str() );
343 h.ifspreproc.back() =
"if";
344 if ( dbg_filename ==
h.filename )
345 printf (
"POST-PUSHPOP preproc stack = %lu\n",
h.ifs.size() );
347 else if ( preproc ==
"else" )
349 if ( dbg_filename ==
h.filename )
350 printf (
"(%s) PRE-PUSHPOP preproc stack = %lu\n", preproc.
c_str(),
h.ifs.size() );
351 string& oldpre =
h.ifspreproc.back();
352 ASSERT ( oldpre !=
"else" );
353 if ( oldpre ==
"ifdef" )
354 h.ifs.back() =
"ifndef";
355 else if ( oldpre ==
"ifndef" )
356 h.ifs.back() =
"ifdef";
357 else if ( oldpre ==
"if" )
358 h.ifs.back() =
string(
"!(") +
h.ifs.back() +
")";
361 printf (
"unrecognized preproc '%s'\n", oldpre.
c_str() );
366 if ( dbg_filename ==
h.filename )
367 printf (
"POST-PUSHPOP preproc stack = %lu\n",
h.ifs.size() );
369 else if ( preproc ==
"include_next" )
373 else if ( preproc ==
"pragma" )
377 else if ( preproc ==
"error" )
383 printf (
"process_preprocessor() choked on '%s'\n", preproc.
c_str() );
397 for (
int i = 0;
i <
h.ifs.size();
i++ )
399 if (
h.ifs[
i].size() )
400 s->ifs.push_back (
h.ifs[
i] );
425 h.symbols.push_back (
s );
462 if ( !
strncmp ( p2,
"\"C\"", 3 ) )
474 if ( !
strncmp (
p,
"typedef_tident", 14 ) )
481 bool isStruct =
false;
488 char* semi =
strchr (
p,
'{' );
489 if ( !semi || semi >
end )
493 const char* structs[] = {
"struct",
"enum",
"class",
"union" };
494 for (
int i = 0;
i <
sizeof(structs)/
sizeof(structs[0]);
i++ )
496 char* pStruct =
strstr (
p, structs[
i] );
513 if ( *pStruct ==
':' )
515 pStruct =
skip_ws ( pStruct + 1 );
527 if ( *pStruct ==
'{' )
552 if ( tokens[off] ==
"__declspec" )
560 if ( tokens[off] ==
"(" )
562 else if ( tokens[off] ==
")" )
583 if ( tokens[off] ==
"__asm__" )
585 else if ( tokens[off] ==
"return" )
587 else if ( tokens[off] ==
"typedef_tident" )
589 else if ( tokens[off] ==
"if" )
591 else if ( tokens[off] ==
"while" )
593 else if ( tokens[off] ==
"do" )
598 for (
int i = off;
i < tokens.
size();
i++ )
600 if ( tokens[
i] ==
"(" && !brackets )
602 else if ( tokens[
i] ==
")" && !brackets && openparens == 1 )
604 else if ( tokens[
i] ==
"{" )
606 else if ( (tokens[
i] ==
"struct" || tokens[
i] ==
"union") && !openparens )
608 for (
int j =
i + 1;
j < tokens.
size();
j++ )
610 if ( tokens[
j] ==
"{" )
612 else if ( tokens[
j] ==
"(" || tokens[
j] ==
";" || tokens[
j] ==
"*" )
616 else if ( tokens[
i] ==
";" )
618 else if ( tokens[
i] ==
"__attribute__" )
621 if ( openparens > 1 && closeparens )
623 else if ( openparens >= 1 )
632 dependencies.
resize ( 0 );
640 if ( tokens[
i] ==
"typedef" )
675 TOKASSERT(!
"unidentified type in parse_type()");
686 for (
int i = 0;
i <
names.size();
i++ )
700 for (
int i = 0;
i < dependencies.
size();
i++ )
702 if ( dependencies[
i] ==
ident )
711 while ( tokens[off] !=
";" )
713 ASSERT ( tokens[off] ==
";" );
719 TOKASSERT ( tokens[off] ==
"typedef_tident" );
720 TOKASSERT ( tokens[off+1] ==
"(" && tokens[off+3] ==
")" );
721 names.push_back ( tokens[off+2] );
722 dependencies.
push_back (
"typedef_tident" );
729 if ( tokens[off] ==
";" )
731 depend ( tokens[off++], dependencies );
732 int done = tokens.
size();
733 while ( off < tokens.
size() && tokens[off] !=
";" )
741 int done = tokens.
size();
746 while ( off < done && tokens[off] !=
"struct" && tokens[off] !=
"union" )
747 depend ( tokens[off++], dependencies );
749 TOKASSERT ( tokens[off] ==
"struct" || tokens[off] ==
"union" );
750 if ( tokens[off] !=
"struct" && tokens[off] !=
"union" )
754 if ( tokens[off] !=
"{" )
757 if ( tokens[off] ==
":" )
760 TOKASSERT ( tokens[off] ==
"public" || tokens[off] ==
"protected" || tokens[off] ==
"private" );
762 depend ( tokens[off++], dependencies );
771 while ( off < done && tokens[off] !=
"}" )
775 off =
parse_type (
t, tokens, off, fauxnames, dependencies );
780 while ( tokens[off] !=
";" )
783 if ( tokens[off+1] ==
"," || tokens[off+1] ==
";" )
786 depend ( tokens[off], dependencies );
798 if ( tokens[off] ==
")" )
806 if ( tokens[done] ==
"," && parens == 1 )
808 if ( tokens[done] ==
")" )
815 if ( tokens[done] ==
"(" )
817 if ( tokens[done] ==
"*" && tokens[done-1] ==
"(" )
824 depend ( tokens[off++], dependencies );
836 while ( tokens[off+1] !=
"(" )
837 depend ( tokens[off++], dependencies );
842 while ( tokens[off] !=
")" )
845 off =
parse_param ( tokens, off, fauxnames, dependencies );
846 TOKASSERT ( tokens[off] ==
"," || tokens[off] ==
")" );
852 if ( tokens[off] ==
"__attribute__" )
860 if ( tokens[off] ==
"(" )
862 else if ( tokens[off] ==
")" )
869 if ( tokens[off] ==
";" )
876 while ( tokens[off] !=
"}" )
880 off =
parse_type (
t, tokens, off, fauxnames, dependencies );
883 while ( tokens[off] !=
";" )
900 while ( tokens[off] !=
"(" )
901 depend ( tokens[off++], dependencies );
906 while ( tokens[off+1] !=
")" )
907 depend ( tokens[off++], dependencies );
916 while ( tokens[off] !=
")" )
920 off =
parse_param ( tokens, off, fauxnames, dependencies );
921 TOKASSERT ( tokens[off] ==
"," || tokens[off] ==
")" );
932 TOKASSERT ( tokens[off] ==
"if" || tokens[off] ==
"while" );
939 while ( tokens[off] !=
")" )
942 if ( tokens[off] ==
"{" )
944 while ( tokens[off] !=
"}" )
959 if ( tokens[off] !=
"{" )
966 while ( tokens[off] !=
"}" )
977 while ( tokens[off] !=
")" )
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
char * strpbrk(const char *String, const char *Delimiters)
const _CharT * c_str() const
static const WCHAR indent[]
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
bool iskeyword(const string &ident)
_Check_return_ _CRTIMP int __cdecl getch(void)
_CRTIMP char *__cdecl strupr(_Inout_z_ char *_Str)
_CRTIMP char *__cdecl strlwr(_Inout_z_ char *_Str)
int parse_tident(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
int parse_variable(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
bool import_file(const char *filename)
bool is_libc_include(const string &inc)
BOOL FileEnumProc(PWIN32_FIND_DATA pwfd, const char *filename, long lParam)
string get_hdrguardtext(const char *filename)
int parse_function_ptr(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
char * findend(char *p, bool &externc)
Type identify(const vector< string > &tokens, int off=0)
const char * libc_includes[]
vector< Header * > headers
int parse_ignored_statement(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
int parse_struct(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
int parse_param(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
void process_preprocessor(const char *filename, Header &h, const string &element)
void depend(const string &ident, vector< string > &dependencies)
void process_c(Header &h, const string &element)
int parse_do(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
int parse_type(Type t, const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
int skip_declspec(const vector< string > &tokens, int off)
int parse_ifwhile(const vector< string > &tokens, int off, vector< string > &names, vector< string > &dependencies)
static LPCTSTR skip_ws(LPCTSTR p)
void push_back(const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
void resize(size_type __new_size, const _Tp &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
void tokenize(const string &text, vector< string > &tokens)
_In_ ULONG _In_ ULONG_PTR ident