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 MyFunction(napi_env env, napi_callback_info info) {
napi_value str;
NODE_API_CALL(env, napi_create_string_utf8(env, "hello world", -1, &str));
return str;
}
static napi_value CreateFunction(napi_env env, napi_callback_info info) {
napi_value fn;
NODE_API_CALL(env,
napi_create_function(env, "theFunction", -1, MyFunction, NULL, &fn));
return fn;
}
EXTERN_C_START
napi_value Init(napi_env env, napi_value exports) {
NODE_API_CALL(env,
napi_create_function(env, "exports", -1, CreateFunction, NULL, &exports));
return exports;
}
EXTERN_C_END

View File

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

View File

@ -0,0 +1,7 @@
'use strict';
const common = require('../../common');
const assert = require('assert');
const addon = require(`./build/${common.buildType}/5_function_factory`);
const fn = addon();
assert.strictEqual(fn(), 'hello world'); // 'hello world'