Skip to content

Commit

Permalink
Update release
Browse files Browse the repository at this point in the history
  • Loading branch information
vczh committed Jul 31, 2018
1 parent 620c80f commit 8e276b2
Show file tree
Hide file tree
Showing 40 changed files with 4,776 additions and 4,595 deletions.
38 changes: 25 additions & 13 deletions Import/GacUICompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ namespace vl
using namespace collections;
using namespace stream;
using namespace filesystem;
using namespace parsing;
using namespace workflow;
using namespace workflow::cppcodegen;

Ptr<GuiResourceFolder> PrecompileAndWriteErrors(
Ptr<GuiResource> resource,
IGuiResourcePrecompileCallback* callback,
bool WriteErrors(
collections::List<GuiResourceError>& errors,
const filesystem::FilePath& errorPath)
{
List<WString> output;
GuiResourceError::SortAndLog(errors, output);
return File(errorPath).WriteAllLines(output, true, BomEncoder::Utf8);
}

Ptr<GuiResourceFolder> PrecompileResource(
Ptr<GuiResource> resource,
IGuiResourcePrecompileCallback* callback,
collections::List<GuiResourceError>& errors)
{
auto precompiledFolder = resource->Precompile(callback, errors);
if (errors.Count() > 0)
{
List<WString> output;
GuiResourceError::SortAndLog(errors, output);
if (!File(errorPath).WriteAllLines(output, true, BomEncoder::Utf8))
{
return nullptr;
}
}
return precompiledFolder;
}

Expand Down Expand Up @@ -79,11 +79,23 @@ namespace vl
}

Ptr<workflow::cppcodegen::WfCppOutput> WriteCppCodesToFile(
Ptr<GuiResource> resource,
Ptr<GuiInstanceCompiledWorkflow> compiled,
Ptr<workflow::cppcodegen::WfCppInput> cppInput,
const filesystem::FilePath& cppFolder)
const filesystem::FilePath& cppFolder,
collections::List<GuiResourceError>& errors)
{
auto output = GenerateCppFiles(cppInput, compiled->metadata.Obj());

if (compiled->metadata->errors.Count() > 0)
{
FOREACH(Ptr<ParsingError>, error, compiled->metadata->errors)
{
errors.Add(GuiResourceError({ {resource} }, error->errorMessage));
}
return nullptr;
}

FOREACH_INDEXER(WString, fileName, index, output->cppFiles.Keys())
{
WString code = output->cppFiles.Values()[index];
Expand Down
14 changes: 10 additions & 4 deletions Import/GacUICompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,21 +939,27 @@ namespace vl
{
using namespace reflection;

extern Ptr<GuiResourceFolder> PrecompileAndWriteErrors(
extern bool WriteErrors(
collections::List<GuiResourceError>& errors,
const filesystem::FilePath& errorPath
);

extern Ptr<GuiResourceFolder> PrecompileResource(
Ptr<GuiResource> resource,
IGuiResourcePrecompileCallback* callback,
collections::List<GuiResourceError>& errors,
const filesystem::FilePath& errorPath);
collections::List<GuiResourceError>& errors);

extern Ptr<GuiInstanceCompiledWorkflow> WriteWorkflowScript(
Ptr<GuiResourceFolder> precompiledFolder,
const WString& assemblyResourcePath,
const filesystem::FilePath& workflowPath);

extern Ptr<workflow::cppcodegen::WfCppOutput> WriteCppCodesToFile(
Ptr<GuiResource> resource,
Ptr<GuiInstanceCompiledWorkflow> compiled,
Ptr<workflow::cppcodegen::WfCppInput> cppInput,
const filesystem::FilePath& cppFolder);
const filesystem::FilePath& cppFolder,
collections::List<GuiResourceError>& errors);

extern bool WriteBinaryResource(
Ptr<GuiResource> resource,
Expand Down
2,680 changes: 1,340 additions & 1,340 deletions Import/Skins/DarkSkin/DarkSkin.cpp

Large diffs are not rendered by default.

2,814 changes: 1,407 additions & 1,407 deletions Import/Skins/DarkSkin/DarkSkin.h

Large diffs are not rendered by default.

153 changes: 135 additions & 18 deletions Import/VlppWorkflowCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4470,6 +4470,28 @@ WfErrors
{
return new ParsingError(node, L"G13: Auto property \"" + node->name.value + L"\" cannot be initialized in interface \"" + classDecl->name.value + L"\".");
}

Ptr<parsing::ParsingError> WfErrors::CppUnableToDecideClassOrder(WfClassDeclaration* node, collections::List<reflection::description::ITypeDescriptor*>& tds)
{
WString description;
FOREACH(ITypeDescriptor*, td, tds)
{
description += L"\r\n\t";
description += td->GetTypeName();
}
return new ParsingError(node, L"CPP1: (C++ Code Generation) Cannot decide order of the following classes. It is probably caused by inheritance relationships of internal classes inside these classes:" + description + L".");
}

Ptr<parsing::ParsingError> WfErrors::CppUnableToSeparateCustomFile(WfClassDeclaration* node, collections::List<reflection::description::ITypeDescriptor*>& tds)
{
WString description;
FOREACH(ITypeDescriptor*, td, tds)
{
description += L"\r\n\t";
description += td->GetTypeName();
}
return new ParsingError(node, L"CPP2: (C++ Code Generation) @cpp:File atrribute values for these classes are invalid. Generating classes to source files specified by these attribute values will create source files which do not compile. It is probably caused by inheritance relationships of internal classes inside these classes:" + description + L".");
}
}
}
}
Expand Down Expand Up @@ -10464,15 +10486,15 @@ CreateTypeInfoFromType
VisitReferenceType(node);
}

