Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教wasm的编译问题。 #24

Open
zhaosky opened this issue Oct 21, 2024 · 8 comments
Open

请教wasm的编译问题。 #24

zhaosky opened this issue Oct 21, 2024 · 8 comments

Comments

@zhaosky
Copy link

zhaosky commented Oct 21, 2024

想问下大佬工程里面的chili_occ.d.ts是自己写的还是编译chili_occ.wasm的时候自动生成,如果是自动生成的能分享下方法吗,谢谢。

@xiangechen
Copy link
Owner

--emit-tsd 自动生成的,参照这个文档:https://emscripten.org/docs/tools_reference/emcc.html#emcc-emit-tsd
也可以看我项目中 cmake 的配置:https://github.com/xiangechen/chili3d/blob/main/cpp/CMakeLists.txt

@zhaosky
Copy link
Author

zhaosky commented Oct 21, 2024

--emit-tsd 自动生成的,参照这个文档:https://emscripten.org/docs/tools_reference/emcc.html#emcc-emit-tsd 也可以看我项目中 cmake 的配置:https://github.com/xiangechen/chili3d/blob/main/cpp/CMakeLists.txt

那emscripten不是要注册绑定吗,类似下面这种,这个你是纯手写的吗?我就想问这个注册绑定的东西是自己写的还是有工具可以自动生成。

EMSCRIPTEN_BINDINGS(Module) {
    emscripten::class_<TopoDS_Shape>("TopoDS_Shape")
        .constructor<>()
        .function("IsNull", &TopoDS_Shape::IsNull)
        .function("Nullify", &TopoDS_Shape::Nullify)
        .function("Location", emscripten::select_overload<const TopLoc_Location& () const>(&TopoDS_Shape::Location))
        //.function("SetLocation", emscripten::select_overload<void(const TopLoc_Location&)>(&TopoDS_Shape::Location))
        .function("Located", &TopoDS_Shape::Located)
        .function("Orientation", emscripten::select_overload<TopAbs_Orientation () const>(&TopoDS_Shape::Orientation))
        .function("SetOrientation", emscripten::select_overload<void(TopAbs_Orientation)>(&TopoDS_Shape::Orientation))
        .function("Oriented", &TopoDS_Shape::Oriented)
        .function("ShapeType", &TopoDS_Shape::ShapeType)
        .function("Free", emscripten::select_overload<Standard_Boolean () const>(&TopoDS_Shape::Free))
       .........
       .function("EmptyCopied", &TopoDS_Shape::EmptyCopied);
}

@xiangechen
Copy link
Owner

如果要用包装好的话,可以用 opencascade.js 这个库,这个是用 python 写的自动绑定。不怕麻烦的话就手动绑定,可控性更强,只绑定你需要的接口就行。

@zhaosky zhaosky closed this as completed Oct 21, 2024
@zhaosky
Copy link
Author

zhaosky commented Oct 25, 2024

如果要用包装好的话,可以用 opencascade.js 这个库,这个是用 python 写的自动绑定。不怕麻烦的话就手动绑定,可控性更强,只绑定你需要的接口就行。

还想再问下里面的chili_occ.d.ts是自动生成的吗,还是手动写的?自动生成是直接编译加选项吗?

@zhaosky zhaosky reopened this Oct 25, 2024
@xiangechen
Copy link
Owner

旧版本的chili_occ.d.ts是用的opencascade.js这个库的自定义模块自动生成,源码可以查看https://github.com/donalffons/opencascade.js/blob/master/src/buildFromYaml.py

新版本为chili-wasm是通过--emit-tsd选项自动生成。

1 similar comment
@xiangechen
Copy link
Owner

旧版本的chili_occ.d.ts是用的opencascade.js这个库的自定义模块自动生成,源码可以查看https://github.com/donalffons/opencascade.js/blob/master/src/buildFromYaml.py

新版本为chili-wasm是通过--emit-tsd选项自动生成。

@zhaosky
Copy link
Author

zhaosky commented Oct 25, 2024

旧版本的chili_occ.d.ts是用的opencascade.js这个库的自定义模块自动生成,源码可以查看https://github.com/donalffons/opencascade.js/blob/master/src/buildFromYaml.py

新版本为chili-wasm是通过--emit-tsd选项自动生成。

好的,谢谢,能在请教一下,Handle(TDocStd_Document)这样的在cpp里面绑定要怎么写啊?

@xiangechen
Copy link
Owner

就是一个普通的类Handle_TDocStd_Document

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants