Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,10 @@
{
"targets": [
{
"target_name": "test_symbol",
"sources": [
"test_symbol.c"
]
}
]
}

View File

@ -0,0 +1,19 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
// Testing api calls for symbol
const test_symbol = require(`./build/${common.buildType}/test_symbol`);
const sym = test_symbol.New('test');
assert.strictEqual(sym.toString(), 'Symbol(test)');
const myObj = {};
const fooSym = test_symbol.New('foo');
const otherSym = test_symbol.New('bar');
myObj.foo = 'bar';
myObj[fooSym] = 'baz';
myObj[otherSym] = 'bing';
assert.strictEqual(myObj.foo, 'bar');
assert.strictEqual(myObj[fooSym], 'baz');
assert.strictEqual(myObj[otherSym], 'bing');

View File

@ -0,0 +1,17 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
// Testing api calls for symbol
const test_symbol = require(`./build/${common.buildType}/test_symbol`);
const fooSym = test_symbol.New('foo');
assert.strictEqual(fooSym.toString(), 'Symbol(foo)');
const myObj = {};
myObj.foo = 'bar';
myObj[fooSym] = 'baz';
assert.deepStrictEqual(Object.keys(myObj), ['foo']);
assert.deepStrictEqual(Object.getOwnPropertyNames(myObj), ['foo']);
assert.deepStrictEqual(Object.getOwnPropertySymbols(myObj), [fooSym]);

View File

@ -0,0 +1,19 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
// Testing api calls for symbol
const test_symbol = require(`./build/${common.buildType}/test_symbol`);
assert.notStrictEqual(test_symbol.New(), test_symbol.New());
assert.notStrictEqual(test_symbol.New('foo'), test_symbol.New('foo'));
assert.notStrictEqual(test_symbol.New('foo'), test_symbol.New('bar'));
const foo1 = test_symbol.New('foo');
const foo2 = test_symbol.New('foo');
const object = {
[foo1]: 1,
[foo2]: 2,
};
assert.strictEqual(object[foo1], 1);
assert.strictEqual(object[foo2], 2);

View File

@ -0,0 +1,38 @@
#include <js_native_api.h>
#include "../common.h"
#include "../entry_point.h"
static napi_value New(napi_env env, napi_callback_info info) {
size_t argc = 1;
napi_value args[1];
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
napi_value description = NULL;
if (argc >= 1) {
napi_valuetype valuetype;
NODE_API_CALL(env, napi_typeof(env, args[0], &valuetype));
NODE_API_ASSERT(env, valuetype == napi_string,
"Wrong type of arguments. Expects a string.");
description = args[0];
}
napi_value symbol;
NODE_API_CALL(env, napi_create_symbol(env, description, &symbol));
return symbol;
}
EXTERN_C_START
napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor properties[] = {
DECLARE_NODE_API_PROPERTY("New", New),
};
NODE_API_CALL(env, napi_define_properties(
env, exports, sizeof(properties) / sizeof(*properties), properties));
return exports;
}
EXTERN_C_END