mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 02:01:21 +00:00
more special-cases
svn path=/trunk/; revision=6685
This commit is contained in:
parent
6c1d0b1576
commit
1f5f11925a
2 changed files with 100 additions and 9 deletions
|
@ -87,8 +87,8 @@ BOOL FileEnumProc ( PWIN32_FIND_DATA pwfd, const char* filename, long lParam )
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
printf ( "press any key to start\n" );
|
//printf ( "press any key to start\n" );
|
||||||
getch();
|
//getch();
|
||||||
#if 1
|
#if 1
|
||||||
import_file ( "../test.h" );
|
import_file ( "../test.h" );
|
||||||
#else
|
#else
|
||||||
|
@ -208,8 +208,12 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
p = end+1;
|
p = end+1;
|
||||||
p = skip_ws ( p );
|
p = skip_ws ( p );
|
||||||
|
|
||||||
|
const string dbg_filename = "napi/lpc.h DISABLE DISABLE DISABLE";
|
||||||
|
|
||||||
if ( preproc == "include" )
|
if ( preproc == "include" )
|
||||||
{
|
{
|
||||||
|
//if ( h.filename == "napi/lpc.h" )
|
||||||
|
// _CrtDbgBreak();
|
||||||
ASSERT ( *p == '<' || *p == '\"' );
|
ASSERT ( *p == '<' || *p == '\"' );
|
||||||
p++;
|
p++;
|
||||||
p = skip_ws ( p );
|
p = skip_ws ( p );
|
||||||
|
@ -224,7 +228,7 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
for ( int i = 0; i < headers.size(); i++ )
|
for ( int i = 0; i < headers.size() && !loaded; i++ )
|
||||||
{
|
{
|
||||||
if ( headers[i]->filename == include_filename )
|
if ( headers[i]->filename == include_filename )
|
||||||
{
|
{
|
||||||
|
@ -277,6 +281,8 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
}
|
}
|
||||||
else if ( preproc == "if" || preproc == "ifdef" || preproc == "ifndef" )
|
else if ( preproc == "if" || preproc == "ifdef" || preproc == "ifndef" )
|
||||||
{
|
{
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "(%s) PRE-PUSH preproc stack = %lu\n", preproc.c_str(), h.ifs.size() );
|
||||||
size_t len = element.size();
|
size_t len = element.size();
|
||||||
// check for header include guard...
|
// check for header include guard...
|
||||||
if ( strstr ( element.c_str(), hdrguardtext.c_str() )
|
if ( strstr ( element.c_str(), hdrguardtext.c_str() )
|
||||||
|
@ -286,14 +292,23 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
else
|
else
|
||||||
h.ifs.push_back ( element );
|
h.ifs.push_back ( element );
|
||||||
h.ifspreproc.push_back ( preproc );
|
h.ifspreproc.push_back ( preproc );
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "POST-PUSH preproc stack = %lu\n", h.ifs.size() );
|
||||||
}
|
}
|
||||||
else if ( preproc == "endif" )
|
else if ( preproc == "endif" )
|
||||||
{
|
{
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "(%s) PRE-POP preproc stack = %lu\n", preproc.c_str(), h.ifs.size() );
|
||||||
|
ASSERT ( h.ifs.size() > 0 && h.ifs.size() == h.ifspreproc.size() );
|
||||||
h.ifs.pop_back();
|
h.ifs.pop_back();
|
||||||
h.ifspreproc.pop_back();
|
h.ifspreproc.pop_back();
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "POST-POP preproc stack = %lu\n", h.ifs.size() );
|
||||||
}
|
}
|
||||||
else if ( preproc == "elif" )
|
else if ( preproc == "elif" )
|
||||||
{
|
{
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "(%s) PRE-PUSHPOP preproc stack = %lu\n", preproc.c_str(), h.ifs.size() );
|
||||||
string& oldpre = h.ifspreproc.back();
|
string& oldpre = h.ifspreproc.back();
|
||||||
string old = h.ifs.back();
|
string old = h.ifs.back();
|
||||||
string condold;
|
string condold;
|
||||||
|
@ -311,9 +326,13 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
}
|
}
|
||||||
h.ifs.back() = string("(") + element + ") && " + condold;
|
h.ifs.back() = string("(") + element + ") && " + condold;
|
||||||
h.ifspreproc.back() = "if";
|
h.ifspreproc.back() = "if";
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "POST-PUSHPOP preproc stack = %lu\n", h.ifs.size() );
|
||||||
}
|
}
|
||||||
else if ( preproc == "else" )
|
else if ( preproc == "else" )
|
||||||
{
|
{
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "(%s) PRE-PUSHPOP preproc stack = %lu\n", preproc.c_str(), h.ifs.size() );
|
||||||
string& oldpre = h.ifspreproc.back();
|
string& oldpre = h.ifspreproc.back();
|
||||||
ASSERT ( oldpre != "else" );
|
ASSERT ( oldpre != "else" );
|
||||||
if ( oldpre == "ifdef" )
|
if ( oldpre == "ifdef" )
|
||||||
|
@ -329,6 +348,8 @@ void process_preprocessor ( const char* filename, Header& h, const string& eleme
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
oldpre = "else";
|
oldpre = "else";
|
||||||
|
if ( dbg_filename == h.filename )
|
||||||
|
printf ( "POST-PUSHPOP preproc stack = %lu\n", h.ifs.size() );
|
||||||
}
|
}
|
||||||
else if ( preproc == "include_next" )
|
else if ( preproc == "include_next" )
|
||||||
{
|
{
|
||||||
|
@ -511,13 +532,34 @@ char* findend ( char* p, bool& externc )
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int skip_declspec ( const vector<string>& tokens, int off )
|
||||||
|
{
|
||||||
|
if ( tokens[off] == "__declspec" )
|
||||||
|
{
|
||||||
|
off++;
|
||||||
|
TOKASSERT ( tokens[off] == "(" );
|
||||||
|
off++;
|
||||||
|
int parens = 1;
|
||||||
|
while ( parens )
|
||||||
|
{
|
||||||
|
if ( tokens[off] == "(" )
|
||||||
|
parens++;
|
||||||
|
else if ( tokens[off] == ")" )
|
||||||
|
parens--;
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return off;
|
||||||
|
}
|
||||||
|
|
||||||
Type identify ( const vector<string>& tokens, int off )
|
Type identify ( const vector<string>& tokens, int off )
|
||||||
{
|
{
|
||||||
if ( tokens.size() > off+2 )
|
off = skip_declspec ( tokens, off );
|
||||||
|
/*if ( tokens.size() > off+4 )
|
||||||
{
|
{
|
||||||
if ( tokens[off+2] == "_lfind" )
|
if ( tokens[off+4] == "PCONTROLDISPATCHER" )
|
||||||
_CrtDbgBreak();
|
_CrtDbgBreak();
|
||||||
}
|
}*/
|
||||||
/*if ( tokens.size() > off+1 )
|
/*if ( tokens.size() > off+1 )
|
||||||
{
|
{
|
||||||
if ( tokens[off+1] == "_OSVERSIONINFOEXA" )
|
if ( tokens[off+1] == "_OSVERSIONINFOEXA" )
|
||||||
|
@ -558,6 +600,8 @@ Type identify ( const vector<string>& tokens, int off )
|
||||||
}
|
}
|
||||||
else if ( tokens[i] == ";" )
|
else if ( tokens[i] == ";" )
|
||||||
break;
|
break;
|
||||||
|
else if ( tokens[i] == "__attribute__" )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if ( openparens > 1 && closeparens )
|
if ( openparens > 1 && closeparens )
|
||||||
return T_FUNCTION_PTR;
|
return T_FUNCTION_PTR;
|
||||||
|
@ -738,8 +782,32 @@ int parse_param ( const vector<string>& tokens, int off, vector<string>& names,
|
||||||
{
|
{
|
||||||
if ( tokens[off] == ")" )
|
if ( tokens[off] == ")" )
|
||||||
return off;
|
return off;
|
||||||
while ( tokens[off+1] != "," && tokens[off+1] != ")" )
|
// special-case check for function pointer params
|
||||||
|
int done = off;
|
||||||
|
int parens = 1;
|
||||||
|
bool fptr = false;
|
||||||
|
for ( ;; )
|
||||||
|
{
|
||||||
|
if ( tokens[done] == "," && parens == 1 )
|
||||||
|
break;
|
||||||
|
if ( tokens[done] == ")" )
|
||||||
|
{
|
||||||
|
if ( parens == 1 )
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
parens--;
|
||||||
|
}
|
||||||
|
if ( tokens[done] == "(" )
|
||||||
|
parens++;
|
||||||
|
if ( tokens[done] == "*" && tokens[done-1] == "(" )
|
||||||
|
fptr = true;
|
||||||
|
done++;
|
||||||
|
}
|
||||||
|
if ( !fptr )
|
||||||
|
done--;
|
||||||
|
while ( off < done )
|
||||||
depend ( tokens[off++], dependencies );
|
depend ( tokens[off++], dependencies );
|
||||||
|
if ( !fptr )
|
||||||
name ( tokens[off++], names );
|
name ( tokens[off++], names );
|
||||||
return off;
|
return off;
|
||||||
}
|
}
|
||||||
|
@ -748,6 +816,8 @@ int parse_function ( const vector<string>& tokens, int off, vector<string>& name
|
||||||
{
|
{
|
||||||
vector<string> fauxnames;
|
vector<string> fauxnames;
|
||||||
|
|
||||||
|
off = skip_declspec ( tokens, off );
|
||||||
|
|
||||||
while ( tokens[off+1] != "(" )
|
while ( tokens[off+1] != "(" )
|
||||||
depend ( tokens[off++], dependencies );
|
depend ( tokens[off++], dependencies );
|
||||||
name ( tokens[off++], names );
|
name ( tokens[off++], names );
|
||||||
|
@ -763,6 +833,23 @@ int parse_function ( const vector<string>& tokens, int off, vector<string>& name
|
||||||
|
|
||||||
off++;
|
off++;
|
||||||
|
|
||||||
|
// check for "attributes"
|
||||||
|
if ( tokens[off] == "__attribute__" )
|
||||||
|
{
|
||||||
|
off++;
|
||||||
|
TOKASSERT ( tokens[off] == "(" );
|
||||||
|
off++;
|
||||||
|
int parens = 1;
|
||||||
|
while ( parens )
|
||||||
|
{
|
||||||
|
if ( tokens[off] == "(" )
|
||||||
|
parens++;
|
||||||
|
else if ( tokens[off] == ")" )
|
||||||
|
parens--;
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// is this just a function *declaration* ?
|
// is this just a function *declaration* ?
|
||||||
if ( tokens[off] == ";" )
|
if ( tokens[off] == ";" )
|
||||||
return off;
|
return off;
|
||||||
|
@ -793,6 +880,8 @@ int parse_function ( const vector<string>& tokens, int off, vector<string>& name
|
||||||
|
|
||||||
int parse_function_ptr ( const vector<string>& tokens, int off, vector<string>& names, vector<string>& dependencies )
|
int parse_function_ptr ( const vector<string>& tokens, int off, vector<string>& names, vector<string>& dependencies )
|
||||||
{
|
{
|
||||||
|
off = skip_declspec ( tokens, off );
|
||||||
|
|
||||||
while ( tokens[off] != "(" )
|
while ( tokens[off] != "(" )
|
||||||
depend ( tokens[off++], dependencies );
|
depend ( tokens[off++], dependencies );
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: test.h,v 1.3 2003/11/06 19:38:23 royce Exp $
|
/* $Id: test.h,v 1.4 2003/11/18 05:20:00 royce Exp $
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* test.h
|
* test.h
|
||||||
|
@ -22,6 +22,8 @@
|
||||||
#ifndef __INTERNAL_PSAPI_H_INCLUDED__
|
#ifndef __INTERNAL_PSAPI_H_INCLUDED__
|
||||||
#define __INTERNAL_PSAPI_H_INCLUDED__
|
#define __INTERNAL_PSAPI_H_INCLUDED__
|
||||||
|
|
||||||
|
void *_lfind(const void* match, const void* start,unsigned int* array_size, unsigned int elem_size,int (*cf)(const void*,const void*));
|
||||||
|
|
||||||
static inline struct _TEB * NtCurrentTeb(void)
|
static inline struct _TEB * NtCurrentTeb(void)
|
||||||
{
|
{
|
||||||
struct _TEB * pTeb;
|
struct _TEB * pTeb;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue