8000 process, feat:: support process.dlopen. · fibjs/fibjs@949d310 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 949d310

Browse files
committed
process, feat:: support process.dlopen.
1 parent b18cd2b commit 949d310

File tree

96 files changed

+13874
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+13874
-9
lines changed

build

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ if [[ $CC == "" ]]; then
6262
fi
6363

6464
if [ -f "${SOURCE_ROOT}/vender/build" ]; then
65-
if [ -z $USE_VENDER_DIST ]; then
66-
cd "${SOURCE_ROOT}/vender"
67-
bash build "$@"
68-
if [ $? != 0 ]; then
69-
exit 1
70-
fi
71-
fi
65+
if [ -z $USE_VENDER_DIST ]; then
66+
cd "${SOURCE_ROOT}/vender"
67+
bash build "$@"
68+
if [ $? != 0 ]; then
69+
exit 1
70+
fi
71+
fi
7272
else
73-
inform
73+
inform
7474
fi
7575

7676
cd "${SOURCE_ROOT}/fibjs"
@@ -85,6 +85,12 @@ if [ $? != 0 ]; then
8585
exit 1
8686
fi
8787

88+
cd "${SOURCE_ROOT}/fibjs/addons"
89+
bash build "$@"
90+
if [ $? != 0 ]; then
91+
exit 1
92+
fi
93+
8894
cd "${SOURCE_ROOT}/fibjs/installer"
8995
bash build "$@"
9096
if [ $? != 0 ]; then

build.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ cd /d "%SOURCE_ROOT%/fibjs/program"
1919
call build %*%
2020
if ERRORLEVEL 1 goto exitbuild
2121

22+
cd /d "%SOURCE_ROOT%/fibjs/addons"
23+
call build %*%
24+
if ERRORLEVEL 1 goto exitbuild
25+
2226
cd /d "%SOURCE_ROOT%/fibjs/installer"
2327
call F438 build %*%
2428
if ERRORLEVEL 1 goto exitbuild
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
include(../common.cmake)

