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,8 @@
{
"targets": [
{
"target_name": "test_exception",
"sources": [ "test_exception.c" ]
}
]
}

View File

@ -0,0 +1,20 @@
'use strict';
// Flags: --expose-gc
const common = require('../../common');
const assert = require('assert');
const test_exception = require(`./build/${common.buildType}/test_exception`);
// Make sure that exceptions that occur during finalization are propagated.
function testFinalize(binding) {
let x = test_exception[binding]();
x = null;
global.gc();
process.on('uncaughtException', (err) => {
assert.strictEqual(err.message, 'Error during Finalize');
});
// To assuage the linter's concerns.
(function() {})(x);
}
testFinalize('createExternalBuffer');

View File

@ -0,0 +1,27 @@
#include <node_api.h>
#include "../../js-native-api/common.h"
static void finalizer(napi_env env, void *data, void *hint) {
NODE_API_CALL_RETURN_VOID(env,
napi_throw_error(env, NULL, "Error during Finalize"));
}
static char buffer_data[12];
static napi_value createExternalBuffer(napi_env env, napi_callback_info info) {
napi_value buffer;
NODE_API_CALL(env, napi_create_external_buffer(env, sizeof(buffer_data),
buffer_data, finalizer, NULL, &buffer));
return buffer;
}
static napi_value Init(napi_env env, napi_value exports) {
napi_property_descriptor descriptors[] = {
DECLARE_NODE_API_PROPERTY("createExternalBuffer", createExternalBuffer),
};
NODE_API_CALL(env, napi_define_properties(
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
return exports;
}
NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)