Commit Graph

45 Commits

Author SHA1 Message Date
bjorn 963f496ac1 Lua hides a Type in its userdata; 2019-05-13 03:21:11 -07:00
bjorn c247682653 BRING BACK HEXCODES; 2019-04-20 13:36:36 -07:00
bjorn f268810d2a Minor cleanup; Fix some undefined behavior; 2019-04-20 13:11:11 -07:00
bjorn 941fc1717f headset: forward declarations; 2019-04-05 05:08:03 -07:00
bjorn ae470d8804 Make registertype/extend type a macro;
Just a nice-to-have.
2019-04-05 03:48:36 -07:00
bjorn 6fdeda9e61 Make lovrRelease non-generic;
We know what type we're releasing 99% of the time, we don't need to
play a guessing game in lovrRelease, just have the caller say which
destructor to use.

There is lovrGenericRelease for situations where we need it, which
does the slower lookup of the destructor.
2019-04-05 03:41:03 -07:00
bjorn 7932ef6f9f Add type lookup;
Now Ref has a type id instead of a destructor/name, and use the type to
lookup the destructor and name when needed.

This improves performance, since now Ref contains a lot less data and we
can do an integer comparison instead of a string comparison when reading
objects from Lua.
2019-04-05 02:54:54 -07:00
bjorn 85c51399a6 Fix MSVC warnings; 2019-03-17 00:58:13 -07:00
bjorn 1d7e8519d6 Organize luax_setmainthread; 2019-03-14 13:36:51 -07:00
bjorn 569c9f7a11 Refactor asynchronous headset render errors;
It's now a more general error stored in the registry instead of
in a global variable.  There are more helper functions.
2019-03-06 23:17:29 -08:00
bjorn d340fc7aaa Polyfill LUA_RIDX_MAINTHREAD;
Instead of using a static variable.
2019-03-06 08:42:32 -08:00
bjorn bf89216997 Explicitly convert lua_Numbers to floats; 2019-01-29 22:04:04 -08:00
bjorn bf19fd5c15 Avoid more implicit float-double conversions; 2019-01-24 17:00:41 -08:00
bjorn 90cacd03ca Handle numbers more consistently in Lua API;
I still don't know if I should cast or not, but at least now things
will be consistently right or wrong.
2019-01-11 22:37:54 -08:00
bjorn 1fb2d6be02 Always use pushliteral when possible; 2018-12-15 21:45:32 -08:00
bjorn 0b78e238b3 luax_traceback;
Simplifies traceback code by adding a polyfill for Lua 5.2's
luaL_traceback function that can be used by the panic helper and
luax_getstack.
2018-11-15 07:51:21 -08:00
bjorn c6126bed59 Move print_override to luax;
It makes more sense for it to live there since it's a Lua override.
I misunderstood something when communicating about this initially.
2018-11-15 07:51:21 -08:00
bjorn 784d61ef4a Modify module loading;
Dynamically loading things was cool but is causing more pain than
pleasure because it just barely doesn't work everywhere.  Instead,
find a better way to load modules.  Use a data driven luaL_Reg array
to define the module mapping and luaL_register to smoosh it into
package.preload at boot time.  Benefits:

- LOVR_ENABLE_<x> defines are respected and only require a single #if
- Module list is data driven and defined in one place
- It's faster (luax_preloadmodule did a global lookup every invocation)
- It works everywhere

Oh also threads were totally broken and this (mostly) fixes them.
2018-11-15 07:51:21 -08:00
mcc 96eed2786c Amend oculus_mobile error handling so headset.c renderHelper drives
Back out lovrHeadsetExtractRenderFn, don't let oculus_mobile.c pcall the render function, instead fit the render error saving inside renderHelper (emscripten/oculusmobile path). The render error is now saved in the environment at _lovrHeadsetRenderError. For this to work, luax now keeps track of a global variable for the current "main" environment.

This does means the render error path now works on emscripten (this has not been tested).
2018-11-13 16:50:31 -08:00
mcc 684fd77316 Various changes around error reporting to support Oculus Mobile
General changes:

