Adds little hack for GetOwner.

This commit is contained in:
Deukhoofd 2021-10-30 11:49:52 +02:00
parent f9c8efb9b1
commit 31414d6521
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 15 additions and 14 deletions

View File

@ -18,10 +18,9 @@ static void PrintObjectTypeDef(asITypeInfo* type, const std::filesystem::path& d
std::fstream fs;
fs.open((dir / name).concat(".astypedef"), std::fstream::out);
if ((type->GetFlags() & asOBJ_VALUE) != 0 && (type->GetFlags() & asOBJ_ASHANDLE) == 0){
if ((type->GetFlags() & asOBJ_VALUE) != 0 && (type->GetFlags() & asOBJ_ASHANDLE) == 0) {
fs << "valuetype";
}
else{
} else {
fs << "type";
}
@ -117,24 +116,27 @@ static void PrintScriptObject(asITypeInfo* type, const std::filesystem::path& di
auto name = std::string(method->GetName());
if (name == "opAssign")
continue;
if (name == "GetOwner") {
fs << "\tref@ __owner;" << std::endl << std::endl;
}
auto decl = std::string(method->GetDeclaration(false, true, true));
replace(decl, "&in", " &in");
replace(decl, "&out", " &out");
replace(decl, "ref", "ref@");
fs << "\t" << decl;
if (isAbstract){
if (method->GetReturnTypeId() == 0){
if (isAbstract) {
if (method->GetReturnTypeId() == 0) {
fs << "{};" << std::endl;
}
else{
if (method->GetReturnTypeId() == asTYPEID_BOOL){
} else {
if (name == "GetOwner") {
fs << "{ return __owner; };" << std::endl;
} else if (method->GetReturnTypeId() == asTYPEID_BOOL) {
fs << "{ return false; };" << std::endl;
}
else{
} else {
fs << "{ return 0; };" << std::endl;
}
}
}
else
} else
fs << ";" << std::endl;
}
}
@ -187,7 +189,7 @@ void ScriptHeadersExporter::Export(const std::string& outPath) {
}
auto globalFuncs = engine->GetGlobalFunctionCount();
if (globalFuncs > 0){
if (globalFuncs > 0) {
std::fstream fs;
fs.open((dir / "globals").concat(".astypedef"), std::fstream::out);
@ -196,5 +198,4 @@ void ScriptHeadersExporter::Export(const std::string& outPath) {
fs << "func " << func->GetDeclaration(false, false, true) << ";" << std::endl;
}
}
}