File tree 1 file changed +51
-0
lines changed
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -3726,6 +3726,57 @@ int main(int argc, char* argv[])
3726
3726
}
3727
3727
</source>
3728
3728
3729
+ <h4>nbind</h4>
3730
+
3731
+ Home:[https://github.com/charto/nbind]
3732
+
3733
+ 把 C++ 代码编译为 JS 的 package。编译方式支持“原生二进制”或“asm.js”。
3734
+
3735
+ 编译需要依赖 Node.js,运行环境支持 Node.js 或浏览器。
3736
+
3737
+ 代码示例——C++ 代码
3738
+ <source lang="cpp">
3739
+ #include <string>
3740
+ #include <iostream>
3741
+
3742
+ struct Greeter
3743
+ {
3744
+ static void sayHello(std::string name)
3745
+ {
3746
+ std::cout << "Hello, " << name << "\n";
3747
+ }
3748
+ };
3749
+
3750
+ // 建立绑定
3751
+ #include <nbind/nbind.h>
3752
+
3753
+ NBIND_CLASS(Greeter)
3754
+ {
3755
+ method(sayHello);
3756
+ }
3757
+ </source>
3758
+
3759
+ 代码示例——node.js 环境调用代码
3760
+ <source lang="javascript">
3761
+ var nbind = require("nbind");
3762
+ var lib = nbind.init().lib;
3763
+ lib.Greeter.sayHello("you");
3764
+ </source>
3765
+
3766
+ 代码示例——浏览器环境调用代码
3767
+ <source lang="html">
3768
+ <script src="nbind.js"></script>
3769
+ <script>
3770
+ nbind.init(
3771
+ function(err, binding)
3772
+ {
3773
+ var lib = binding.lib;
3774
+ lib.Greeter.sayHello("you");
3775
+ }
3776
+ );
3777
+ </script>
3778
+ </source>
3779
+
3729
3780
----
3730
3781
3731
3782
= 18 (其它) =
You can’t perform that action at this time.
0 commit comments