diff --git a/cell.toml b/cell.toml index 9cf8d5a7..fd89a789 100644 --- a/cell.toml +++ b/cell.toml @@ -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" \ No newline at end of file +CFLAGS = "-DMINIZ_NO_TIME -DTARGET_EXTENSION -DTARGET_PLAYDATE -I$LOCAL/PlaydateSDK/C_API" diff --git a/docs/functions.md b/docs/functions.md index 4d4bcf55..f7e92830 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -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 ``` diff --git a/docs/language.md b/docs/language.md index 66755117..c51d0c03 100644 --- a/docs/language.md +++ b/docs/language.md @@ -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 diff --git a/package.cm b/package.cm index 5e74f7ce..a4c7e0fa 100644 --- a/package.cm +++ b/package.cm @@ -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 } diff --git a/source/runtime.c b/source/runtime.c index bf0f5f40..7769efe7 100644 --- a/source/runtime.c +++ b/source/runtime.c @@ -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 */