File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ build /
2
+ src /
Original file line number Diff line number Diff line change
1
+ #include " napi.h"
2
+
3
+ using namespace Napi ;
4
+
5
+ Value Test1 (const CallbackInfo& info) {
6
+ auto env = info.Env ();
7
+ Object obj = Object::New (env);
8
+
9
+ obj[" foo" ] = String::New (env, " bar" );
10
+
11
+ return obj;
12
+ }
13
+
14
+ void Init (Env env, Object exports, Object module ) {
15
+ exports.Set (" test1" , Function::New (env, Test1));
16
+ }
17
+
18
+ NODE_API_MODULE (addon, Init)
Original file line number Diff line number Diff line change
1
+ {
2
+ 'targets' : [
3
+ {
4
+ 'target_name' : 'binding' ,
5
+ 'sources' : [ 'binding.cc' ],
6
+ 'include_dirs' : ['<!(node -p \' require("../").include\' )' ],
7
+ 'dependencies' : ['<!(node -p \' require("../").gyp\' )' ],
8
+ 'cflags!' : [ '-fno-exceptions' ],
9
+ 'cflags_cc!' : [ '-fno-exceptions' ],
10
+ 'xcode_settings' : { 'GCC_ENABLE_CPP_EXCEPTIONS' : 'YES' }
11
+ }
12
+ ]
13
+ }
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const binding = require ( './build/Release/binding.node' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+
5
+ assert . deepStrictEqual ( binding . test1 ( ) , { "foo" : "bar" } ) ;
You can’t perform that action at this time.
0 commit comments