- Amended the boot.lua error handling so when an error occurs in the error handler, the inner error is printed before quitting
- Silent quit instead of crash if a user implements lovr.errhand but it doesn't return a function

Oculus Mobile changes:

- The lovr.errhand screen is now correctly invoked for errors that occur inside lovr.draw. Multiple changes were needed to make this work:
    - Instead of calling renderHelper, which uses lua_call (unsafe as Oculus Mobile does not call renderHelper) the oculus driver gets hold of the Lua ref and lua_pcalls itself. A new lovrHeadsetExtractRenderFn is added to make this possible.
    - A mechanism is added where if the coroutine resume in boot.lua returns a value, boot.lua treats this as the string returned from luax_getstack and invokes lovr.errhand.
- Added a custom atpanic that routes through lovrThrow (since stderr gets eaten). With the draw() changes this should never be encountered, but it's good just in case. In current testing the tracebacks this prints don't seem to be right.
- Fix major bug in android_vthrow that meant % codes didn't work in lovrThrow on Android
- Nothing to do with errors, but fix getAxis("trigger")
2018-11-13 16:50:31 -08:00
bjorn 816fda2177 Fix everything and merge; 2018-09-27 18:38:44 -07:00
bjorn cee3c28f4e luax_atexit; rm lovrDestroy;
Modules register themselves in the registry for destruction at
lua_close instead of having a hardcoded list in lovrDestroy.
2018-09-27 18:38:44 -07:00
bjorn 92e6ad93cb Dynamically load modules; 2018-09-27 18:38:44 -07:00
bjorn 148a2bdb45 Error system no longer relies on Lua; 2018-09-26 10:39:17 -07:00
bjorn f872a5f094 Re-enable threads for emscripten;
They don't appear to work very well but this simplifies code a lot.
2018-08-30 22:09:54 -07:00
bjorn d6daa885c8 Simplify luax_checktype and inheritance; 2018-07-24 21:15:07 -07:00
bjorn 83ddb82162 Simplify Lua object management; 2018-07-24 20:13:54 -07:00
bjorn 0214c7605e Support requiring dll/so files;
Still WIP
2018-07-07 13:55:22 -07:00
bjorn f903b6014c Use arrays for enums instead of maps; 2018-07-04 20:11:52 -07:00
bjorn 781a5a7688 Rename luax_stubnil to luax_emptymodule; 2018-05-27 19:05:10 -07:00
bjorn 012ba07063 Disable threads in WebVR;
Browser/emscripten support is currently unstable.
2018-05-27 19:05:10 -07:00
bjorn 583afc9f16 Reorganize main/lovr separation; 2018-02-23 18:38:34 -08:00
bjorn 66d0e42908 Refactor VertexFormat; 2018-01-26 19:11:40 -08:00
bjorn dc801d8590 luax_pushvertex; 2018-01-26 19:01:41 -08:00
bjorn f0cac8fa69 Add luax_totype; 2018-01-22 08:08:26 -08:00
bjorn 8bda7a9ed8 Minor cleanup of previous change; 2017-11-22 20:13:36 -08:00
bjorn ad779820a7 Refactor lovr.conf to be exposed to C;
This simplifies boot.lua and means we don't need private functions
all over the place for the stuff configured by conf.lua.
2017-11-22 20:11:51 -08:00
bjorn 602e0ced7d Floating point colors;
This is a breaking change.
2017-11-20 21:47:36 -08:00
bjorn b8fededcf6 Add luax_checkcolor; 2017-10-21 13:21:30 -07:00
bjorn e79c45ffdf BoxShape; 2017-05-16 15:52:09 -06:00
bjorn 4ac72a54d6 luax_extendtype; luax_checktypeof; 2017-05-16 11:38:49 -06:00
bjorn 2cc360db11 Fix stack adjustment in pushtype; 2017-02-26 14:49:42 -08:00
bjorn 706481f9ee Fix issue with registry creation; 2017-02-18 15:18:17 -08:00
bjorn cce3445f9b Fix memory management; 2017-02-18 14:44:52 -08:00
bjorn 4303846eac Clean up includes; 2017-01-21 18:00:32 -08:00