Allow strings to be returned from structs
This commit is contained in:
@@ -99,10 +99,11 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
|||||||
${SDL2_INCLUDE_DIRS}
|
${SDL2_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Force turn tests off for now
|
|
||||||
set(ENABLE_TESTS OFF CACHE BOOL "Enable tests" FORCE)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Force turn tests off for now
|
||||||
|
set(ENABLE_TESTS OFF CACHE BOOL "Enable tests" FORCE)
|
||||||
|
|
||||||
# Add code
|
# Add code
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ following packages, depending on your system;
|
|||||||
|
|
||||||
Fedora;
|
Fedora;
|
||||||
```
|
```
|
||||||
sudo dnf install git make gcc cmake python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl
|
sudo dnf install git make gcc cmake python python-polib python3-pillow python3-dotenv python3-numpy python-qt5 python3-pyopengl SDL2-devel zlib-devel libzip-devel bzip2-devel openssl-devel lzma-sdk-devel xz xz-devel lua-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
Ubuntu;
|
Ubuntu;
|
||||||
|
|||||||
@@ -5,11 +5,6 @@ module('glm')
|
|||||||
|
|
||||||
camera = cameraCreate(CAMERA_PROJECTION_TYPE_PERSPECTIVE)
|
camera = cameraCreate(CAMERA_PROJECTION_TYPE_PERSPECTIVE)
|
||||||
|
|
||||||
print('Camera position')
|
|
||||||
print(camera.position.x)
|
|
||||||
print(camera.position.y)
|
|
||||||
print(camera.position.z)
|
|
||||||
|
|
||||||
function sceneDispose()
|
function sceneDispose()
|
||||||
-- print('Disposing initial scene')
|
-- print('Disposing initial scene')
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
#include "script/struct/scriptstruct.h"
|
#include "script/struct/scriptstruct.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
|
||||||
void moduleGLM(scriptcontext_t *context) {
|
void moduleGLM(scriptcontext_t *context) {
|
||||||
assertNotNull(context, "Context cannot be NULL.");
|
assertNotNull(context, "Context cannot be NULL.");
|
||||||
@@ -32,6 +33,8 @@ void moduleGLMVec3Getter(
|
|||||||
assertNotNull(structPtr, "Structure pointer cannot be NULL.");
|
assertNotNull(structPtr, "Structure pointer cannot be NULL.");
|
||||||
assertNotNull(outValue, "Output value cannot be NULL.");
|
assertNotNull(outValue, "Output value cannot be NULL.");
|
||||||
|
|
||||||
|
printf("Getting vec3 field %s\n", key);
|
||||||
|
|
||||||
vec3 *v = (vec3 *)structPtr;
|
vec3 *v = (vec3 *)structPtr;
|
||||||
if(stringCompare(key, "x") == 0) {
|
if(stringCompare(key, "x") == 0) {
|
||||||
outValue->type = SCRIPT_VALUE_TYPE_FLOAT;
|
outValue->type = SCRIPT_VALUE_TYPE_FLOAT;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ typedef struct scriptvalue_s {
|
|||||||
union {
|
union {
|
||||||
int32_t intValue;
|
int32_t intValue;
|
||||||
float_t floatValue;
|
float_t floatValue;
|
||||||
const char_t *strValue;
|
char_t *strValue;
|
||||||
bool_t boolValue;
|
bool_t boolValue;
|
||||||
} value;
|
} value;
|
||||||
} scriptvalue_t;
|
} scriptvalue_t;
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "scriptstruct.h"
|
#include "scriptstruct.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
|
||||||
void scriptStructRegister(
|
void scriptStructRegister(
|
||||||
scriptcontext_t *context,
|
scriptcontext_t *context,
|
||||||
@@ -66,7 +67,9 @@ int scriptStructIndex(lua_State *l) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SCRIPT_VALUE_TYPE_STRING:
|
case SCRIPT_VALUE_TYPE_STRING:
|
||||||
|
assertNotNull(outValue.value.strValue, "String value cannot be NULL");
|
||||||
lua_pushstring(l, outValue.value.strValue);
|
lua_pushstring(l, outValue.value.strValue);
|
||||||
|
memoryFree((void *)outValue.value.strValue);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCRIPT_VALUE_TYPE_BOOL:
|
case SCRIPT_VALUE_TYPE_BOOL:
|
||||||
@@ -122,6 +125,7 @@ int scriptStructNewIndex(lua_State *l) {
|
|||||||
inValue.type = SCRIPT_VALUE_TYPE_BOOL;
|
inValue.type = SCRIPT_VALUE_TYPE_BOOL;
|
||||||
inValue.value.boolValue = lua_toboolean(l, 3);
|
inValue.value.boolValue = lua_toboolean(l, 3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LUA_TNIL:
|
case LUA_TNIL:
|
||||||
inValue.type = SCRIPT_VALUE_TYPE_NIL;
|
inValue.type = SCRIPT_VALUE_TYPE_NIL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user