static Ptr<ITypeInfo> Execute(WfLexicalScope* scope, WfType* type)
static Ptr<ITypeInfo> Execute(WfLexicalScope* scope, WfType* type, bool checkTypeForValue)
{
return CreateTypeInfoFromTypeVisitor(scope).Call(type, true);
return CreateTypeInfoFromTypeVisitor(scope).Call(type, checkTypeForValue);
}
};

Ptr<reflection::description::ITypeInfo> CreateTypeInfoFromType(WfLexicalScope* scope, Ptr<WfType> type)
Ptr<reflection::description::ITypeInfo> CreateTypeInfoFromType(WfLexicalScope* scope, Ptr<WfType> type, bool checkTypeForValue)
{
return CreateTypeInfoFromTypeVisitor::Execute(scope, type.Obj());
return CreateTypeInfoFromTypeVisitor::Execute(scope, type.Obj(), checkTypeForValue);
}

/***********************************************************************
Expand Down Expand Up @@ -17086,6 +17108,7 @@ namespace vl
{
namespace cppcodegen
{
using namespace analyzer;
using namespace collections;

#define ASSIGN_INDEX_KEY(INDEX_DECL, INDEX_KEY, STRING_KEY) \
Expand Down Expand Up @@ -17262,7 +17285,24 @@ WfCppConfig::Collect
for (vint j = 0; j < pop.components.Count(); j++)
{
auto& component = pop.components[j];
CHECK_ERROR(component.nodeCount == 1, L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found.");

// check error
if (component.nodeCount > 1)
{
List<ITypeDescriptor*> tds;
for (vint k = 0; k < component.nodeCount; k++)
{
auto& node = pop.nodes[component.firstNode[k]];
auto indexKey = classLevelDep.subClass[items[node.firstSubClassItem[0]]];
tds.Add(globalDep.allTds.Values()[indexKey]);
}

Sort<ITypeDescriptor*>(&tds[0], tds.Count(), [](ITypeDescriptor* a, ITypeDescriptor* b)
{
return WString::Compare(a->GetTypeName(), b->GetTypeName());
});
manager->errors.Add(WfErrors::CppUnableToDecideClassOrder(tdDecls[tds[0]].Cast<WfClassDeclaration>().Obj(), tds));
}

auto& node = pop.nodes[component.firstNode[0]];
auto subDeclIndexKey = classLevelDep.subClass[items[node.firstSubClassItem[0]]];
Expand All @@ -17271,7 +17311,7 @@ WfCppConfig::Collect
}
}

if (!parent)
if (!parent && manager->errors.Count() == 0)
{
for (vint i = 0; i < classLevelDep.subClass.Count(); i++)
{
Expand Down Expand Up @@ -17334,7 +17374,32 @@ WfCppConfig::Collect
for (vint i = 0; i < popSubClass.components.Count(); i++)
{
auto& component = popSubClass.components[i];
CHECK_ERROR(component.nodeCount == 1, L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found.");

// check error
if (component.nodeCount > 1)
{
List<ITypeDescriptor*> tds;
for (vint j = 0; j < component.nodeCount; j++)
{
auto& node = popSubClass.nodes[component.firstNode[j]];
for (vint k = 0; k < node.subClassItemCount; k++)
{
auto indexKey = globalDep.topLevelClasses[node.firstSubClassItem[k]];
tds.Add(globalDep.allTds.Values()[indexKey]);
}
}

Sort<ITypeDescriptor*>(&tds[0], tds.Count(), [](ITypeDescriptor* a, ITypeDescriptor* b)
{
return WString::Compare(a->GetTypeName(), b->GetTypeName());
});
manager->errors.Add(WfErrors::CppUnableToSeparateCustomFile(tdDecls[tds[0]].Cast<WfClassDeclaration>().Obj(), tds));
}
}

if (manager->errors.Count() != 0)
{
return;
}

// generate two item list, one have all @cpp:File classes put in front, one have all non-@cpp:File classes put in front
Expand Down Expand Up @@ -17417,9 +17482,9 @@ WfCppConfig::Collect
popNonCustomFirst.InitWithGroup(nonCustomFirstItems, subClassDepGroup);
popNonCustomFirst.Sort();

CHECK_ERROR(popCustomFirst.components.Count() == customFirstItems.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found.");
CHECK_ERROR(popNonCustomFirst.components.Count() == nonCustomFirstItems.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found.");
CHECK_ERROR(popCustomFirst.components.Count() == popNonCustomFirst.components.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found.");
CHECK_ERROR(popCustomFirst.components.Count() == customFirstItems.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Internal error: Unexpected circle dependency found, this should have been caught by code above.");
CHECK_ERROR(popNonCustomFirst.components.Count() == nonCustomFirstItems.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found, this should have been caught by code above.");
CHECK_ERROR(popCustomFirst.components.Count() == popNonCustomFirst.components.Count(), L"WfCppConfig::AssignClassDeclsToFiles()#Future error: Unexpected circle dependency found, this should have been caught by code above.");

// translate popCustomFirst's sorting result
// popSubClass.nodes's index
Expand Down Expand Up @@ -17951,7 +18016,7 @@ WfGenerateClassMemberImplVisitor
vint callIndex = 0;
FOREACH(Ptr<WfBaseConstructorCall>, call, node->baseConstructorCalls)
{
auto callType = CreateTypeInfoFromType(scope, call->type);
auto callType = CreateTypeInfoFromType(scope, call->type, false);
auto callCtor = config->manager->baseConstructorCallResolvings[{node, callType->GetTypeDescriptor()}].value;

writer.WriteString(prefix);
Expand Down Expand Up @@ -21135,6 +21200,10 @@ GenerateCppFiles
Ptr<WfCppOutput> GenerateCppFiles(Ptr<WfCppInput> input, analyzer::WfLexicalScopeManager* manager)
{
WfCppConfig config(manager, input->assemblyName, input->assemblyNamespace);
if (manager->errors.Count() > 0)
{
return nullptr;
}

auto output = MakePtr<WfCppOutput>();
if (config.manager->declarationTypes.Count() > 0)
Expand Down Expand Up @@ -21406,6 +21475,40 @@ MergeCppFile
});
}

MergeCppMultiPlatformException::MergeCppMultiPlatformException(vint _row32, vint _column32, vint _row64, vint _column64)
:Exception(L"The difference at "
L"x86 file(row:" + itow(_row32 + 1) + L", column:" + itow(_column32 + 1) + L") and "
L"x64 file(row:" + itow(_row64 + 1) + L", column:" + itow(_column64 + 1) + L") are not "
L"\"vint32_t\" and \"vint64_t\", "
L"\"vuint32_t\" and \"vuint64_t\", "
L"\"<number>\" and \"<number>L\", "
L"\"<number>\" and \"<number>UL\".")
, row32(_row32)
, column32(_column32)
, row64(_row64)
, column64(_column64)
{
}

void CountRowAndColumn(const wchar_t* start, const wchar_t* reading, vint& row, vint& column)
{
row = 0;
column = 0;
while (start < reading)
{
if (*start++ == L'\n')
{
row++;
column = 0;
}
else
{
column++;
}
}
}


WString MergeCppMultiPlatform(const WString& code32, const WString& code64)
{
static wchar_t stringCast32[] = L"static_cast<::vl::vint32_t>(";
Expand All @@ -21419,6 +21522,7 @@ MergeCppFile
const wchar_t* reading32 = code32.Buffer();
const wchar_t* reading64 = code64.Buffer();
const wchar_t* start32 = reading32;
const wchar_t* start64 = reading64;
while (true)
{
vint length = 0;
Expand Down Expand Up @@ -21456,6 +21560,15 @@ MergeCppFile
goto NEXT_ROUND;
}
}
if (length >= 5)
{
if (wcsncmp(reading32 - 5, L"vuint32_t", 9) == 0 && wcsncmp(reading64 - 5, L"vuint64_t", 9) == 0)
{
reading32 += 4;
reading64 += 4;
goto NEXT_ROUND;
}
}
}
else if (reading64[0] == L'L')
{
Expand Down Expand Up @@ -21515,13 +21628,17 @@ MergeCppFile
goto NEXT_ROUND;
}
}
throw Exception(L"The difference at " + itow((vint)(reading32 - start32)) + L"-th character between Input C++ source files are not "
L"\"vint32_t\" and \"vint64_t\", "
L"\"<number>\" and \"<number>L\", "
L"\"<number>\" and \"<number>UL\"."
);
NEXT_ROUND:;

{
vint row32 = 0;
vint column32 = 0;
vint row64 = 0;
vint column64 = 0;
CountRowAndColumn(start32, reading32, row32, column32);
CountRowAndColumn(start64, reading64, row64, column64);
throw MergeCppMultiPlatformException(row32, column32, row64, column64);
}
NEXT_ROUND:;
#undef IS_DIGIT
}
});
Expand Down Expand Up @@ -25720,7 +25837,7 @@ GenerateInstructions(Expression)
void Visit(WfTypeOfTypeExpression* node)override
{
auto scope = context.manager->nodeScopes[node].Obj();
auto type = CreateTypeInfoFromType(scope, node->type);
auto type = CreateTypeInfoFromType(scope, node->type, false);
auto value = Value::From(type->GetTypeDescriptor());
INSTRUCTION(Ins::LoadValue(value));
}
Expand Down
17 changes: 16 additions & 1 deletion Import/VlppWorkflowCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4032,7 +4032,7 @@ Type Analyzing
extern Ptr<WfExpression> GetExpressionFromTypeDescriptor(reflection::description::ITypeDescriptor* typeDescriptor);
extern Ptr<WfType> GetTypeFromTypeInfo(reflection::description::ITypeInfo* typeInfo);
extern Ptr<WfLexicalScopeName> GetScopeNameFromReferenceType(WfLexicalScope* scope, Ptr<WfType> type);
extern Ptr<reflection::description::ITypeInfo> CreateTypeInfoFromType(WfLexicalScope* scope, Ptr<WfType> type);
extern Ptr<reflection::description::ITypeInfo> CreateTypeInfoFromType(WfLexicalScope* scope, Ptr<WfType> type, bool checkTypeForValue = true);

extern Ptr<reflection::description::ITypeInfo> CopyTypeInfo(reflection::description::ITypeInfo* typeInfo);
extern bool CanConvertToType(reflection::description::ITypeInfo* fromType, reflection::description::ITypeInfo* toType, bool explicitly);
Expand Down Expand Up @@ -4349,6 +4349,10 @@ Error Messages
static Ptr<parsing::ParsingError> TooManyDestructor(WfDestructorDeclaration* node, WfClassDeclaration* classDecl);
static Ptr<parsing::ParsingError> AutoPropertyShouldBeInitialized(WfAutoPropertyDeclaration* node);
static Ptr<parsing::ParsingError> AutoPropertyCannotBeInitializedInInterface(WfAutoPropertyDeclaration* node, WfClassDeclaration* classDecl);

// CPP: C++ code generation error
static Ptr<parsing::ParsingError> CppUnableToDecideClassOrder(WfClassDeclaration* node, collections::List<reflection::description::ITypeDescriptor*>& tds);
static Ptr<parsing::ParsingError> CppUnableToSeparateCustomFile(WfClassDeclaration* node, collections::List<reflection::description::ITypeDescriptor*>& tds);
};
}
}
Expand Down Expand Up @@ -4800,6 +4804,17 @@ GenerateCppFiles
WString entryFileName;
};

class MergeCppMultiPlatformException : public Exception
{
public:
vint row32;
vint column32;
vint row64;
vint column64;

MergeCppMultiPlatformException(vint _row32, vint _column32, vint _row64, vint _column64);
};

extern Ptr<WfCppOutput> GenerateCppFiles(Ptr<WfCppInput> input, analyzer::WfLexicalScopeManager* manager);
extern WString MergeCppMultiPlatform(const WString& code32, const WString& code64);
extern WString MergeCppFileContent(const WString& dst, const WString& src);
Expand Down
Loading

0 comments on commit 8e276b2

Please sign in to comment.