fix toml issue / isobject

This commit is contained in:
2026-02-17 01:19:43 -06:00
parent 400c58e5f2
commit 3c28dc2c30
5 changed files with 8 additions and 22 deletions

View File

@@ -3,4 +3,4 @@ cell-steam = "/Users/johnalanbrook/work/cell-steam"
cell-sdl3 = "/Users/johnalanbrook/work/cell-sdl3"
[compilation]
[compilation.playdate]
CFLAGS = "-DMINIZ_NO_TIME -DTARGET_EXTENSION -DTARGET_PLAYDATE -I$LOCAL/PlaydateSDK/C_API"
CFLAGS = "-DMINIZ_NO_TIME -DTARGET_EXTENSION -DTARGET_PLAYDATE -I$LOCAL/PlaydateSDK/C_API"

View File

@@ -248,7 +248,7 @@ is_integer(42) // true
is_logical(true) // true
is_null(null) // true
is_number(3.14) // true
is_object({}) // true
is_object({}) // true (records only)
is_text("hello") // true
```

View File

@@ -512,12 +512,13 @@ var a = nil?(null) ? "yes" : "no" // "yes"
is_number(42) // true
is_text("hi") // true
is_logical(true) // true
is_object({}) // true
is_object({}) // true (records only)
is_array([]) // true
is_function(function(){}) // true
is_null(null) // true
is_object([]) // false (array is not object)
is_array({}) // false (object is not array)
is_object([]) // false (arrays are not records)
is_object("hello") // false (text is not a record)
is_array({}) // false (records are not arrays)
```
### Truthiness

View File

@@ -1,15 +1,11 @@
var package = {}
var fd = use('fd')
var toml = use('toml')
var json = use('json')
var runtime = use('runtime')
var link = use('link')
var global_shop_path = runtime.shop_path
// Cache for loaded configs to avoid toml re-parsing corruption
var config_cache = {}
// Convert package name to a safe directory name
// For absolute paths (local packages), replace / with _
// For remote packages, keep slashes as they use nested directories
@@ -48,10 +44,6 @@ package.load_config = function(name)
{
var config_path = get_path(name) + '/cell.toml'
// Return cached config if available
if (config_cache[config_path])
return config_cache[config_path]
if (!fd.is_file(config_path)) {
print(`${config_path} does not exist`); disrupt
}
@@ -65,10 +57,6 @@ package.load_config = function(name)
return {}
}
// Deep copy to avoid toml module's shared state bug and cache it
result = json.decode(json.encode(result))
config_cache[config_path] = result
return result
}

View File

@@ -10872,13 +10872,10 @@ static JSValue js_cell_is_number (JSContext *ctx, JSValue this_val, int argc, JS
return JS_NewBool (ctx, JS_IsNumber (argv[0]));
}
/* is_object(val) - true for non-array, non-null objects */
/* is_object(val) - true for records */
static JSValue js_cell_is_object (JSContext *ctx, JSValue this_val, int argc, JSValue *argv) {
if (argc < 1) return JS_FALSE;
JSValue val = argv[0];
if (!mist_is_gc_object (val)) return JS_FALSE;
if (JS_IsArray (val)) return JS_FALSE;
return JS_TRUE;
return JS_NewBool (ctx, mist_is_record (argv[0]));
}
/* is_stone(val) - check if value is immutable */