fibjs/addons/1_hello_world/binding.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <node_api.h>
2+
#include "common.h"
3+
#include <string.h>
4+
5+
static napi_value Method(napi_env env, napi_callback_info info)
6+
{
7+
napi_value world;
8+
const char* str = "world";
9+
size_t str_len = strlen(str);
10+
NODE_API_CALL(env, napi_create_string_utf8(env, str, str_len, &world));
11+
return world;
12+
}
13+
14+
NAPI_MODULE_INIT()
15+
{
16+
napi_property_descriptor desc = DECLARE_NODE_API_PROPERTY("hello", Method);
17+
NODE_API_CALL(env, napi_define_properties(env, exports, 1, &desc));
18+
return exports;
19+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <js_native_api.h>
2+
#include "common.h"
3+
#include "../entry_point.h"
4+
5+
static napi_value Add(napi_env env, napi_callback_info info)
6+
{
7+
size_t argc = 2;
8+
napi_value args[2];
9+
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
10+
11+
NODE_API_ASSERT(env, argc >= 2, "Wrong number of arguments");
12+
13+
napi_valuetype valuetype0;
14+
NODE_API_CALL(env, napi_typeof(env, args[0], &valuetype0));
15+
16+
napi_valuetype valuetype1;
17+
NODE_API_CALL(env, napi_typeof(env, args[1], &valuetype1));
18+
19+
NODE_API_ASSERT(env, valuetype0 == napi_number && valuetype1 == napi_number,
20+
"Wrong argument type. Numbers expected.");
21+
22+
double value0;
23+
NODE_API_CALL(env, napi_get_value_double(env, args[0], &value0));
24+
25+
double value1;
26+
NODE_API_CALL(env, napi_get_value_double(env, args[1], &value1));
27+
28+
napi_value sum;
29+
NODE_API_CALL(env, napi_create_double(env, value0 + value1, &sum));
30+
31+
return sum;
32+
}
33+
34+
EXTERN_C_START
35+
napi_value Init(napi_env env, napi_value exports)
36+
{
37+
napi_property_descriptor desc = DECLARE_NODE_API_PROPERTY("add", Add);
38+
NODE_API_CALL(env, napi_define_properties(env, exports, 1, &desc));
39+
return exports;
40+
}
41+
EXTERN_C_END
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
include(../common.cmake)
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <js_native_api.h>
2+
#include <string.h>
3+
#include "common.h"
4+
#include "entry_point.h"
5+
6+
static napi_value RunCallback(napi_env env, napi_callback_info info)
7+
{
8+
size_t argc = 2;
9+
napi_value args[2];
10+
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
11+
12+
NODE_API_ASSERT(env, argc == 1,
13+
"Wrong number of arguments. Expects a single argument.");
14+
15+
napi_valuetype valuetype0;
16+
NODE_API_CALL(env, napi_typeof(env, args[0], &valuetype0));
17+
NODE_API_ASSERT(env, valuetype0 == napi_function,
18+
"Wrong type of arguments. Expects a function as first argument.");
19+
20+
napi_valuetype valuetype1;
21+
NODE_API_CALL(env, napi_typeof(env, args[1], &valuetype1));
22+
NODE_API_ASSERT(env, valuetype1 == napi_undefined,
23+
"Additional arguments should be undefined.");
24+
25+
napi_value argv[1];
26+
const char* str = "hello world";
27+
size_t str_len = strlen(str);
28+
NODE_API_CALL(env, napi_create_string_utf8(env, str, str_len, argv));
29+
30+
napi_value global;
31+
NODE_API_CALL(env, napi_get_global(env, &global));
32+
33+
napi_value cb = args[0];
34+
NODE_API_CALL(env, napi_call_function(env, global, cb, 1, argv, NULL));
35+
36+
return NULL;
37+
}
38+
39+
static napi_value RunCallbackWithRecv(napi_env env, napi_callback_info info)
40+
{
41+
size_t argc = 2;
42+
napi_value args[2];
43+
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
44+
45+
napi_value cb = args[0];
46+
napi_value recv = args[1];
47+
NODE_API_CALL(env, napi_call_function(env, recv, cb, 0, NULL, NULL));
48+
return NULL;
49+
}
50+
51+
EXTERN_C_START
52+
napi_value Init(napi_env env, napi_value exports)
53+
{
54+
napi_property_descriptor desc[2] = {
55+
DECLARE_NODE_API_PROPERTY("RunCallback", RunCallback),
56+
DECLARE_NODE_API_PROPERTY("RunCallbackWithRecv", RunCallbackWithRecv),
57+
};
58+
NODE_API_CALL(env, napi_define_properties(env, exports, 2, desc));
59+
return exports;
60+
}
61+
EXTERN_C_END
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
include(../common.cmake)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <js_native_api.h>
2+
#include "common.h"
3+
#include "entry_point.h"
4+
5+
static napi_value CreateObject(napi_env env, napi_callback_info info)
6+
{
7+
size_t argc = 1;
8+
napi_value args[1];
9+
NODE_API_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL));
10+
11+
napi_value obj;
12+
NODE_API_CALL(env, napi_create_object(env, &obj));
13+
14+
NODE_API_CALL(env, napi_set_named_property(env, obj, "msg", args[0]));
15+
16+
return obj;
17+
}
18+
19+
EXTERN_C_START
20+
napi_value Init(napi_env env, napi_value exports)
21+
{
22+
NODE_API_CALL(env,
23+
napi_create_function(env, "exports", -1, CreateObject, NULL, &exports));
24+
return exports;
25+
}
26+
EXTERN_C_END
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
include(../common.cmake)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <js_native_api.h>
2+
#include "common.h"
3+
#include "entry_point.h"
4+
5+
static napi_value MyFunction(napi_env env, napi_callback_info info)
6+
{
7+
napi_value str;
8+
NODE_API_CALL(env, napi_create_string_utf8(env, "hello world", -1, &str));
9+
return str;
10+
}
11+
12+
static napi_value CreateFunction(napi_env env, napi_callback_info info)
13+
{
14+
napi_value fn;
15+
NODE_API_CALL(env,
16+
napi_create_function(env, "theFunction", -1, MyFunction, NULL, &fn));
17+
return fn;
18+
}
19+
20+
EXTERN_C_START
21+
napi_value Init(napi_env env, napi_value exports)
22+
{
23+
NODE_API_CALL(env,
24+
napi_create_function(env, "exports", -1, CreateFunction, NULL, &exports< 6B09 /span>));
25+
return exports;
26+
}
27+
EXTERN_C_END
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
include(../common.cmake)

0 commit comments

Comments
 (0)
0