-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35afc58
commit 1e16b7f
Showing
21 changed files
with
915 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
{ | ||
"recommendations": [ | ||
"shd101wyy.markdown-preview-enhanced", | ||
"christian-kohler.path-intellisense", | ||
"esbenp.prettier-vscode", | ||
"michelemelluso.gitignore", | ||
"ms-python.vscode-pylance", | ||
"ms-vscode.cpptools", | ||
"ms-dotnettools.csdevkit" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"C_Cpp.errorSquiggles": "disabled", | ||
"files.associations": { | ||
"*.mut": "cpp", | ||
"*.asc": "cpp", | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int vroom() { | ||
return 2; | ||
} | ||
|
||
void main() { | ||
int sum1 = Add(1, 2); | ||
double sum2 = Add(1.5, 2.5); | ||
int sum3 = Add(1, 2, 3); | ||
|
||
auto a = Add(2, 3); | ||
|
||
Print("Sum1: " + sum1 + ", Sum2: " + sum2 + ", Sum3: " + sum3); | ||
Print(""+vroom()); | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import json | ||
|
||
OUTPUT = """// This file was automatically generated. Do not modify. | ||
#include "funcs.h" | ||
// Typedefs | ||
typedef uint8_t byte; | ||
typedef int8_t int8; | ||
typedef uint8_t uint8; | ||
typedef int16_t int16; | ||
typedef uint16_t uint16; | ||
typedef int32_t int; | ||
typedef uint32_t uint; | ||
typedef float float32; | ||
typedef int64_t int64; | ||
typedef uint64_t uint64; | ||
typedef double double64; | ||
%DEFINE_FUNCTIONS% | ||
void RegisterFunctions(asIScriptEngine* engine) { | ||
%REGISTER_FUNCTIONS% | ||
} | ||
""" | ||
|
||
f = open("global.json").read() | ||
f = json.loads(f) | ||
|
||
define_functions = "" | ||
register_functions = "" | ||
|
||
# actual codegen goes here | ||
|
||
funcs = f["globalfunctionsList"] | ||
for x in funcs: | ||
returns = "0" | ||
return_type = x["full"].split(x["name"])[0].strip() | ||
if return_type == "bool": | ||
returns = "true" | ||
elif return_type == "void": | ||
returns = "" | ||
elif return_type == "float": | ||
returns = "0.0" | ||
elif return_type == "string": | ||
returns = "\"\"" | ||
elif return_type != "int" and return_type != "uint16" and return_type != "uint64" and return_type != "uint": | ||
print(f"IDK what this is {return_type}") | ||
|
||
define_functions += x["full"] + " {\n" | ||
define_functions += f"\treturn {returns};\n" | ||
define_functions += "}\n\n" | ||
|
||
# engine->RegisterGlobalFunction("int Add(int, int)", asFUNCTION(Add), asCALL_CDECL); | ||
|
||
register_functions += f"\tengine->RegisterGlobalFunction(\"{x['full']}\", asFUNCTION({x['name']}), asCALL_CDECL);\n" | ||
# codegen end | ||
|
||
OUTPUT = OUTPUT.replace("%DEFINE_FUNCTIONS%", define_functions).replace( | ||
"%REGISTER_FUNCTIONS%", register_functions | ||
) | ||
open("output.cpp", "w").write(OUTPUT) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.