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,24 @@
#include <js_native_api.h>
#include "../common.h"
#include "../entry_point.h"
static napi_value CreateObject(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 obj;
NODE_API_CALL(env, napi_create_object(env, &obj));
NODE_API_CALL(env, napi_set_named_property(env, obj, "msg", args[0]));
return obj;
}
EXTERN_C_START
napi_value Init(napi_env env, napi_value exports) {
NODE_API_CALL(env,
napi_create_function(env, "exports", -1, CreateObject, NULL, &exports));
return exports;
}
EXTERN_C_END

View File

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

View File

@ -0,0 +1,8 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const addon = require(`./build/${common.buildType}/4_object_factory`);
const obj1 = addon('hello');
const obj2 = addon('world');
assert.strictEqual(`${obj1.msg} ${obj2.msg}`, 'hello world');