-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QuickJS generator improvements. (#1865)
* Fixes to QuickJS marshaling. * Handle more primitive types in `GetInfo`. * Fix generator kind CLI option matching. * Alias QuickJS generator kind to `quickjs`. * General CLI code cleanups. * Default to x64 platform over x86 for the CLI. * Implement new Lua bindings file and commands for CLI tool. * Fix QuickJS primitive type marshaling to take target sizes into account. * Minor code cleanup. * Avoid generating includes to units when generating the QuickJS module. * Update file generation naming pattern for QuickJS files. * Update QuickJS JS_GetOpaque and JS_GetAnyOpaque references to work with latest upstream. * Update QuickJS runtime and support code to work with latest upstream. * Avoid generating properties when generating QuickJS register code. * Update QuickJS test suite to bootstrap its own QuickJS runtime. * Update QuickJS test suite to use a Lua bindings definition file. * Minor fixes to test header files. * Fix C++ warning about return values for event invokes. * Disable some non working tests for QuickJS. * Enable QuickJS testing on CI. * Fix shell color attributes for test scripts when under CI. * WIP CI fixes. * Fix warnings in QuickJS support runtime code. * Use C99 designated initializers for all QuickJS class def members. * Disable QuickJS CI steps on Windows. * Clean up error handling for `JS_ToBool`. * More QuickJS support code fixes. * Rename Signal.cpp to QuickJS nomenclature. * Fix QuickJS JS_ToBigUint call. * Remove QuickJS test script verbosity. * More CI fixes. * Verbose build. * Extension fix.
- Loading branch information
Showing
32 changed files
with
415 additions
and
200 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
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
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
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
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
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,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using CppSharp; | ||
using MoonSharp.Interpreter; | ||
|
||
class LuaContext | ||
{ | ||
public Script script; | ||
public Options options; | ||
public List<string> errorMessages; | ||
|
||
public string CurrentModule; | ||
|
||
public LuaContext(Options options, List<string> errorMessages) | ||
{ | ||
this.options = options; | ||
this.errorMessages = errorMessages; | ||
|
||
script = new Script(CoreModules.Basic | CoreModules.String | | ||
CoreModules.Table | CoreModules.TableIterators); | ||
|
||
script.Globals["generator"] = (string kind) => | ||
{ | ||
CLI.GetGeneratorKind(kind, errorMessages); | ||
}; | ||
|
||
script.Globals["platform"] = (string platform) => | ||
{ | ||
CLI.GetDestinationPlatform(platform, errorMessages); | ||
}; | ||
|
||
script.Globals["architecture"] = (string arch) => | ||
{ | ||
CLI.GetDestinationArchitecture(arch, errorMessages); | ||
}; | ||
|
||
script.Globals["output"] = script.Globals["location"] = (string dir) => | ||
{ | ||
options.OutputDir = dir; | ||
}; | ||
|
||
script.Globals["includedirs"] = (List<string> dirs) => | ||
{ | ||
foreach (var dir in dirs) | ||
{ | ||
options.IncludeDirs.Add(dir); | ||
} | ||
}; | ||
|
||
script.Globals["module"] = (string name) => | ||
{ | ||
CurrentModule = name; | ||
options.OutputFileName = name; | ||
}; | ||
|
||
script.Globals["namespace"] = (string name) => | ||
{ | ||
options.OutputNamespace = name; | ||
}; | ||
|
||
script.Globals["headers"] = (List<string> files) => | ||
{ | ||
foreach (var file in files) | ||
{ | ||
options.HeaderFiles.Add(file); | ||
} | ||
}; | ||
} | ||
|
||
public DynValue LoadFile(string luaFile) | ||
{ | ||
var code = script.LoadFile(luaFile); | ||
|
||
try | ||
{ | ||
return code.Function.Call(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.Error.WriteLine($"Error running {Path.GetFileName(luaFile)}:\n{ex.Message}"); | ||
return null; | ||
} | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.