Open source Star Ruler 2 source code!

This commit is contained in:
Lucas de Vries
2018-07-17 14:15:37 +02:00
commit cc307720ff
4342 changed files with 2365070 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
#include "as_binding_print.h"
#include "angelscript.h"
#include <fstream>
using std::endl;
//Prints all enums, global variables, global functions, and object declarations in the engine to the specified file
void printBindings(asIScriptEngine* engine, const char* filename) {
//TODO
/*std::ofstream file(filename);
if(!file.is_open() || !file.good())
return;
file << "Enums:" << endl << "======" << endl << endl;
for(asUINT i = 0, cnt = engine->GetEnumCount(); i < cnt; ++i) {
int id;
file << engine->GetEnumByIndex(i, &id) << " {" << endl;
int prevV = -1;
bool showNums = false;
for(asUINT v = 0, vCnt = engine->GetEnumValueCount(id); v < vCnt; ++v) {
int value;
file << "\t" << engine->GetEnumValueByIndex(id, v, &value);
//Show it like a traditional enum if it starts at 0. If it ever breaks from that, begin to always show the numbers
if(!showNums && value == prevV + 1) {
file << "," << endl;
prevV = value;
}
else {
showNums = true;
file << " = " << value << endl;
}
}
file << "}" << endl << endl;
}
file << "Globals:" << endl << "========" << endl << endl;
for(asUINT i = 0, cnt = engine->GetGlobalPropertyCount(); i < cnt; ++i) {
const char* name;
int typeID;
bool isConst;
int id = engine->GetGlobalPropertyByIndex(i, &name, 0, &typeID, &isConst);
file << "\t";
if(isConst)
file << "const ";
file << engine->GetTypeDeclaration(typeID) << " " << name << endl;
}
file << endl << "Global Functions:" << endl << "=================" << endl << endl;
for(asUINT i = 0, cnt = engine->GetGlobalFunctionCount(); i < cnt; ++i) {
asIScriptFunction* func = engine->GetGlobalFunctionByIndex(i);
file << func->GetDeclaration() << endl;
}
file << endl << "Classes:" << endl << "========" << endl << endl;
for(asUINT i = 0, cnt = engine->GetObjectTypeCount(); i < cnt; ++i) {
asITypeInfo* obj = engine->GetObjectTypeByIndex(i);
file << obj->GetName();
if(asITypeInfo* base = obj->GetBaseType())
file << " : " << base->GetName();
file << " {" << endl;
for(asUINT p = 0, pCnt = obj->GetPropertyCount(); p < pCnt; ++p) {
const char* name;
bool isRef;
int typeID;
obj->GetProperty(p, &name, &typeID, 0, 0, &isRef);
file << "\t" << engine->GetTypeDeclaration(typeID);
if(isRef)
file << "@ ";
else
file << " ";
file << name << endl;
}
if(obj->GetPropertyCount() != 0 && obj->GetMethodCount() != 0)
file << endl;
for(asUINT m = 0, mCnt = obj->GetMethodCount(); m < mCnt; ++m) {
asIScriptFunction* func = obj->GetMethodByIndex(m);
file << "\t" << func->GetDeclaration(false) << endl;
}
file << "}" << endl << endl;
}*/
}
+3
View File
@@ -0,0 +1,3 @@
class asIScriptEngine;
void printBindings(asIScriptEngine* engine, const char* filename);
File diff suppressed because it is too large Load Diff
+53
View File
@@ -0,0 +1,53 @@
#pragma once
#include "angelscript.h"
#include <vector>
#include <map>
namespace assembler {
struct CodePage;
struct CriticalSection;
};
enum JITSettings {
//Should the JIT attempt to suspend? (Slightly faster, but makes suspension very rare if it occurs at all)
JIT_NO_SUSPEND = 0x01,
//Should the JIT reset the FPU entering System calls? (Slightly faster, may not work on all platforms)
JIT_SYSCALL_FPU_NORESET = 0x02,
//Should the JIT support error events from System calls? (Faster, but exceptions will generally be ignored, possibly leading to crashes)
JIT_SYSCALL_NO_ERRORS = 0x04,
//Do allocation/deallocation functions inspect the script context? (Faster, but won't work correctly if you try to get information about the script system during allocations)
JIT_ALLOC_SIMPLE = 0x08,
//Fall back to AngelScript to perform switch logic? (Slower, but uses less memory)
JIT_NO_SWITCHES = 0x10,
//Fall back to AngelScript to perform script calls
// Slower, but can be used as a temporary workaround for angelscript changes
JIT_NO_SCRIPT_CALLS = 0x20,
//Make calling reference counting functions faster in common situations
// Reference counting functions which access the script context will produce undefined results
JIT_FAST_REFCOUNT = 0x40,
};
class asCJITCompiler : public asIJITCompiler {
assembler::CodePage* activePage;
std::multimap<asJITFunction,assembler::CodePage*> pages;
assembler::CriticalSection* lock;
unsigned flags;
std::multimap<asJITFunction,unsigned char**> jumpTables;
unsigned char** activeJumpTable;
unsigned currentTableSize;
struct DeferredCodePointer {
void** jitFunction;
void** jitEntry;
};
std::multimap<asIScriptFunction*,DeferredCodePointer> deferredPointers;
public:
asCJITCompiler(unsigned Flags = 0);
~asCJITCompiler();
int CompileFunction(asIScriptFunction *function, asJITFunction *output);
void ReleaseJITFunction(asJITFunction func);
void finalizePages();
};