Updated Toy, fixed a leak
This commit is contained in:
+1
-1
Submodule Toy updated: 3b813da1cf...53d3606c7e
+6
-4
@@ -72,7 +72,7 @@ static void api_loadSprite(Toy_VM* vm) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//insert into the table as an opaque
|
//insert into the table as an opaque
|
||||||
Toy_insertTable(&spriteTable, Toy_copyValue(&vm->memoryBucket, key), TOY_OPAQUE_FROM_POINTER(sprite));
|
Toy_insertTable(&spriteTable, key, TOY_OPAQUE_FROM_POINTER(sprite));
|
||||||
|
|
||||||
Toy_freeValue(key);
|
Toy_freeValue(key);
|
||||||
Toy_freeValue(file);
|
Toy_freeValue(file);
|
||||||
@@ -204,7 +204,7 @@ void initActorAPI(Toy_VM* vm) {
|
|||||||
|
|
||||||
//declare each callback in the global scope
|
//declare each callback in the global scope
|
||||||
for (int i = 0; callbackPairs[i].name; i++) {
|
for (int i = 0; callbackPairs[i].name; i++) {
|
||||||
Toy_String* key = Toy_toString(&(vm->memoryBucket), callbackPairs[i].name);
|
Toy_String* key = Toy_createStringLength(&(vm->memoryBucket), callbackPairs[i].name, strlen(callbackPairs[i].name));
|
||||||
Toy_Function* fn = Toy_createFunctionFromCallback(&(vm->memoryBucket), callbackPairs[i].callback);
|
Toy_Function* fn = Toy_createFunctionFromCallback(&(vm->memoryBucket), callbackPairs[i].callback);
|
||||||
|
|
||||||
Toy_declareScope(vm->scope, key, TOY_VALUE_FUNCTION, TOY_VALUE_FROM_FUNCTION(fn), true);
|
Toy_declareScope(vm->scope, key, TOY_VALUE_FUNCTION, TOY_VALUE_FROM_FUNCTION(fn), true);
|
||||||
@@ -260,7 +260,7 @@ void processActorStep(Toy_VM* vm) {
|
|||||||
|
|
||||||
//c-string of the param's name && as a name string
|
//c-string of the param's name && as a name string
|
||||||
const char* cstr = ((char*)(subVM.code + subVM.dataAddr)) + paramAddr;
|
const char* cstr = ((char*)(subVM.code + subVM.dataAddr)) + paramAddr;
|
||||||
Toy_String* name = Toy_toStringLength(&subVM.memoryBucket, cstr, strlen(cstr));
|
Toy_String* name = Toy_toStringLength(&subVM.memoryBucket, cstr, strlen(cstr)); //don't use 'create'
|
||||||
|
|
||||||
int ticker = 0;
|
int ticker = 0;
|
||||||
|
|
||||||
@@ -280,6 +280,8 @@ void processActorStep(Toy_VM* vm) {
|
|||||||
|
|
||||||
Toy_freeVM(&subVM);
|
Toy_freeVM(&subVM);
|
||||||
|
|
||||||
|
Toy_freeString(name);
|
||||||
|
|
||||||
//DEBUG: "wipe" the actors if there's too many, so memory doesn't keep growing.
|
//DEBUG: "wipe" the actors if there's too many, so memory doesn't keep growing.
|
||||||
if (ticker >= 100) {
|
if (ticker >= 100) {
|
||||||
for (unsigned int i = 0; i < actorArray->count; i++) {
|
for (unsigned int i = 0; i < actorArray->count; i++) {
|
||||||
@@ -337,7 +339,7 @@ void loadSprite(Toy_Bucket** bucketHandle, Toy_Value key, const char* fname, int
|
|||||||
sprite->texture = LoadTexture(fname);
|
sprite->texture = LoadTexture(fname);
|
||||||
|
|
||||||
//insert into the table as an opaque
|
//insert into the table as an opaque
|
||||||
Toy_insertTable(&spriteTable, Toy_copyValue(bucketHandle, key), TOY_OPAQUE_FROM_POINTER(sprite));
|
Toy_insertTable(&spriteTable, key, TOY_OPAQUE_FROM_POINTER(sprite));
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorData* spawnActorAt(Toy_Bucket** bucketHandle, Toy_Value key, int xpos, int ypos) {
|
ActorData* spawnActorAt(Toy_Bucket** bucketHandle, Toy_Value key, int xpos, int ypos) {
|
||||||
|
|||||||
+2
-2
@@ -85,7 +85,7 @@ void initScreen(Toy_VM* vm) {
|
|||||||
|
|
||||||
//setup raylib
|
//setup raylib
|
||||||
InitWindow(TOY_VALUE_AS_INTEGER(width), TOY_VALUE_AS_INTEGER(height), TOY_VALUE_AS_STRING(caption)->leaf.data);
|
InitWindow(TOY_VALUE_AS_INTEGER(width), TOY_VALUE_AS_INTEGER(height), TOY_VALUE_AS_STRING(caption)->leaf.data);
|
||||||
SetTargetFPS(60);
|
// SetTargetFPS(60);
|
||||||
|
|
||||||
if (!IsWindowReady()) {
|
if (!IsWindowReady()) {
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: raylib failed to init the window, exiting" TOY_CC_RESET "\n");
|
fprintf(stderr, TOY_CC_ERROR "ERROR: raylib failed to init the window, exiting" TOY_CC_RESET "\n");
|
||||||
@@ -160,7 +160,7 @@ void initGameAPI(Toy_VM* vm) {
|
|||||||
|
|
||||||
//declare each function in the global scope
|
//declare each function in the global scope
|
||||||
for (int i = 0; callbackPairs[i].name; i++) {
|
for (int i = 0; callbackPairs[i].name; i++) {
|
||||||
Toy_String* key = Toy_toString(&(vm->memoryBucket), callbackPairs[i].name);
|
Toy_String* key = Toy_createStringLength(&(vm->memoryBucket), callbackPairs[i].name, strlen(callbackPairs[i].name));
|
||||||
Toy_Function* fn = Toy_createFunctionFromCallback(&(vm->memoryBucket), callbackPairs[i].callback);
|
Toy_Function* fn = Toy_createFunctionFromCallback(&(vm->memoryBucket), callbackPairs[i].callback);
|
||||||
Toy_declareScope(vm->scope, key, TOY_VALUE_FUNCTION, TOY_VALUE_FROM_FUNCTION(fn), true);
|
Toy_declareScope(vm->scope, key, TOY_VALUE_FUNCTION, TOY_VALUE_FROM_FUNCTION(fn), true);
|
||||||
Toy_freeString(key);
|
Toy_freeString(key);
|
||||||
|
|||||||
Reference in New Issue
Block a user