git-svn-id: svn://ultimatepp.org/upp/trunk@8159 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-02-09 18:22:27 +00:00
parent d91bdd45d9
commit ca1913c579
5 changed files with 181 additions and 104 deletions

View file

@ -1,36 +1,43 @@
#include "cpp.h"
/*
#define TEST(x, y) %x%y%
#define TESTS(x) #x
#define TEST2(x, y) x ## y
#define TEST4 alfa x ## y.r #hahaha
#define TESTX x\
//h
Vector<String> errs;
#define TESTY haha // note\
ble
void AddError(int ln, const String& s)
{
errs.Add(AsString(ln) + ": " + s);
}
#define TESTZ haha \
ble
void Test(const char *path)
{
CppBase base;
//*
TEST('\1', "\2")
TEST( 1 +1 , 3 )
TEST( "1" "2" ",", ',')
TESTS(a)
TESTS(a x y)
TESTS("A")
TEST2(a, 3)
TEST2(3, a)
TEST2(a, #)
TEST2(a, "X")
TEST2("Y", "X")
TESTX
TESTY
TESTZ
TEST4
//*/
Cpp cpp;
cpp.filedir = GetFileFolder(path);
cpp.include_path = "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Vc\\Include;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include;C:\\OpenSSL-Win32\\include;C:\\u\\pgsql\\include;C:\\u\\OpenSSL-Win32\\include";
FileIn in(path);
Index<String> inc;
String pp = cpp.Do(in, inc);
SaveFile(GetHomeDirFile(GetFileTitle(path) + ".pp"), pp);
StringStream ss(pp);
Parse(ss, Vector<String>() << "__cdecl", base, path, callback(AddError));
DLOG("=======================");
DUMPC(inc);
DLOG("=======================");
DUMPC(errs);
DLOG("=======================");
Qualify(base);
String out;
for(int i = 0; i < base.GetCount(); i++) {
out << Nvl(base.GetKey(i), "<globals>") << " {\n";
const Array<CppItem>& ma = base[i];
for(int j = 0; j < ma.GetCount(); j++) {
const CppItem& m = ma[j];
out << '\t' << CppItemKindAsString(m.kind) << ' ' << m.qitem << ' ' << m.line << "\n";
}
out << "}\n";
}
LOG(out);
}
CONSOLE_APP_MAIN
{
@ -54,17 +61,29 @@ CONSOLE_APP_MAIN
DUMP(x.Expand("This is: TEST((1 , 2), 3)!"));
DUMP(x.Expand("This is: TEST( \"1\" \"2\" \",\", ',')!"));
*/
// Test("C:/OpenSSL-Win32/include/openssl/ssl.h");
Test("C:/Program Files/Microsoft SDKs/Windows/v7.1/Include/WinBase.h");
// Test("C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Vc\\Include\\string.h");
return;
Cpp x;
x.filedir = GetFileFolder(GetDataFile("x"));
x.include_path = "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Vc\\Include;C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include;C:\\OpenSSL-Win32\\include;C:\\u\\pgsql\\include;C:\\u\\OpenSSL-Win32\\include";
x.level = 0;
// FileIn in0("C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Vc\\Include\\crtdefs.h");
// x.Preprocess(in0);
// FileIn in("C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Vc\\Include\\string.h");
FileIn in(GetDataFile("test.h"));
LOG(x.Preprocess(in));
// FileIn in(GetDataFile("test.h"));
FileIn in("C:/OpenSSL-Win32/include/openssl/ssl.h");
// FileIn in();
Index<String> inc;
LOG(x.Do(in, inc));
LOG("---------------------------");
DUMPM(x.macro);
LOG("---------------------------");
DUMPC(x.usedmacro);
LOG("---------------------------");
DUMPC(x.notmacro);
LOG("---------------------------");
DUMPC(inc);
}
// TEST:a,b:|a|b|\n