mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-06-15 22:03:24 -06:00
.autotest
git-svn-id: svn://ultimatepp.org/upp/trunk@8432 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
0766826c68
commit
7c3bc633e4
5 changed files with 0 additions and 348 deletions
|
|
@ -1,42 +0,0 @@
|
|||
#include <Core/Core.h>
|
||||
#include <CppBase/CppBase.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
StringStream ss;
|
||||
|
||||
void Error(int line, const String& error)
|
||||
{
|
||||
ss << "ERROR at " << line << ": " << error << "\n";
|
||||
}
|
||||
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
FindFile ff(GetDataFile("*.tc"));
|
||||
while(ff) {
|
||||
FileIn in(ff.GetPath());
|
||||
ss.Create();
|
||||
CppBase base;
|
||||
Parse(in, Vector<String>(), base, "test.cpp", callback(Error));
|
||||
Qualify(base);
|
||||
for(int i = 0; i < base.GetCount(); i++) {
|
||||
ss << "======== " << Nvl(base.GetKey(i), "GLOBALS") << "\n";
|
||||
const Array<CppItem>& am = base[i];
|
||||
for(int j = 0; j < am.GetCount(); j++) {
|
||||
const CppItem& m = am[j];
|
||||
m.Dump(ss);
|
||||
}
|
||||
}
|
||||
String result = ss.GetResult();
|
||||
LOG("****** FILE: " << ff.GetName());
|
||||
VppLog() << result;
|
||||
LOG("******\n\n");
|
||||
String h = LoadFile(ForceExt(ff.GetPath(), ".r"));
|
||||
result.Replace("\r", "");
|
||||
h.Replace("\r", "");
|
||||
if(h.GetCount())
|
||||
ASSERT(h == result);
|
||||
ff.Next();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
uses
|
||||
Core,
|
||||
CppBase;
|
||||
|
||||
file
|
||||
CppBaseTest.cpp,
|
||||
Test.tc highlight cpp,
|
||||
Test.r;
|
||||
|
||||
mainconfig
|
||||
"" = "";
|
||||
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
ERROR at 63: Name expected
|
||||
======== GLOBALS
|
||||
? VARIABLE PUBLIC FILE_CPP lvalue 3
|
||||
natural: NAMESPACE_UPP
|
||||
type: NAMESPACE_UPP
|
||||
qtype: NAMESPACE_UPP
|
||||
? VARIABLE PUBLIC FILE_CPP lvalue 63
|
||||
natural: void
|
||||
? VARIABLE PUBLIC FILE_CPP lvalue 201
|
||||
natural: END_UPP_NAMESPACE
|
||||
type: END_UPP_NAMESPACE
|
||||
qtype: END_UPP_NAMESPACE
|
||||
Foo(int,const String&) FUNCTION PUBLIC FILE_CPP decla lvalue 65
|
||||
item: Foo(int,const String&)
|
||||
name: Foo
|
||||
uname: FOO
|
||||
natural: void Foo(int x, const String& y)
|
||||
param: int x;const String& y
|
||||
pname: x;y
|
||||
ptype: ;String
|
||||
qptype: ;String
|
||||
Foo(int,const String&) FUNCTION PUBLIC FILE_CPP decla lvalue impl 67
|
||||
item: Foo(int,const String&)
|
||||
name: Foo
|
||||
uname: FOO
|
||||
natural: void Foo(int x, const String& y)
|
||||
param: int x;const String& y
|
||||
pname: x;y
|
||||
ptype: ;String
|
||||
qptype: ;String
|
||||
GetCppFile(int) FUNCTION PUBLIC FILE_CPP decla lvalue impl 21
|
||||
item: GetCppFile(int)
|
||||
name: GetCppFile
|
||||
uname: GETCPPFILE
|
||||
natural: const String& GetCppFile(int i)
|
||||
type: String
|
||||
qtype: String
|
||||
param: int i
|
||||
pname: i
|
||||
GetCppFileIndex(const String&) FUNCTION PUBLIC FILE_CPP decla lvalue impl 13
|
||||
item: GetCppFileIndex(const String&)
|
||||
name: GetCppFileIndex
|
||||
uname: GETCPPFILEINDEX
|
||||
natural: int GetCppFileIndex(const String& path)
|
||||
param: const String& path
|
||||
pname: path
|
||||
ptype: String
|
||||
qptype: String
|
||||
PreProcess(Stream&) FUNCTION PUBLIC FILE_CPP decla lvalue impl 69
|
||||
item: PreProcess(Stream&)
|
||||
name: PreProcess
|
||||
uname: PREPROCESS
|
||||
natural: SrcFile PreProcess(Stream& in)
|
||||
type: SrcFile
|
||||
qtype: SrcFile
|
||||
param: Stream& in
|
||||
pname: in
|
||||
ptype: Stream
|
||||
qptype: Stream
|
||||
SLPos(SrcFile&) FUNCTION PUBLIC FILE_CPP decla lvalue impl 51
|
||||
item: SLPos(SrcFile&)
|
||||
name: SLPos
|
||||
uname: SLPOS
|
||||
natural: void SLPos(SrcFile& res)
|
||||
param: SrcFile& res
|
||||
pname: res
|
||||
ptype: SrcFile
|
||||
qptype: SrcFile
|
||||
cpp_file VARIABLE PUBLIC FILE_CPP lvalue 11
|
||||
item: cpp_file
|
||||
name: cpp_file
|
||||
uname: CPP_FILE
|
||||
natural: static Index<String> cpp_file
|
||||
type: Index<String>
|
||||
qtype: Index<String>
|
||||
cpp_file_mutex VARIABLE PUBLIC FILE_CPP lvalue 10
|
||||
item: cpp_file_mutex
|
||||
name: cpp_file_mutex
|
||||
uname: CPP_FILE_MUTEX
|
||||
natural: static StaticMutex cpp_file_mutex
|
||||
type: StaticMutex
|
||||
qtype: StaticMutex
|
||||
======== SrcFile
|
||||
SrcFile() CONSTRUCTOR PUBLIC FILE_CPP decla lvalue impl 56
|
||||
item: SrcFile()
|
||||
name: SrcFile
|
||||
uname: SRCFILE
|
||||
natural: SrcFile()
|
||||
|
|
@ -1,201 +0,0 @@
|
|||
#include "CppBase.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma inline_depth(255)
|
||||
#pragma optimize("t", on)
|
||||
#endif
|
||||
|
||||
static StaticMutex cpp_file_mutex;
|
||||
static Index<String> cpp_file;
|
||||
|
||||
int GetCppFileIndex(const String& path)
|
||||
{
|
||||
INTERLOCKED_(cpp_file_mutex) {
|
||||
return cpp_file.FindAdd(path);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const String& GetCppFile(int i)
|
||||
{
|
||||
INTERLOCKED_(cpp_file_mutex) {
|
||||
return cpp_file[i];
|
||||
}
|
||||
static String x;
|
||||
return x;
|
||||
}
|
||||
/*
|
||||
void CppPos::Serialize(Stream& s)
|
||||
{
|
||||
s % impl % line;
|
||||
String fn = GetCppFile(file);
|
||||
s % fn;
|
||||
file = GetCppFileIndex(fn);
|
||||
}
|
||||
|
||||
String SSpaces(const char *txt)
|
||||
{
|
||||
StringBuffer r;
|
||||
while(*txt)
|
||||
if(*txt == ' ') {
|
||||
while((byte)*txt <= ' ' && *txt) txt++;
|
||||
r.Cat(' ');
|
||||
}
|
||||
else
|
||||
r.Cat(*txt++);
|
||||
return r;
|
||||
}
|
||||
*/
|
||||
void SLPos(SrcFile& res)
|
||||
{
|
||||
res.linepos.Add(res.text.GetLength());
|
||||
}
|
||||
|
||||
SrcFile::SrcFile() :
|
||||
preprocessorLinesRemoved(0),
|
||||
blankLinesRemoved(0),
|
||||
commentLinesRemoved(0)
|
||||
{
|
||||
}
|
||||
|
||||
void 3BUG();
|
||||
|
||||
void Foo(int x, const String& y);
|
||||
|
||||
void Foo(int x, const String& y) {}
|
||||
|
||||
SrcFile PreProcess(Stream& in)
|
||||
{
|
||||
SrcFile res;
|
||||
bool include = true;
|
||||
while(!in.IsEof()) {
|
||||
String ln = in.GetLine();
|
||||
SLPos(res);
|
||||
while(*ln.Last() == '\\') {
|
||||
ln.Trim(ln.GetLength() - 1);
|
||||
ln.Cat(in.GetLine());
|
||||
SLPos(res);
|
||||
}
|
||||
const char *rm = ln;
|
||||
if(IsAlNum(*rm)) {
|
||||
const char *s = ln.Last();
|
||||
while(s > rm && *s == ' ') s--;
|
||||
if(*s != ':')
|
||||
res.text << '\2';
|
||||
}
|
||||
while(*rm == ' ' || *rm == '\t') rm++;
|
||||
if(*rm == '\0')
|
||||
res.blankLinesRemoved++;
|
||||
else
|
||||
if(*rm == '#')
|
||||
{
|
||||
if(rm[1] == 'd' && rm[2] == 'e' && rm[3] == 'f' &&
|
||||
rm[4] == 'i' && rm[5] == 'n' && rm[6] == 'e' && !iscid(rm[7])) {
|
||||
const char *s = rm + 8;
|
||||
while(*s == ' ') s++;
|
||||
String macro;
|
||||
while(iscid(*s))
|
||||
macro.Cat(*s++);
|
||||
if(*s == '(') {
|
||||
while(*s != ')' && *s)
|
||||
macro.Cat(*s++);
|
||||
macro << ')';
|
||||
}
|
||||
// res.text << '#' << AsCString(SSpaces(macro));
|
||||
if(include)
|
||||
res.text << '#' << AsCString(macro);
|
||||
}
|
||||
res.preprocessorLinesRemoved++;
|
||||
}
|
||||
else {
|
||||
bool lineContainsComment = false;
|
||||
bool lineContainsNonComment = false;
|
||||
String cmd;
|
||||
while(*rm) {
|
||||
if(*rm == '\"') {
|
||||
lineContainsNonComment = true;
|
||||
res.text << '\"';
|
||||
rm++;
|
||||
while((byte)*rm && *rm != '\r' && *rm != '\n') {
|
||||
if(*rm == '\"') {
|
||||
res.text << '\"';
|
||||
rm++;
|
||||
break;
|
||||
}
|
||||
if(*rm == '\\' && rm[1]) {
|
||||
if(include)
|
||||
res.text.Cat(*rm);
|
||||
rm++;
|
||||
}
|
||||
if(include)
|
||||
res.text.Cat(*rm);
|
||||
rm++;
|
||||
}
|
||||
}
|
||||
else
|
||||
if(*rm == '\\' && rm[1]) {
|
||||
lineContainsNonComment = true;
|
||||
if(include) {
|
||||
res.text.Cat(*rm++);
|
||||
res.text.Cat(*rm++);
|
||||
}
|
||||
else
|
||||
rm += 2;
|
||||
}
|
||||
else
|
||||
if(rm[0] == '/' && rm[1] == '/') {
|
||||
cmd = rm + 2;
|
||||
if(!lineContainsNonComment)
|
||||
res.commentLinesRemoved++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(rm[0] == '/' && rm[1] == '*') {
|
||||
lineContainsComment = true;
|
||||
rm += 2;
|
||||
for(;;) {
|
||||
if(*rm == '\0') {
|
||||
if(!lineContainsNonComment)
|
||||
res.commentLinesRemoved++;
|
||||
if(in.IsEof()) break;
|
||||
SLPos(res);
|
||||
ln = in.GetLine();
|
||||
rm = ~ln;
|
||||
lineContainsNonComment = false;
|
||||
}
|
||||
if(rm[0] == '*' && rm[1] == '/') {
|
||||
rm += 2;
|
||||
break;
|
||||
}
|
||||
rm++;
|
||||
}
|
||||
if(include)
|
||||
res.text.Cat(' ');
|
||||
}
|
||||
else {
|
||||
lineContainsNonComment = true;
|
||||
if(include)
|
||||
res.text.Cat(*rm);
|
||||
rm++;
|
||||
}
|
||||
}
|
||||
if(include)
|
||||
res.text << ' ';
|
||||
if(cmd[0] == '$') {
|
||||
if(cmd[1] == '-') include = false;
|
||||
if(cmd[1] == '+') include = true;
|
||||
if(cmd[1]) {
|
||||
res.text.Cat(~cmd + 2);
|
||||
res.text.Cat(' ');
|
||||
}
|
||||
}
|
||||
if(lineContainsComment && !lineContainsNonComment)
|
||||
res.commentLinesRemoved++;
|
||||
}
|
||||
}
|
||||
return pick(res);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _CppBaseTest_icpp_init_stub
|
||||
#define _CppBaseTest_icpp_init_stub
|
||||
#include "Core/init"
|
||||
#include "CppBase/init"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue