├── .clang-format ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── README.md ├── astgen ├── CMakeLists.txt ├── bake_resources.py ├── resources │ ├── __clang_cuda_builtin_vars.h │ ├── __clang_cuda_cmath.h │ ├── __clang_cuda_complex_builtins.h │ ├── __clang_cuda_device_functions.h │ ├── __clang_cuda_intrinsics.h │ ├── __clang_cuda_libdevice_declares.h │ ├── __clang_cuda_math_forward_declares.h │ ├── __clang_cuda_runtime_wrapper.h │ ├── __stddef_max_align_t.h │ ├── __wmmintrin_aes.h │ ├── __wmmintrin_pclmul.h │ ├── adxintrin.h │ ├── altivec.h │ ├── ammintrin.h │ ├── arm64intr.h │ ├── arm_acle.h │ ├── arm_cmse.h │ ├── arm_fp16.h │ ├── arm_mve.h │ ├── arm_neon.h │ ├── armintr.h │ ├── avx2intrin.h │ ├── avx512bf16intrin.h │ ├── avx512bitalgintrin.h │ ├── avx512bwintrin.h │ ├── avx512cdintrin.h │ ├── avx512dqintrin.h │ ├── avx512erintrin.h │ ├── avx512fintrin.h │ ├── avx512ifmaintrin.h │ ├── avx512ifmavlintrin.h │ ├── avx512pfintrin.h │ ├── avx512vbmi2intrin.h │ ├── avx512vbmiintrin.h │ ├── avx512vbmivlintrin.h │ ├── avx512vlbf16intrin.h │ ├── avx512vlbitalgintrin.h │ ├── avx512vlbwintrin.h │ ├── avx512vlcdintrin.h │ ├── avx512vldqintrin.h │ ├── avx512vlintrin.h │ ├── avx512vlvbmi2intrin.h │ ├── avx512vlvnniintrin.h │ ├── avx512vlvp2intersectintrin.h │ ├── avx512vnniintrin.h │ ├── avx512vp2intersectintrin.h │ ├── avx512vpopcntdqintrin.h │ ├── avx512vpopcntdqvlintrin.h │ ├── avxintrin.h │ ├── bmi2intrin.h │ ├── bmiintrin.h │ ├── cetintrin.h │ ├── cldemoteintrin.h │ ├── clflushoptintrin.h │ ├── clwbintrin.h │ ├── clzerointrin.h │ ├── cpuid.h │ ├── cuda_wrappers │ │ ├── algorithm │ │ ├── complex │ │ └── new │ ├── emmintrin.h │ ├── enqcmdintrin.h │ ├── f16cintrin.h │ ├── float.h │ ├── fma4intrin.h │ ├── fmaintrin.h │ ├── fxsrintrin.h │ ├── gfniintrin.h │ ├── htmintrin.h │ ├── htmxlintrin.h │ ├── ia32intrin.h │ ├── immintrin.h │ ├── intrin.h │ ├── inttypes.h │ ├── invpcidintrin.h │ ├── iso646.h │ ├── limits.h │ ├── lwpintrin.h │ ├── lzcntintrin.h │ ├── mm3dnow.h │ ├── mm_malloc.h │ ├── mmintrin.h │ ├── module.modulemap │ ├── movdirintrin.h │ ├── msa.h │ ├── mwaitxintrin.h │ ├── nmmintrin.h │ ├── opencl-c-base.h │ ├── opencl-c.h │ ├── openmp_wrappers │ │ ├── __clang_openmp_math.h │ │ ├── __clang_openmp_math_declares.h │ │ ├── cmath │ │ └── math.h │ ├── pconfigintrin.h │ ├── pkuintrin.h │ ├── pmmintrin.h │ ├── popcntintrin.h │ ├── ppc_wrappers │ │ ├── emmintrin.h │ │ ├── mm_malloc.h │ │ ├── mmintrin.h │ │ ├── pmmintrin.h │ │ ├── smmintrin.h │ │ ├── tmmintrin.h │ │ └── xmmintrin.h │ ├── prfchwintrin.h │ ├── ptwriteintrin.h │ ├── rdseedintrin.h │ ├── rtmintrin.h │ ├── s390intrin.h │ ├── sgxintrin.h │ ├── shaintrin.h │ ├── smmintrin.h │ ├── stdalign.h │ ├── stdarg.h │ ├── stdatomic.h │ ├── stdbool.h │ ├── stddef.h │ ├── stdint.h │ ├── stdnoreturn.h │ ├── tbmintrin.h │ ├── tgmath.h │ ├── tmmintrin.h │ ├── unwind.h │ ├── vadefs.h │ ├── vaesintrin.h │ ├── varargs.h │ ├── vecintrin.h │ ├── vpclmulqdqintrin.h │ ├── waitpkgintrin.h │ ├── wbnoinvdintrin.h │ ├── wmmintrin.h │ ├── x86intrin.h │ ├── xmmintrin.h │ ├── xopintrin.h │ ├── xsavecintrin.h │ ├── xsaveintrin.h │ ├── xsaveoptintrin.h │ ├── xsavesintrin.h │ └── xtestintrin.h └── src │ ├── ast.cpp │ ├── ast.hpp │ ├── ast_utils.cpp │ ├── ast_utils.hpp │ ├── astgen.cpp │ ├── base64.hpp │ ├── filesystem.hpp │ ├── optional.hpp │ ├── process_binding.cpp │ ├── process_binding.hpp │ ├── pystring.cpp │ ├── pystring.h │ ├── resources.cpp │ ├── resources.hpp │ ├── tagged_pointer.hpp │ └── variant.hpp ├── asttoc ├── CMakeLists.txt ├── README.md ├── include │ ├── base64.hpp │ ├── case.hpp │ ├── cppmm_ast.hpp │ ├── cppmm_ast_add_c.hpp │ ├── cppmm_ast_read.hpp │ ├── cppmm_ast_write_c.hpp │ ├── cppmm_ast_write_cmake.hpp │ ├── cppmm_ast_write_rustsys.hpp │ ├── filesystem.hpp │ ├── json.hh │ └── pystring.h ├── simple_test.c └── src │ ├── cppmm_ast.cpp │ ├── cppmm_ast_add_c.cpp │ ├── cppmm_ast_read.cpp │ ├── cppmm_ast_write_c.cpp │ ├── cppmm_ast_write_cmake.cpp │ ├── cppmm_ast_write_rustsys.cpp │ ├── main.cpp │ └── pystring.cpp ├── bind.sh ├── genbind ├── CMakeLists.txt └── src │ ├── base64.hpp │ ├── filesystem.hpp │ ├── genbind.cpp │ ├── genbind.py │ ├── pystring.cpp │ ├── pystring.h │ ├── resources.cpp │ └── resources.hpp ├── include ├── cppmm_config.hpp └── cppmm_config.hpp.in ├── package.py ├── package.py.in ├── test ├── array_params │ ├── CMakeLists.txt │ ├── bind │ │ └── c-array_params.cpp │ ├── include │ │ └── array_params.hpp │ └── ref │ │ ├── array_params-sys │ │ ├── Cargo.toml │ │ ├── array_params-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── abigen.cpp │ │ │ │ ├── c-array_params.cpp │ │ │ │ ├── c-array_params.hpp │ │ │ │ └── insert_abi.py │ │ │ ├── include.in │ │ │ │ └── c-array_params.h │ │ │ ├── include │ │ │ │ ├── array_params-api-export.h │ │ │ │ └── array_params-errors.h │ │ │ ├── private │ │ │ │ ├── array_params-errors-private.h │ │ │ │ └── c-array_params_private.h │ │ │ └── src │ │ │ │ ├── array_params-errors.cpp │ │ │ │ └── c-array_params.cpp │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ └── src │ │ │ ├── c_array_params.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ └── test.rs │ │ └── ast │ │ └── c-array_params.json ├── bindandtest.sh ├── comments │ ├── CMakeLists.txt │ ├── bind │ │ └── c-comments.cpp │ ├── include │ │ └── comments.hpp │ └── ref │ │ ├── ast │ │ └── c-comments.json │ │ └── comments-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── comments-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── c-comments.cpp │ │ │ ├── c-comments.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ └── c-comments.h │ │ ├── include │ │ │ ├── comments-api-export.h │ │ │ └── comments-errors.h │ │ ├── private │ │ │ ├── c-comments_private.h │ │ │ └── comments-errors-private.h │ │ └── src │ │ │ ├── c-comments.cpp │ │ │ └── comments-errors.cpp │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ └── src │ │ ├── c_comments.rs │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ └── test.rs ├── containers │ ├── bind │ │ ├── containers.hpp │ │ └── containers_bind.cpp │ ├── ref │ │ ├── CMakeLists.txt │ │ ├── casts.h │ │ ├── containers_bind.cpp │ │ ├── containers_bind.h │ │ ├── cppmm_containers.cpp │ │ └── cppmm_containers.h │ └── test-rust-sys │ │ └── test.rs ├── copymoveaccess │ ├── CMakeLists.txt │ ├── bind │ │ └── cma.cpp │ └── include │ │ └── cma.hpp ├── cppmm.cpp ├── cppmm.h ├── deep_namespace │ ├── CMakeLists.txt │ ├── bind │ │ └── c-dn.cpp │ ├── include │ │ └── dn.hpp │ └── ref │ │ ├── ast │ │ └── c-dn.json │ │ └── deep_namespace-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── deep_namespace-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── c-dn.cpp │ │ │ ├── c-dn.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ └── c-dn.h │ │ ├── include │ │ │ ├── deep_namespace-api-export.h │ │ │ └── deep_namespace-errors.h │ │ ├── private │ │ │ ├── c-dn_private.h │ │ │ └── deep_namespace-errors-private.h │ │ └── src │ │ │ ├── c-dn.cpp │ │ │ └── deep_namespace-errors.cpp │ │ └── src │ │ ├── c_dn.rs │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ └── test.rs ├── deriveattr │ ├── CMakeLists.txt │ ├── bind │ │ └── dattr.cpp │ ├── include │ │ └── dattr.hpp │ └── ref │ │ ├── ast │ │ └── dattr.json │ │ └── deriveattr-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── deriveattr-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── dattr.cpp │ │ │ ├── dattr.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ └── dattr.h │ │ ├── include │ │ │ ├── deriveattr-api-export.h │ │ │ └── deriveattr-errors.h │ │ ├── private │ │ │ ├── dattr_private.h │ │ │ └── deriveattr-errors-private.h │ │ └── src │ │ │ ├── dattr.cpp │ │ │ └── deriveattr-errors.cpp │ │ └── src │ │ ├── cppmmabi.rs │ │ ├── dattr.rs │ │ ├── lib.rs │ │ └── test.rs ├── diff.sh ├── dtor │ ├── CMakeLists.txt │ ├── bind │ │ ├── c-dtor.cpp │ │ └── std_string.cpp │ ├── include │ │ └── dtor.hpp │ ├── ref │ │ ├── ast │ │ │ ├── c-dtor.json │ │ │ └── std_string.json │ │ └── dtor-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── dtor-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── abigen.cpp │ │ │ │ ├── c-dtor.cpp │ │ │ │ ├── c-dtor.hpp │ │ │ │ ├── insert_abi.py │ │ │ │ ├── std_string.cpp │ │ │ │ └── std_string.hpp │ │ │ ├── include.in │ │ │ │ ├── c-dtor.h │ │ │ │ └── std_string.h │ │ │ ├── include │ │ │ │ ├── dtor-api-export.h │ │ │ │ └── dtor-errors.h │ │ │ ├── private │ │ │ │ ├── c-dtor_private.h │ │ │ │ ├── dtor-errors-private.h │ │ │ │ └── std_string_private.h │ │ │ └── src │ │ │ │ ├── c-dtor.cpp │ │ │ │ ├── dtor-errors.cpp │ │ │ │ └── std_string.cpp │ │ │ └── src │ │ │ ├── c_dtor.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ ├── std_string.rs │ │ │ └── test.rs │ └── test.rs ├── exceptions │ ├── CMakeLists.txt │ ├── bind │ │ └── c-ex.cpp │ ├── include │ │ └── ex.hpp │ ├── ref │ │ ├── ast │ │ │ └── c-ex.json │ │ └── exceptions-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── exceptions-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── abigen.cpp │ │ │ │ ├── c-ex.cpp │ │ │ │ ├── c-ex.hpp │ │ │ │ └── insert_abi.py │ │ │ ├── include.in │ │ │ │ └── c-ex.h │ │ │ ├── include │ │ │ │ ├── exceptions-api-export.h │ │ │ │ └── exceptions-errors.h │ │ │ ├── private │ │ │ │ ├── c-ex_private.h │ │ │ │ └── exceptions-errors-private.h │ │ │ └── src │ │ │ │ ├── c-ex.cpp │ │ │ │ └── exceptions-errors.cpp │ │ │ └── src │ │ │ ├── c_ex.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ └── test.rs │ └── test.rs ├── function_pointers │ ├── CMakeLists.txt │ ├── bind │ │ └── c-fptr.cpp │ ├── include │ │ └── fptr.hpp │ ├── ref │ │ ├── ast │ │ │ └── c-fptr.json │ │ └── function_pointers-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── function_pointers-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── abigen.cpp │ │ │ │ ├── c-fptr.cpp │ │ │ │ ├── c-fptr.hpp │ │ │ │ └── insert_abi.py │ │ │ ├── include.in │ │ │ │ └── c-fptr.h │ │ │ ├── include │ │ │ │ ├── function_pointers-api-export.h │ │ │ │ └── function_pointers-errors.h │ │ │ ├── private │ │ │ │ ├── c-fptr_private.h │ │ │ │ └── function_pointers-errors-private.h │ │ │ └── src │ │ │ │ ├── c-fptr.cpp │ │ │ │ └── function_pointers-errors.cpp │ │ │ └── src │ │ │ ├── c_fptr.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ └── test.rs │ └── test.rs ├── half │ ├── bind │ │ └── half.cpp │ └── ref │ │ ├── CMakeLists.txt │ │ ├── casts.h │ │ ├── cppmm_containers.cpp │ │ ├── cppmm_containers.h │ │ ├── half.cpp │ │ └── half.h ├── imath │ ├── CMakeLists.txt │ ├── bind │ │ ├── imath_box.cpp │ │ └── imath_vec.cpp │ └── ref │ │ ├── ast │ │ ├── imath_box.json │ │ └── imath_vec.json │ │ └── imath-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── imath-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── imath_box.cpp │ │ │ ├── imath_box.hpp │ │ │ ├── imath_vec.cpp │ │ │ ├── imath_vec.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ ├── imath_box.h │ │ │ └── imath_vec.h │ │ ├── include │ │ │ ├── imath-api-export.h │ │ │ └── imath-errors.h │ │ ├── private │ │ │ ├── imath-errors-private.h │ │ │ ├── imath_box_private.h │ │ │ └── imath_vec_private.h │ │ └── src │ │ │ ├── imath-errors.cpp │ │ │ ├── imath_box.cpp │ │ │ └── imath_vec.cpp │ │ └── src │ │ ├── cppmmabi.rs │ │ ├── imath_box.rs │ │ ├── imath_vec.rs │ │ ├── lib.rs │ │ └── test.rs ├── mimpl │ ├── CMakeLists.txt │ ├── bind │ │ └── mimpl.cpp │ ├── include │ │ └── mimpl.hpp │ └── ref │ │ ├── ast │ │ └── mimpl.json │ │ └── mimpl-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── mimpl-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── insert_abi.py │ │ │ ├── mimpl.cpp │ │ │ └── mimpl.hpp │ │ ├── include.in │ │ │ └── mimpl.h │ │ ├── include │ │ │ ├── mimpl-api-export.h │ │ │ └── mimpl-errors.h │ │ ├── private │ │ │ ├── mimpl-errors-private.h │ │ │ └── mimpl_private.h │ │ └── src │ │ │ ├── mimpl-errors.cpp │ │ │ └── mimpl.cpp │ │ └── src │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ ├── mimpl.rs │ │ └── test.rs ├── nested │ ├── CMakeLists.txt │ ├── bind │ │ ├── a │ │ │ ├── neste.cpp │ │ │ └── neste.cpp.json │ │ ├── b │ │ │ ├── neste.cpp │ │ │ └── neste.cpp.json │ │ └── c │ │ │ └── d │ │ │ └── neste.cpp │ ├── include │ │ ├── a │ │ │ └── neste.hpp │ │ ├── b │ │ │ └── neste.hpp │ │ └── c │ │ │ └── d │ │ │ └── neste.hpp │ └── ref │ │ ├── ast │ │ ├── a │ │ │ └── neste.json │ │ ├── b │ │ │ └── neste.json │ │ └── c │ │ │ └── d │ │ │ └── neste.json │ │ └── nested-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── nested-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── a │ │ │ │ ├── neste.cpp │ │ │ │ └── neste.hpp │ │ │ ├── abigen.cpp │ │ │ ├── b │ │ │ │ ├── neste.cpp │ │ │ │ └── neste.hpp │ │ │ ├── c │ │ │ │ └── d │ │ │ │ │ ├── neste.cpp │ │ │ │ │ └── neste.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ ├── a │ │ │ │ └── neste.h │ │ │ ├── b │ │ │ │ └── neste.h │ │ │ └── c │ │ │ │ └── d │ │ │ │ └── neste.h │ │ ├── include │ │ │ ├── nested-api-export.h │ │ │ └── nested-errors.h │ │ ├── private │ │ │ ├── a │ │ │ │ └── neste_private.h │ │ │ ├── b │ │ │ │ └── neste_private.h │ │ │ ├── c │ │ │ │ └── d │ │ │ │ │ └── neste_private.h │ │ │ └── nested-errors-private.h │ │ └── src │ │ │ ├── a │ │ │ └── neste.cpp │ │ │ ├── b │ │ │ └── neste.cpp │ │ │ ├── c │ │ │ └── d │ │ │ │ └── neste.cpp │ │ │ └── nested-errors.cpp │ │ └── src │ │ ├── a │ │ ├── mod.rs │ │ └── neste.rs │ │ ├── b │ │ ├── mod.rs │ │ └── neste.rs │ │ ├── c │ │ ├── d │ │ │ ├── mod.rs │ │ │ └── neste.rs │ │ └── mod.rs │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ └── test.rs ├── oiio.old │ ├── bind │ │ ├── c-filesystem.cpp │ │ ├── c-imageio.cpp │ │ └── c-typedesc.cpp │ ├── ref │ │ ├── CMakeLists.txt │ │ ├── c-filesystem.cpp │ │ ├── c-filesystem.h │ │ ├── c-imageio.cpp │ │ ├── c-imageio.h │ │ ├── c-typedesc.cpp │ │ ├── c-typedesc.h │ │ ├── casts.h │ │ ├── cppmm_containers.cpp │ │ └── cppmm_containers.h │ └── test_filesystem.c ├── oiio │ ├── CMakeLists.txt │ ├── bind │ │ ├── c-filesystem.cpp │ │ ├── c-imageio.cpp │ │ ├── c-typedesc.cpp │ │ ├── std_string.cpp │ │ └── std_vector.cpp │ └── ref │ │ ├── ast │ │ ├── c-filesystem.json │ │ ├── c-imageio.json │ │ ├── c-typedesc.json │ │ ├── std_string.json │ │ └── std_vector.json │ │ ├── oiio-c │ │ ├── CMakeLists.txt │ │ ├── c-filesystem.cpp │ │ ├── c-filesystem.h │ │ ├── c-filesystem_private.h │ │ ├── c-imageio.cpp │ │ ├── c-imageio.h │ │ ├── c-imageio_private.h │ │ ├── c-typedesc.cpp │ │ ├── c-typedesc.h │ │ ├── c-typedesc_private.h │ │ ├── std_string.cpp │ │ ├── std_string.h │ │ ├── std_string_private.h │ │ ├── std_vector.cpp │ │ ├── std_vector.h │ │ └── std_vector_private.h │ │ └── oiio-sys │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ ├── c_filesystem.rs │ │ ├── c_imageio.rs │ │ ├── c_typedesc.rs │ │ ├── lib.rs │ │ ├── std_string.rs │ │ ├── std_vector.rs │ │ └── test.rs ├── opaquebytes │ ├── CMakeLists.txt │ ├── bind │ │ └── obyte.cpp │ ├── include │ │ └── obyte.hpp │ └── ref │ │ ├── ast │ │ └── obyte.json │ │ └── opaquebytes-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── opaquebytes-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── insert_abi.py │ │ │ ├── obyte.cpp │ │ │ └── obyte.hpp │ │ ├── include.in │ │ │ └── obyte.h │ │ ├── include │ │ │ ├── opaquebytes-api-export.h │ │ │ └── opaquebytes-errors.h │ │ ├── private │ │ │ ├── obyte_private.h │ │ │ └── opaquebytes-errors-private.h │ │ └── src │ │ │ ├── obyte.cpp │ │ │ └── opaquebytes-errors.cpp │ │ └── src │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ ├── obyte.rs │ │ └── test.rs ├── opaqueptr │ ├── CMakeLists.txt │ ├── bind │ │ └── c-optr.cpp │ ├── include │ │ └── optr.hpp │ └── ref │ │ ├── ast │ │ └── c-optr.json │ │ └── opaqueptr-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── opaqueptr-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── c-optr.cpp │ │ │ ├── c-optr.hpp │ │ │ └── insert_abi.py │ │ ├── include.in │ │ │ └── c-optr.h │ │ ├── include │ │ │ ├── opaqueptr-api-export.h │ │ │ └── opaqueptr-errors.h │ │ ├── private │ │ │ ├── c-optr_private.h │ │ │ └── opaqueptr-errors-private.h │ │ └── src │ │ │ ├── c-optr.cpp │ │ │ └── opaqueptr-errors.cpp │ │ └── src │ │ ├── c_optr.rs │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ └── test.rs ├── openexr │ ├── CMakeLists.txt │ ├── bind │ │ ├── c-half.cpp │ │ ├── imath_box.cpp │ │ ├── imath_matrix.cpp │ │ ├── imath_vec.cpp │ │ ├── imf_aces_file.cpp │ │ ├── imf_array.cpp │ │ ├── imf_attribute.cpp │ │ ├── imf_b44compressor.cpp │ │ ├── imf_channellist.cpp │ │ ├── imf_chromaticities.cpp │ │ ├── imf_compositedeepscanline.cpp │ │ ├── imf_compression.cpp │ │ ├── imf_compressor.cpp │ │ ├── imf_convert.cpp │ │ ├── imf_deepcompositing.cpp │ │ ├── imf_deepframebuffer.cpp │ │ ├── imf_deepimage.cpp │ │ ├── imf_deepimagechannel.cpp │ │ ├── imf_deepimageio.cpp │ │ ├── imf_deepimagelevel.cpp │ │ ├── imf_deepimagestate.cpp │ │ ├── imf_deepscanlineinputfile.cpp │ │ ├── imf_deepscanlineinputpart.cpp │ │ ├── imf_deepscanlineoutputfile.cpp │ │ ├── imf_deepscanlineoutputpart.cpp │ │ ├── imf_deeptiledinputfile.cpp │ │ ├── imf_deeptiledinputpart.cpp │ │ ├── imf_deeptiledoutputfile.cpp │ │ ├── imf_deeptiledoutputpart.cpp │ │ ├── imf_envmap.cpp │ │ ├── imf_flatimage.cpp │ │ ├── imf_flatimagechannel.cpp │ │ ├── imf_flatimageio.cpp │ │ ├── imf_flatimagelevel.cpp │ │ ├── imf_framebuffer.cpp │ │ ├── imf_framespersecond.cpp │ │ ├── imf_header.cpp │ │ ├── imf_huf.cpp │ │ ├── imf_image.cpp │ │ ├── imf_imagechannel.cpp │ │ ├── imf_imagechannelrenaming.cpp │ │ ├── imf_imagedatawindow.cpp │ │ ├── imf_imageio.cpp │ │ ├── imf_imagelevel.cpp │ │ ├── imf_inputfile.cpp │ │ ├── imf_inputpart.cpp │ │ ├── imf_io.cpp │ │ ├── imf_keycode.cpp │ │ ├── imf_lineorder.cpp │ │ ├── imf_lut.cpp │ │ ├── imf_multipartinputfile.cpp │ │ ├── imf_multipartoutputfile.cpp │ │ ├── imf_multiview.cpp │ │ ├── imf_name.cpp │ │ ├── imf_opaqueattribute.cpp │ │ ├── imf_outputfile.cpp │ │ ├── imf_outputpart.cpp │ │ ├── imf_parthelper.cpp │ │ ├── imf_parttype.cpp │ │ ├── imf_pixeltype.cpp │ │ ├── imf_previewimage.cpp │ │ ├── imf_rational.cpp │ │ ├── imf_rgba.cpp │ │ ├── imf_rgbafile.cpp │ │ ├── imf_rgbayca.cpp │ │ ├── imf_samplecountchannel.cpp │ │ ├── imf_standardattributes.cpp │ │ ├── imf_testfile.cpp │ │ ├── imf_threading.cpp │ │ ├── imf_tiledescription.cpp │ │ ├── imf_tiledinputfile.cpp │ │ ├── imf_tiledinputpart.cpp │ │ ├── imf_tiledoutputfile.cpp │ │ ├── imf_tiledoutputpart.cpp │ │ ├── imf_tiledrgbafile.cpp │ │ ├── imf_timecode.cpp │ │ ├── imf_version.cpp │ │ ├── imf_wav.cpp │ │ ├── std.cpp │ │ ├── std_map.cpp │ │ ├── std_set.cpp │ │ ├── std_string.cpp │ │ └── std_vector.cpp │ ├── ref │ │ └── ast │ │ │ ├── half.json │ │ │ ├── imath_box.json │ │ │ ├── imath_matrix.json │ │ │ ├── imath_vec.json │ │ │ ├── imf_aces_file.json │ │ │ ├── imf_array.json │ │ │ ├── imf_attribute.json │ │ │ ├── imf_b44compressor.json │ │ │ ├── imf_channellist.json │ │ │ ├── imf_chromaticities.json │ │ │ ├── imf_compositedeepscanline.json │ │ │ ├── imf_compression.json │ │ │ ├── imf_compressor.json │ │ │ ├── imf_convert.json │ │ │ ├── imf_deepcompositing.json │ │ │ ├── imf_deepframebuffer.json │ │ │ ├── imf_deepimage.json │ │ │ ├── imf_deepimagechannel.json │ │ │ ├── imf_deepimageio.json │ │ │ ├── imf_deepimagelevel.json │ │ │ ├── imf_deepimagestate.json │ │ │ ├── imf_deepscanlineinputfile.json │ │ │ ├── imf_deepscanlineinputpart.json │ │ │ ├── imf_deepscanlineoutputfile.json │ │ │ ├── imf_deepscanlineoutputpart.json │ │ │ ├── imf_deeptiledinputfile.json │ │ │ ├── imf_deeptiledinputpart.json │ │ │ ├── imf_deeptiledoutputfile.json │ │ │ ├── imf_deeptiledoutputpart.json │ │ │ ├── imf_envmap.json │ │ │ ├── imf_flatimage.json │ │ │ ├── imf_flatimagechannel.json │ │ │ ├── imf_flatimageio.json │ │ │ ├── imf_flatimagelevel.json │ │ │ ├── imf_framebuffer.json │ │ │ ├── imf_framespersecond.json │ │ │ ├── imf_header.json │ │ │ ├── imf_huf.json │ │ │ ├── imf_image.json │ │ │ ├── imf_imagechannel.json │ │ │ ├── imf_imagechannelrenaming.json │ │ │ ├── imf_imagedatawindow.json │ │ │ ├── imf_imageio.json │ │ │ ├── imf_imagelevel.json │ │ │ ├── imf_inputfile.json │ │ │ ├── imf_inputpart.json │ │ │ ├── imf_io.json │ │ │ ├── imf_keycode.json │ │ │ ├── imf_lineorder.json │ │ │ ├── imf_lut.json │ │ │ ├── imf_multipartinputfile.json │ │ │ ├── imf_multipartoutputfile.json │ │ │ ├── imf_multiview.json │ │ │ ├── imf_name.json │ │ │ ├── imf_opaqueattribute.json │ │ │ ├── imf_outputfile.json │ │ │ ├── imf_outputpart.json │ │ │ ├── imf_parthelper.json │ │ │ ├── imf_parttype.json │ │ │ ├── imf_pixeltype.json │ │ │ ├── imf_previewimage.json │ │ │ ├── imf_rational.json │ │ │ ├── imf_rgba.json │ │ │ ├── imf_rgbafile.json │ │ │ ├── imf_rgbayca.json │ │ │ ├── imf_samplecountchannel.json │ │ │ ├── imf_testfile.json │ │ │ ├── imf_threading.json │ │ │ ├── imf_tiledescription.json │ │ │ ├── imf_tiledinputfile.json │ │ │ ├── imf_tiledinputpart.json │ │ │ ├── imf_tiledoutputfile.json │ │ │ ├── imf_tiledoutputpart.json │ │ │ ├── imf_tiledrgbafile.json │ │ │ ├── imf_timecode.json │ │ │ ├── imf_version.json │ │ │ └── imf_wav.json │ └── test.rs ├── property │ ├── CMakeLists.txt │ ├── bind │ │ └── prop.cpp │ ├── include │ │ └── prop.hpp │ └── ref │ │ ├── ast │ │ └── prop.json │ │ └── property-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── property-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── insert_abi.py │ │ │ ├── prop.cpp │ │ │ └── prop.hpp │ │ ├── include.in │ │ │ └── prop.h │ │ ├── include │ │ │ ├── property-api-export.h │ │ │ └── property-errors.h │ │ ├── private │ │ │ ├── prop_private.h │ │ │ └── property-errors-private.h │ │ └── src │ │ │ ├── prop.cpp │ │ │ └── property-errors.cpp │ │ └── src │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ ├── prop.rs │ │ └── test.rs ├── runtest.py ├── rustify_enum │ ├── CMakeLists.txt │ ├── bind │ │ └── c-renum.cpp │ ├── include │ │ └── renum.hpp │ ├── ref │ │ ├── ast │ │ │ └── c-renum.json │ │ └── rustify_enum-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── rustify_enum-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── abigen.cpp │ │ │ │ ├── c-renum.cpp │ │ │ │ ├── c-renum.hpp │ │ │ │ └── insert_abi.py │ │ │ ├── include.in │ │ │ │ └── c-renum.h │ │ │ ├── include │ │ │ │ ├── rustify_enum-api-export.h │ │ │ │ └── rustify_enum-errors.h │ │ │ ├── private │ │ │ │ ├── c-renum_private.h │ │ │ │ └── rustify_enum-errors-private.h │ │ │ └── src │ │ │ │ ├── c-renum.cpp │ │ │ │ └── rustify_enum-errors.cpp │ │ │ └── src │ │ │ ├── c_renum.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ └── test.rs │ └── test.rs ├── std │ ├── CMakeLists.txt │ ├── bind │ │ ├── c-usestd.cpp │ │ ├── std_list.cpp │ │ ├── std_set.cpp │ │ └── std_string.cpp │ ├── include │ │ └── usestd.hpp │ ├── ref │ │ ├── ast │ │ │ ├── c-usestd.json │ │ │ ├── std_list.json │ │ │ ├── std_set.json │ │ │ └── std_string.json │ │ └── std-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── src │ │ │ ├── c_usestd.rs │ │ │ ├── cppmmabi.rs │ │ │ ├── lib.rs │ │ │ ├── std_list.rs │ │ │ ├── std_set.rs │ │ │ ├── std_string.rs │ │ │ └── test.rs │ │ │ └── std-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── c-usestd.cpp │ │ │ ├── c-usestd.hpp │ │ │ ├── insert_abi.py │ │ │ ├── std_list.cpp │ │ │ ├── std_list.hpp │ │ │ ├── std_set.cpp │ │ │ ├── std_set.hpp │ │ │ ├── std_string.cpp │ │ │ └── std_string.hpp │ │ │ ├── include.in │ │ │ ├── c-usestd.h │ │ │ ├── std_list.h │ │ │ ├── std_set.h │ │ │ └── std_string.h │ │ │ ├── include │ │ │ ├── std-api-export.h │ │ │ └── std-errors.h │ │ │ ├── private │ │ │ ├── c-usestd_private.h │ │ │ ├── std-errors-private.h │ │ │ ├── std_list_private.h │ │ │ ├── std_set_private.h │ │ │ └── std_string_private.h │ │ │ └── src │ │ │ ├── c-usestd.cpp │ │ │ ├── std-errors.cpp │ │ │ ├── std_list.cpp │ │ │ ├── std_set.cpp │ │ │ └── std_string.cpp │ ├── test-rust-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── clib │ │ │ ├── CMakeLists.txt │ │ │ ├── casts.h │ │ │ ├── cppmm_containers.cpp │ │ │ ├── cppmm_containers.h │ │ │ ├── std_string.cpp │ │ │ ├── std_string.h │ │ │ ├── test_bind.cpp │ │ │ └── test_bind.h │ │ └── src │ │ │ ├── cppmm_containers.rs │ │ │ ├── lib.rs │ │ │ ├── std_string.rs │ │ │ ├── std_string_bind.rs │ │ │ ├── test.rs │ │ │ └── test_bind.rs │ └── test.rs ├── templates │ ├── bind │ │ ├── templates.hpp │ │ └── templates_bind.cpp │ └── ref │ │ ├── CMakeLists.txt │ │ ├── bind.cpp │ │ ├── bind.h │ │ ├── casts.h │ │ ├── cppmm_containers.cpp │ │ ├── cppmm_containers.h │ │ ├── templates_bind.cpp │ │ └── templates_bind.h ├── tmp_specs │ ├── CMakeLists.txt │ ├── bind │ │ ├── c-specs.cpp │ │ └── std_string.cpp │ ├── include │ │ └── tmp_specs.hpp │ └── ref │ │ ├── ast │ │ ├── c-specs.json │ │ └── std_string.json │ │ └── tmp_specs-sys │ │ ├── Cargo.toml │ │ ├── build.rs │ │ ├── cppmm_abi_in │ │ └── cppmmabi.rs │ │ ├── src │ │ ├── c_specs.rs │ │ ├── cppmmabi.rs │ │ ├── lib.rs │ │ ├── std_string.rs │ │ └── test.rs │ │ └── tmp_specs-c │ │ ├── CMakeLists.txt │ │ ├── abigen │ │ ├── CMakeLists.txt │ │ ├── abigen.cpp │ │ ├── c-specs.cpp │ │ ├── c-specs.hpp │ │ ├── insert_abi.py │ │ ├── std_string.cpp │ │ └── std_string.hpp │ │ ├── include.in │ │ ├── c-specs.h │ │ └── std_string.h │ │ ├── include │ │ ├── tmp_specs-api-export.h │ │ └── tmp_specs-errors.h │ │ ├── private │ │ ├── c-specs_private.h │ │ ├── std_string_private.h │ │ └── tmp_specs-errors-private.h │ │ └── src │ │ ├── c-specs.cpp │ │ ├── std_string.cpp │ │ └── tmp_specs-errors.cpp ├── uniqueptr │ ├── CMakeLists.txt │ ├── bind │ │ ├── foo.cpp │ │ └── uptr.cpp │ ├── include │ │ └── foo.hpp │ ├── ref │ │ ├── ast │ │ │ ├── foo.json │ │ │ └── uptr.json │ │ └── uniqueptr-sys │ │ │ ├── Cargo.toml │ │ │ ├── build.rs │ │ │ ├── cppmm_abi_in │ │ │ └── cppmmabi.rs │ │ │ ├── src │ │ │ ├── cppmmabi.rs │ │ │ ├── foo.rs │ │ │ ├── lib.rs │ │ │ ├── test.rs │ │ │ └── uptr.rs │ │ │ └── uniqueptr-c │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen │ │ │ ├── CMakeLists.txt │ │ │ ├── abigen.cpp │ │ │ ├── foo.cpp │ │ │ ├── foo.hpp │ │ │ ├── insert_abi.py │ │ │ ├── uptr.cpp │ │ │ └── uptr.hpp │ │ │ ├── include.in │ │ │ ├── foo.h │ │ │ └── uptr.h │ │ │ ├── include │ │ │ ├── uniqueptr-api-export.h │ │ │ └── uniqueptr-errors.h │ │ │ ├── private │ │ │ ├── foo_private.h │ │ │ ├── uniqueptr-errors-private.h │ │ │ └── uptr_private.h │ │ │ └── src │ │ │ ├── foo.cpp │ │ │ ├── uniqueptr-errors.cpp │ │ │ └── uptr.cpp │ └── test.rs ├── updatetest.py └── usd │ ├── CMakeLists.txt │ ├── bind │ └── tftoken-c.cpp │ ├── ref-c │ ├── CMakeLists.txt │ ├── tftoken-c.cpp │ ├── tftoken-c.h │ └── tftoken-c_private.h │ ├── ref-sys │ ├── Cargo.toml │ ├── build.rs │ └── src │ │ ├── lib.rs │ │ └── tftoken_c.rs │ ├── ref │ ├── ast │ │ └── tftoken-c.json │ ├── usd-c │ │ ├── CMakeLists.txt │ │ ├── tftoken-c.cpp │ │ ├── tftoken-c.h │ │ └── tftoken-c_private.h │ └── usd-sys │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── build.rs │ │ └── src │ │ ├── lib.rs │ │ ├── test.rs │ │ └── tftoken_c.rs │ └── test-rust-sys │ └── test.rs └── tutorial ├── 01_simple_class ├── bind │ └── c-hello.cpp └── include │ └── hello.hpp ├── 02_customizing_methods ├── bind │ └── c-hello.cpp └── include │ └── hello.hpp ├── 03_math ├── bind │ └── c-math.cpp └── include │ └── math.hpp └── 04_templates ├── bind └── c-math.cpp └── include └── math.hpp /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | IndentWidth: 4 3 | AccessModifierOffset: -4 4 | AlignTrailingComments: true 5 | DerivePointerAlignment: false 6 | PointerAlignment: Left 7 | ... 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.vscode 3 | /.cache 4 | **/#*# 5 | /.clangd 6 | /compile_commands.json 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "spdlog"] 2 | path = spdlog 3 | url = git@github.com:gabime/spdlog.git 4 | [submodule "json"] 5 | path = json 6 | url = git@github.com:nlohmann/json.git 7 | [submodule "asttoc/fmt"] 8 | path = asttoc/fmt 9 | url = git@github.com:fmtlib/fmt.git 10 | -------------------------------------------------------------------------------- /astgen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(astgen 2 | src/astgen.cpp 3 | src/ast.cpp 4 | src/ast_utils.cpp 5 | src/pystring.cpp 6 | src/process_binding.cpp 7 | src/resources.cpp 8 | ) 9 | 10 | target_link_libraries(astgen 11 | clangTooling clangBasic clangASTMatchers 12 | spdlog::spdlog 13 | nlohmann_json::nlohmann_json) 14 | 15 | target_compile_definitions(astgen 16 | PRIVATE 17 | SPDLOG_ACTIVE_LEVEL=TRACE) 18 | 19 | target_include_directories(astgen 20 | PRIVATE 21 | ${LLVM_INCLUDE_DIRS}) 22 | 23 | install(TARGETS astgen DESTINATION ${CMAKE_INSTALL_BINDIR}) 24 | -------------------------------------------------------------------------------- /astgen/resources/invpcidintrin.h: -------------------------------------------------------------------------------- 1 | /*===------------- invpcidintrin.h - INVPCID intrinsic ---------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __IMMINTRIN_H 11 | #error "Never use directly; include instead." 12 | #endif 13 | 14 | #ifndef __INVPCIDINTRIN_H 15 | #define __INVPCIDINTRIN_H 16 | 17 | static __inline__ void 18 | __attribute__((__always_inline__, __nodebug__, __target__("invpcid"))) 19 | _invpcid(unsigned int __type, void *__descriptor) { 20 | __builtin_ia32_invpcid(__type, __descriptor); 21 | } 22 | 23 | #endif /* __INVPCIDINTRIN_H */ 24 | -------------------------------------------------------------------------------- /astgen/resources/iso646.h: -------------------------------------------------------------------------------- 1 | /*===---- iso646.h - Standard header for alternate spellings of operators---=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __ISO646_H 11 | #define __ISO646_H 12 | 13 | #ifndef __cplusplus 14 | #define and && 15 | #define and_eq &= 16 | #define bitand & 17 | #define bitor | 18 | #define compl ~ 19 | #define not ! 20 | #define not_eq != 21 | #define or || 22 | #define or_eq |= 23 | #define xor ^ 24 | #define xor_eq ^= 25 | #endif 26 | 27 | #endif /* __ISO646_H */ 28 | -------------------------------------------------------------------------------- /astgen/resources/nmmintrin.h: -------------------------------------------------------------------------------- 1 | /*===---- nmmintrin.h - SSE4 intrinsics ------------------------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __NMMINTRIN_H 11 | #define __NMMINTRIN_H 12 | 13 | /* To match expectations of gcc we put the sse4.2 definitions into smmintrin.h, 14 | just include it now then. */ 15 | #include 16 | #endif /* __NMMINTRIN_H */ 17 | -------------------------------------------------------------------------------- /astgen/resources/openmp_wrappers/cmath: -------------------------------------------------------------------------------- 1 | /*===-------------- cmath - Alternative cmath header -----------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #include <__clang_openmp_math.h> 11 | 12 | #ifndef __CLANG_NO_HOST_MATH__ 13 | #include_next 14 | #else 15 | #undef __CLANG_NO_HOST_MATH__ 16 | #endif 17 | -------------------------------------------------------------------------------- /astgen/resources/openmp_wrappers/math.h: -------------------------------------------------------------------------------- 1 | /*===------------- math.h - Alternative math.h header ----------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #include <__clang_openmp_math.h> 11 | 12 | #ifndef __CLANG_NO_HOST_MATH__ 13 | #include_next 14 | #else 15 | #undef __CLANG_NO_HOST_MATH__ 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /astgen/resources/s390intrin.h: -------------------------------------------------------------------------------- 1 | /*===---- s390intrin.h - SystemZ intrinsics --------------------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __S390INTRIN_H 11 | #define __S390INTRIN_H 12 | 13 | #ifndef __s390__ 14 | #error " is for s390 only" 15 | #endif 16 | 17 | #ifdef __HTM__ 18 | #include 19 | #endif 20 | 21 | #ifdef __VEC__ 22 | #include 23 | #endif 24 | 25 | #endif /* __S390INTRIN_H*/ 26 | -------------------------------------------------------------------------------- /astgen/resources/stdalign.h: -------------------------------------------------------------------------------- 1 | /*===---- stdalign.h - Standard header for alignment ------------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __STDALIGN_H 11 | #define __STDALIGN_H 12 | 13 | #ifndef __cplusplus 14 | #define alignas _Alignas 15 | #define alignof _Alignof 16 | #endif 17 | 18 | #define __alignas_is_defined 1 19 | #define __alignof_is_defined 1 20 | 21 | #endif /* __STDALIGN_H */ 22 | -------------------------------------------------------------------------------- /astgen/resources/stdnoreturn.h: -------------------------------------------------------------------------------- 1 | /*===---- stdnoreturn.h - Standard header for noreturn macro ---------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __STDNORETURN_H 11 | #define __STDNORETURN_H 12 | 13 | #define noreturn _Noreturn 14 | #define __noreturn_is_defined 1 15 | 16 | #endif /* __STDNORETURN_H */ 17 | -------------------------------------------------------------------------------- /astgen/resources/varargs.h: -------------------------------------------------------------------------------- 1 | /*===---- varargs.h - Variable argument handling -------------------------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | #ifndef __VARARGS_H 10 | #define __VARARGS_H 11 | #error "Please use instead of " 12 | #endif 13 | -------------------------------------------------------------------------------- /astgen/resources/wbnoinvdintrin.h: -------------------------------------------------------------------------------- 1 | /*===-------------- wbnoinvdintrin.h - wbnoinvd intrinsic-------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #if !defined __X86INTRIN_H && !defined __IMMINTRIN_H 11 | #error "Never use directly; include instead." 12 | #endif 13 | 14 | #ifndef __WBNOINVDINTRIN_H 15 | #define __WBNOINVDINTRIN_H 16 | 17 | static __inline__ void 18 | __attribute__((__always_inline__, __nodebug__, __target__("wbnoinvd"))) 19 | _wbnoinvd (void) 20 | { 21 | __builtin_ia32_wbnoinvd (); 22 | } 23 | 24 | #endif /* __WBNOINVDINTRIN_H */ 25 | -------------------------------------------------------------------------------- /astgen/resources/wmmintrin.h: -------------------------------------------------------------------------------- 1 | /*===---- wmmintrin.h - AES intrinsics ------------------------------------=== 2 | * 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 | * See https://llvm.org/LICENSE.txt for license information. 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | * 7 | *===-----------------------------------------------------------------------=== 8 | */ 9 | 10 | #ifndef __WMMINTRIN_H 11 | #define __WMMINTRIN_H 12 | 13 | #include 14 | 15 | #include <__wmmintrin_aes.h> 16 | 17 | #include <__wmmintrin_pclmul.h> 18 | 19 | #endif /* __WMMINTRIN_H */ 20 | -------------------------------------------------------------------------------- /astgen/src/ast_utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "clang/AST/Decl.h" 4 | #include "clang/AST/DeclCXX.h" 5 | #include "clang/AST/DeclTemplate.h" 6 | 7 | #include 8 | 9 | namespace cppmm { 10 | std::vector get_attrs(const clang::Decl* decl); 11 | std::string strip_name_kinds(std::string s); 12 | std::string get_record_name(const clang::CXXRecordDecl* crd); 13 | std::string get_namespace_path(const clang::DeclContext* dc); 14 | std::string mangle_decl(const clang::TagDecl* crd); 15 | std::string mangle_type(const clang::QualType& qt); 16 | std::vector 17 | mangle_template_args(const clang::TemplateArgumentList& args); 18 | std::string get_comment(const clang::Decl* decl); 19 | std::string get_comment_base64(const clang::Decl* decl); 20 | bool is_noexcept(const clang::FunctionDecl* fd); 21 | } // namespace cppmm 22 | -------------------------------------------------------------------------------- /astgen/src/resources.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | int num_files(); 4 | const char* cppmm_resource_array(int i); 5 | const char* cppmm_resource_filename(int i); 6 | -------------------------------------------------------------------------------- /asttoc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | add_subdirectory(fmt) 4 | 5 | add_executable(asttoc 6 | src/main.cpp 7 | src/pystring.cpp 8 | src/cppmm_ast_read.cpp 9 | src/cppmm_ast_add_c.cpp 10 | src/cppmm_ast_write_c.cpp 11 | src/cppmm_ast_write_cmake.cpp 12 | src/cppmm_ast_write_rustsys.cpp 13 | src/cppmm_ast.cpp 14 | ) 15 | 16 | target_include_directories(asttoc PRIVATE include) 17 | target_include_directories(asttoc PRIVATE fmt/include) 18 | target_include_directories(asttoc PRIVATE ${LLVM_INCLUDE_DIRS}) 19 | 20 | target_link_libraries(asttoc fmt spdlog::spdlog LLVMSupport) 21 | 22 | install(TARGETS asttoc DESTINATION ${CMAKE_INSTALL_BINDIR}) 23 | -------------------------------------------------------------------------------- /asttoc/README.md: -------------------------------------------------------------------------------- 1 | # To build 2 | Same as for cppmm 3 | 4 | # To run 5 | 6 | *Make sure you run it from inside the build folder* 7 | 8 | An example of how to run it. 9 | 10 | ``` 11 | cd build 12 | ./asttoc/asttoc -L /usr/local/loc -l Imath -o out ../test/imath/ref/ast 13 | ``` 14 | -------------------------------------------------------------------------------- /asttoc/include/cppmm_ast_add_c.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // vfx-rs 3 | //------------------------------------------------------------------------------ 4 | #pragma once 5 | #include "cppmm_ast.hpp" 6 | #include 7 | 8 | namespace cppmm { 9 | namespace transform { 10 | 11 | void add_c(const std::string& output_directory, Root& root); 12 | 13 | } // namespace transform 14 | } // namespace cppmm 15 | -------------------------------------------------------------------------------- /asttoc/include/cppmm_ast_read.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // vfx-rs 3 | //------------------------------------------------------------------------------ 4 | #pragma once 5 | #include "cppmm_ast.hpp" 6 | 7 | #include 8 | 9 | namespace cppmm { 10 | namespace read { 11 | Root json(const std::string& input); 12 | } // namespace read 13 | } // namespace cppmm 14 | -------------------------------------------------------------------------------- /asttoc/include/cppmm_ast_write_c.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // vfx-rs 3 | //------------------------------------------------------------------------------ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | 9 | namespace cppmm { 10 | class Root; 11 | 12 | namespace write { 13 | void c(const char* project_name, const Root& root, size_t starting_point, 14 | const char* output_dir, const std::string& api_prefix); 15 | void cerrors(const char* output_dir, Root& root, size_t starting_point, 16 | const char* project_name, const std::string& api_prefix); 17 | std::string capiexport(const char* output_dir, Root& root, size_t starting_point, 18 | const char* project_name); 19 | } // namespace write 20 | } // namespace cppmm 21 | -------------------------------------------------------------------------------- /asttoc/include/cppmm_ast_write_rustsys.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // vfx-rs 3 | //------------------------------------------------------------------------------ 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace cppmm { 11 | class Root; 12 | 13 | namespace rust_sys { 14 | void write(const char* out_dir, const char* project_name, const char* c_dir, 15 | const Root& root, size_t starting_point, 16 | const std::vector& libs, 17 | const std::vector& lib_dirs, int version_major, 18 | int version_minor, int version_patch); 19 | } // namespace rust_sys 20 | } // namespace cppmm 21 | -------------------------------------------------------------------------------- /asttoc/simple_test.c: -------------------------------------------------------------------------------- 1 | 2 | #include "imf_inputfile_.h" 3 | #include "imf_outputfile_.h" 4 | 5 | int main() 6 | { 7 | Imf_2_5_InputFile in; 8 | Imf_2_5_InputFile_InputFile(&in, 9 | "/Users/luke/Downloads/openexr-images-1.7.0/ScanLines/CandleGlass.exr", 10 | 1); 11 | 12 | Imf_2_5_OutputFile out; 13 | Imf_2_5_OutputFile_OutputFile(&out, "copy.exr", 14 | Imf_2_5_InputFile_header(&in), 1); 15 | 16 | Imf_2_5_OutputFile_copyPixels(&out, &in); 17 | 18 | Imf_2_5_OutputFile_dtor(&out); 19 | Imf_2_5_InputFile_dtor(&in); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /asttoc/src/cppmm_ast.cpp: -------------------------------------------------------------------------------- 1 | #include "cppmm_ast.hpp" 2 | 3 | namespace cppmm { 4 | 5 | std::map EXCEPTION_MAP; 6 | 7 | std::map> RECORD_MAP; 8 | std::map> TYPE_MAP; 9 | } // namespace cppmm 10 | -------------------------------------------------------------------------------- /genbind/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(genbind 2 | src/genbind.cpp 3 | src/pystring.cpp 4 | src/resources.cpp 5 | ) 6 | 7 | target_link_libraries(genbind clangTooling clangBasic clangASTMatchers spdlog::spdlog nlohmann_json::nlohmann_json) 8 | target_compile_definitions(genbind PRIVATE SPDLOG_ACTIVE_LEVEL=TRACE) 9 | target_include_directories(genbind PRIVATE ${LLVM_INCLUDE_DIRS}) 10 | 11 | install(TARGETS genbind DESTINATION ${CMAKE_INSTALL_BINDIR}) 12 | install(PROGRAMS src/genbind.py DESTINATION ${CMAKE_INSTALL_BINDIR}) 13 | -------------------------------------------------------------------------------- /genbind/src/resources.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | int num_files(); 4 | const char* cppmm_resource_array(int i); 5 | const char* cppmm_resource_filename(int i); 6 | -------------------------------------------------------------------------------- /include/cppmm_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CPPMM_MAJOR_VERSION 0 4 | #define CPPMM_MINOR_VERSION 11 5 | #define CPPMM_PATCH_VERSION 0 6 | 7 | namespace cppmm { 8 | 9 | inline const char* version() { 10 | return "0.11.0"; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /include/cppmm_config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CPPMM_MAJOR_VERSION @CPPMM_MAJOR_VERSION@ 4 | #define CPPMM_MINOR_VERSION @CPPMM_MINOR_VERSION@ 5 | #define CPPMM_PATCH_VERSION @CPPMM_PATCH_VERSION@ 6 | 7 | namespace cppmm { 8 | 9 | inline const char* version() { 10 | return "@CPPMM_VERSION@"; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /package.py: -------------------------------------------------------------------------------- 1 | name = 'cppmm' 2 | version = '0.11.0' 3 | 4 | def commands(): 5 | env.PATH.append('{root}/bin') 6 | -------------------------------------------------------------------------------- /package.py.in: -------------------------------------------------------------------------------- 1 | name = 'cppmm' 2 | version = '@CPPMM_VERSION@' 3 | 4 | def commands(): 5 | env.PATH.append('{root}/bin') 6 | -------------------------------------------------------------------------------- /test/array_params/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname array_params) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | -------------------------------------------------------------------------------- /test/array_params/bind/c-array_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace imath { 8 | 9 | template struct Matrix44 { 10 | using BoundType = ::imath::Matrix44; 11 | 12 | Matrix44(const T a[4][4]) CPPMM_RENAME(from_array); 13 | } CPPMM_VALUETYPE; 14 | 15 | template class Matrix44; 16 | using M44f = ::imath::Matrix44; 17 | 18 | } // namespace imath 19 | 20 | } // namespace cppmm_bind 21 | 22 | template class imath::Matrix44; 23 | -------------------------------------------------------------------------------- /test/array_params/include/array_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace imath { 4 | 5 | template struct Matrix44 { 6 | T data[4][4]; 7 | 8 | Matrix44(const T a[4][4]) { 9 | for (int r = 0; r < 4; ++r) { 10 | for (int c = 0; c < 4; ++c) { 11 | data[r][c] = a[r][c]; 12 | } 13 | } 14 | } 15 | }; 16 | 17 | } // namespace imath 18 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "array_params-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/array_params/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-array_params.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_array_params(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/abigen/c-array_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_array_params(std::ostream& os) { 5 | os << "imath::Matrix44" << "|" << sizeof(imath::Matrix44) << "|" << alignof(imath::Matrix44) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/abigen/c-array_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_array_params(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/include.in/c-array_params.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "array_params-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct imath__Matrix44_float__t_s { 10 | float data[4][4]; 11 | } ARRAY_PARAMS_CPPMM_ALIGN(4) imath__Matrix44_float__t; 12 | typedef imath__Matrix44_float__t imath_M44f_t; 13 | 14 | 15 | ARRAY_PARAMS_CPPMM_API unsigned int imath__Matrix44_float__from_array( 16 | imath_M44f_t * this_ 17 | , float a[4][4]); 18 | #define imath_M44f_from_array imath__Matrix44_float__from_array 19 | 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/include/array_params-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "array_params-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | ARRAY_PARAMS_CPPMM_API const char* array_params_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/private/array_params-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/src/array_params-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "array_params-errors.h" 2 | #include "array_params-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | ARRAY_PARAMS_CPPMM_API const char* array_params_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/array_params-c/src/c-array_params.cpp: -------------------------------------------------------------------------------- 1 | #include "c-array_params_private.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | ARRAY_PARAMS_CPPMM_API unsigned int imath__Matrix44_float__from_array( 8 | imath_M44f_t * this_ 9 | , float a[4][4]) 10 | { 11 | try { 12 | new (this_) imath::Matrix44(a); 13 | return 0; 14 | } catch (std::exception& e) { 15 | TLG_EXCEPTION_STRING = e.what(); 16 | return -1; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/array_params/ref/array_params-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/src/c_array_params.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C, align(4))] 10 | #[derive(Clone)] 11 | pub struct imath__Matrix44_float__t { 12 | pub data: *mut c_float, 13 | } 14 | 15 | 16 | 17 | extern "C" { 18 | 19 | pub fn imath__Matrix44_float__from_array(this_: *mut imath_M44f_t, a: *mut c_float) -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/array_params/ref/array_params-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/comments/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname comments) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/comments/bind/c-comments.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cppmm_bind { 5 | 6 | namespace comments { 7 | 8 | struct Class { 9 | using BoundType = ::comments::Class; 10 | void method() {} 11 | }; 12 | 13 | void function() {} 14 | 15 | } // namespace comments 16 | 17 | } // namespace cppmm_bind 18 | -------------------------------------------------------------------------------- /test/comments/include/comments.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace comments { 4 | 5 | /// A test class to make sure we can 6 | /// grab comments to be injected into C and Rust 7 | struct Class { 8 | 9 | /// This method doesn't do anything interesting at all 10 | void method() {} 11 | }; 12 | 13 | /// This is a free function that also does nothing interesting 14 | void function() {} 15 | 16 | } // namespace comments 17 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "comments-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/comments/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-comments.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_comments(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/abigen/c-comments.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_comments(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/abigen/c-comments.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_comments(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/include.in/c-comments.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "comments-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /** A test class to make sure we can 10 | grab comments to be injected into C and Rust */ 11 | typedef struct comments__Class_t_s { 12 | char _unused; 13 | } COMMENTS_CPPMM_ALIGN(1) comments__Class_t; 14 | typedef comments__Class_t comments_Class_t; 15 | 16 | 17 | /** This method doesn't do anything interesting at all */ 18 | COMMENTS_CPPMM_API unsigned int comments__Class_method( 19 | comments_Class_t * this_); 20 | #define comments_Class_method comments__Class_method 21 | 22 | 23 | /** This is a free function that also does nothing interesting */ 24 | COMMENTS_CPPMM_API unsigned int comments_function(); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/include/comments-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "comments-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | COMMENTS_CPPMM_API const char* comments_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/private/comments-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/src/c-comments.cpp: -------------------------------------------------------------------------------- 1 | #include "c-comments_private.h" 2 | 3 | 4 | #include 5 | 6 | COMMENTS_CPPMM_API unsigned int comments__Class_method( 7 | comments_Class_t * this_) 8 | { 9 | try { 10 | (to_cpp(this_)) -> method(); 11 | return 0; 12 | } catch (std::exception& e) { 13 | TLG_EXCEPTION_STRING = e.what(); 14 | return -1; 15 | } 16 | } 17 | 18 | COMMENTS_CPPMM_API unsigned int comments_function() 19 | { 20 | try { 21 | comments::function(); 22 | return 0; 23 | } catch (std::exception& e) { 24 | TLG_EXCEPTION_STRING = e.what(); 25 | return -1; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/comments-c/src/comments-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "comments-errors.h" 2 | #include "comments-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | COMMENTS_CPPMM_API const char* comments_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/comments/ref/comments-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/src/c_comments.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct comments__Class_t { 11 | _unused: [u8; 0], 12 | } 13 | 14 | 15 | extern "C" { 16 | 17 | pub fn comments__Class_method(this_: *mut comments_Class_t) -> Exception; 18 | 19 | pub fn comments_function() -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/comments/ref/comments-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/containers/ref/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(containers-c) 3 | 4 | add_library(containers-c STATIC 5 | containers_bind.cpp 6 | cppmm_containers.cpp 7 | ) 8 | 9 | target_compile_options(containers-c PRIVATE 10 | -fno-strict-aliasing 11 | ) 12 | 13 | target_include_directories(containers-c PUBLIC 14 | /home/anders/code/cppmm/test/containers/bind 15 | ) 16 | 17 | target_link_libraries(containers-c PUBLIC 18 | 19 | ) 20 | 21 | install(TARGETS containers-c DESTINATION ${CMAKE_INSTALL_PREFIX}) 22 | -------------------------------------------------------------------------------- /test/containers/ref/cppmm_containers.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cppmm_containers.h" 3 | #include 4 | #include 5 | 6 | namespace { 7 | #include "casts.h" 8 | 9 | CPPMM_DEFINE_POINTER_CASTS(std::vector, cppmm_string_vector); 10 | 11 | 12 | #undef CPPMM_DEFINE_POINTER_CASTS 13 | } 14 | 15 | extern "C" { 16 | 17 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index) { 18 | return (*to_cpp(vec))[index].c_str(); 19 | } 20 | 21 | int cppmm_string_vector_size(const cppmm_string_vector* vec) { 22 | return to_cpp(vec)->size(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/containers/ref/cppmm_containers.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | 16 | typedef struct { char _private[24]; } cppmm_string_vector CPPMM_ALIGN(8); 17 | 18 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index); 19 | int cppmm_string_vector_size(const cppmm_string_vector* vec); 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/containers/test-rust-sys/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use std::ffi::CStr; 3 | 4 | #[test] 5 | fn it_works() { 6 | unsafe { 7 | let mut vec = containers_Containers_returns_vec_string(); 8 | containers_Containers_takes_mut_vec_string_ref(&mut vec); 9 | containers_Containers_takes_const_vec_string_ref(&vec); 10 | for i in 0..cppmm_string_vector_size(&vec) { 11 | println!(" {}", CStr::from_ptr(cppmm_string_vector_get(&vec, i)).to_string_lossy().into_owned()); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/copymoveaccess/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname copymoveaccess) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/copymoveaccess/bind/cma.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cppmm_bind { 5 | 6 | namespace foo { 7 | 8 | struct PublicDerived { 9 | using BoundType = ::foo::PublicDerived; 10 | 11 | PublicDerived(const ::foo::PublicDerived&) CPPMM_MANUAL CPPMM_COPY_CTOR; 12 | }; 13 | 14 | // class PrivateDerived { using BoundType = ::foo::PrivateDerived; }; 15 | // class DeletedDerived { using BoundType = ::foo::DeletedDerived; }; 16 | 17 | } 18 | 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test/copymoveaccess/include/cma.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace foo { 4 | 5 | class PublicBase { 6 | public: 7 | // PublicBase(){} 8 | // PublicBase(const PublicBase&){}; 9 | // PublicBase(PublicBase&&){}; 10 | }; 11 | 12 | class PrivateBase { 13 | public: 14 | PrivateBase(){} 15 | 16 | private: 17 | PrivateBase(const PrivateBase&){}; 18 | PrivateBase(PrivateBase&&){}; 19 | }; 20 | 21 | class DeletedBase { 22 | public: 23 | DeletedBase(){} 24 | 25 | private: 26 | DeletedBase(const DeletedBase&)=delete; 27 | DeletedBase(DeletedBase&&)=delete; 28 | }; 29 | 30 | class PublicDerived: public PublicBase {}; 31 | class PrivateDerived: public PrivateBase {}; 32 | class DeletedDerived: public DeletedBase {}; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /test/cppmm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | #if defined(_WIN32) || defined(__CYGWIN__) 16 | #if defined(CPPMM_EXPORT) 17 | #define CPPMM_API __declspec(dllexport) 18 | #else 19 | #define CPPMM_API __declspec(dllimport) 20 | #endif 21 | #else 22 | #define CPPMM_API __attribute__((visbility("default"))) 23 | #endif 24 | 25 | struct cppmm_Vec_string { 26 | char _private[24]; 27 | } CPPMM_ALIGN(8); 28 | 29 | CPPMM_API int cppmm_Vec_string_size(cppmm_Vec_string* self); 30 | CPPMM_API const char* cppmm_Vec_string_get(cppmm_Vec_string* self, int index); 31 | CPPMM_API void cppmm_Vec_string_destroy(cppmm_Vec_string* self); 32 | 33 | 34 | #undef CPPMM_ALIGN 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /test/deep_namespace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname deep_namespace) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/deep_namespace/bind/c-dn.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cppmm_bind { 5 | 6 | namespace DN { 7 | 8 | namespace v2_2 { 9 | 10 | namespace DN = ::DN::v2_2; 11 | 12 | class Class { 13 | public: 14 | using BoundType = DN::Class; 15 | enum Enum { One, Two, Three }; 16 | 17 | struct Struct { 18 | using BoundType = DN::Class::Struct; 19 | void structMethod(); 20 | } CPPMM_VALUETYPE; 21 | }; 22 | 23 | void someFunction(); 24 | 25 | } // namespace v2_2 26 | 27 | } // namespace DN 28 | 29 | } // namespace cppmm_bind 30 | -------------------------------------------------------------------------------- /test/deep_namespace/include/dn.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace DN { 4 | 5 | namespace v2_2 { 6 | 7 | class Class { 8 | public: 9 | int i; 10 | float f; 11 | 12 | enum Enum { One, Two, Three }; 13 | 14 | struct Struct { 15 | int a; 16 | float b; 17 | void structMethod() {} 18 | }; 19 | }; 20 | 21 | void someFunction() {} 22 | 23 | } // namespace v2_2 24 | 25 | using namespace v2_2; 26 | 27 | } // namespace DN 28 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "deep_namespace-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/deep_namespace/ref/deep_namespace-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/deep_namespace/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-dn.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_dn(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/abigen/c-dn.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_dn(std::ostream& os) { 5 | os << "DN::v2_2::Class::Struct" << "|" << sizeof(DN::v2_2::Class::Struct) << "|" << alignof(DN::v2_2::Class::Struct) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/abigen/c-dn.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_dn(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/include/deep_namespace-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "deep_namespace-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | DEEP_NAMESPACE_CPPMM_API const char* deep_namespace_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/private/deep_namespace-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/src/c-dn.cpp: -------------------------------------------------------------------------------- 1 | #include "c-dn_private.h" 2 | 3 | 4 | #include 5 | 6 | DEEP_NAMESPACE_CPPMM_API unsigned int DN__v2_2__Class__Struct_structMethod( 7 | DN_Class_Struct_t * this_) 8 | { 9 | try { 10 | (to_cpp(this_)) -> structMethod(); 11 | return 0; 12 | } catch (std::exception& e) { 13 | TLG_EXCEPTION_STRING = e.what(); 14 | return -1; 15 | } 16 | } 17 | 18 | DEEP_NAMESPACE_CPPMM_API unsigned int DN_v2_2_someFunction() 19 | { 20 | try { 21 | DN::v2_2::someFunction(); 22 | return 0; 23 | } catch (std::exception& e) { 24 | TLG_EXCEPTION_STRING = e.what(); 25 | return -1; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/deep_namespace-c/src/deep_namespace-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "deep_namespace-errors.h" 2 | #include "deep_namespace-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | DEEP_NAMESPACE_CPPMM_API const char* deep_namespace_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/deep_namespace/ref/deep_namespace-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/deriveattr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname deriveattr) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/deriveattr/bind/dattr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace foo { 8 | 9 | struct Foo { 10 | using BoundType = ::foo::Foo; 11 | int bar; 12 | } CPPMM_VALUETYPE CPPMM_DERIVE("Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash"); 13 | 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/deriveattr/include/dattr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace foo { 4 | 5 | struct Foo { int bar; }; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "deriveattr-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/deriveattr/ref/deriveattr-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/deriveattr/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "dattr.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_dattr(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/abigen/dattr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_dattr(std::ostream& os) { 5 | os << "foo::Foo" << "|" << sizeof(foo::Foo) << "|" << alignof(foo::Foo) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/abigen/dattr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_dattr(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/include.in/dattr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "deriveattr-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct foo__Foo_t_s { 10 | int bar; 11 | } DERIVEATTR_CPPMM_ALIGN(4) foo__Foo_t; 12 | typedef foo__Foo_t foo_Foo_t; 13 | 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/include/deriveattr-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "deriveattr-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | DERIVEATTR_CPPMM_API const char* deriveattr_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/private/deriveattr-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/src/dattr.cpp: -------------------------------------------------------------------------------- 1 | #include "dattr_private.h" 2 | 3 | 4 | #include 5 | 6 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/deriveattr-c/src/deriveattr-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "deriveattr-errors.h" 2 | #include "deriveattr-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | DERIVEATTR_CPPMM_API const char* deriveattr_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/src/dattr.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C, align(4))] 10 | #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 11 | pub struct foo__Foo_t { 12 | pub bar: c_int, 13 | } 14 | 15 | 16 | 17 | extern "C" { 18 | 19 | 20 | } // extern "C" 21 | -------------------------------------------------------------------------------- /test/deriveattr/ref/deriveattr-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/diff.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # diff half-c ../test/half/ref 4 | # diff imath-c ../test/imath/ref 5 | diff oiio_min-c ../test/oiio_min/ref 6 | diff containers-c ../test/containers/ref 7 | diff templates-c ../test/templates/ref 8 | # diff usd-c ../test/usd/ref 9 | -------------------------------------------------------------------------------- /test/dtor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname dtor) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/dtor/bind/c-dtor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace dtor { 8 | 9 | struct Struct { 10 | using BoundType = ::dtor::Struct; 11 | Struct(); 12 | ~Struct(); 13 | } CPPMM_OPAQUEPTR; 14 | 15 | } // namespace dtor 16 | 17 | } // namespace cppmm_bind 18 | -------------------------------------------------------------------------------- /test/dtor/bind/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace std { 8 | 9 | class basic_string { 10 | public: 11 | using BoundType = ::std::string; 12 | 13 | basic_string() CPPMM_RENAME(ctor); 14 | ~basic_string() CPPMM_RENAME(dtor); 15 | basic_string(const ::std::string& rhs) CPPMM_RENAME(copy); 16 | 17 | ::std::string& assign(const char* s, ::std::string::size_type count); 18 | const char* c_str() const; 19 | 20 | } CPPMM_OPAQUEBYTES CPPMM_IGNORE_UNBOUND; 21 | 22 | using string = ::std::string; 23 | 24 | } // namespace std 25 | 26 | } // namespace cppmm_bind 27 | -------------------------------------------------------------------------------- /test/dtor/include/dtor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtor { 6 | 7 | struct Struct { 8 | uint64_t a; 9 | uint64_t b; 10 | std::string c; 11 | 12 | Struct() : a(1), b(2), c("") {} 13 | ~Struct() {} 14 | }; 15 | 16 | }; // namespace dtor 17 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "dtor-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(%ALIGNstd::__cxx11::basic_string%))] 2 | #[derive(Clone)] 3 | pub struct std____cxx11__basic_string_char__t { 4 | _inner: [u8; %SIZEstd::__cxx11::basic_string%] 5 | } 6 | 7 | impl Default for std____cxx11__basic_string_char__t { 8 | fn default() -> Self { 9 | Self { _inner: [0u8; %SIZEstd::__cxx11::basic_string%] } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/dtor/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-dtor.hpp" 4 | #include "std_string.hpp" 5 | 6 | int main() { 7 | std::ofstream os("abigen.txt"); 8 | 9 | abi_gen_c_dtor(os); 10 | abi_gen_std_string(os); 11 | } 12 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/c-dtor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_dtor(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/c-dtor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_dtor(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_std_string(std::ostream& os) { 5 | os << "std::__cxx11::basic_string" << "|" << sizeof(std::__cxx11::basic_string) << "|" << alignof(std::__cxx11::basic_string) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/abigen/std_string.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_std_string(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/include.in/c-dtor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "dtor-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct dtor__Struct_t_s { 10 | char _unused; 11 | } DTOR_CPPMM_ALIGN(8) dtor__Struct_t; 12 | typedef dtor__Struct_t dtor_Struct_t; 13 | 14 | 15 | DTOR_CPPMM_API unsigned int dtor__Struct_ctor( 16 | dtor_Struct_t * * this_); 17 | #define dtor_Struct_ctor dtor__Struct_ctor 18 | 19 | 20 | DTOR_CPPMM_API unsigned int dtor__Struct_dtor( 21 | dtor_Struct_t * this_); 22 | #define dtor_Struct_dtor dtor__Struct_dtor 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/include/dtor-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "dtor-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | DTOR_CPPMM_API const char* dtor_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/private/dtor-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/src/c-dtor.cpp: -------------------------------------------------------------------------------- 1 | #include "c-dtor_private.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | DTOR_CPPMM_API unsigned int dtor__Struct_ctor( 8 | dtor_Struct_t * * this_) 9 | { 10 | try { 11 | to_c(this_, new dtor::Struct()); 12 | return 0; 13 | } catch (std::exception& e) { 14 | TLG_EXCEPTION_STRING = e.what(); 15 | return -1; 16 | } 17 | } 18 | 19 | DTOR_CPPMM_API unsigned int dtor__Struct_dtor( 20 | dtor_Struct_t * this_) 21 | { 22 | try { 23 | delete to_cpp(this_); 24 | return 0; 25 | } catch (std::exception& e) { 26 | TLG_EXCEPTION_STRING = e.what(); 27 | return -1; 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/dtor-c/src/dtor-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "dtor-errors.h" 2 | #include "dtor-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | DTOR_CPPMM_API const char* dtor_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/src/c_dtor.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct dtor__Struct_t { 11 | _unused: [u8; 0], 12 | } 13 | 14 | 15 | extern "C" { 16 | 17 | pub fn dtor__Struct_ctor(this_: *mut *mut dtor_Struct_t) -> Exception; 18 | 19 | pub fn dtor__Struct_dtor(this_: *mut dtor_Struct_t) -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/dtor/ref/dtor-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use std::os::raw::c_void; 3 | 4 | #[repr(transparent)] 5 | pub struct Struct(pub *mut dtor_Struct_t); 6 | 7 | unsafe fn get_struct() -> Struct { 8 | let mut ptr = std::ptr::null_mut(); 9 | dtor_Struct_ctor(&mut ptr); 10 | Struct(ptr) 11 | } 12 | 13 | #[test] 14 | fn it_works() { 15 | unsafe { 16 | let mut s = get_struct(); 17 | dtor_Struct_dtor(s.0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/dtor/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use std::os::raw::c_void; 3 | 4 | #[repr(transparent)] 5 | pub struct Struct(pub *mut dtor_Struct_t); 6 | 7 | unsafe fn get_struct() -> Struct { 8 | let mut ptr = std::ptr::null_mut(); 9 | dtor_Struct_ctor(&mut ptr); 10 | Struct(ptr) 11 | } 12 | 13 | #[test] 14 | fn it_works() { 15 | unsafe { 16 | let mut s = get_struct(); 17 | dtor_Struct_dtor(s.0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/exceptions/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname exceptions) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/exceptions/bind/c-ex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace ex { 8 | 9 | struct Struct { 10 | using BoundType = ::ex::Struct; 11 | 12 | void m1() CPPMM_THROWS(std::runtime_error, STD_RUNTIME_ERROR); 13 | float m2(float a) CPPMM_THROWS(std::logic_error, STD_LOGIC_ERROR) 14 | CPPMM_THROWS(std::runtime_error, STD_RUNTIME_ERROR); 15 | float m3(int a) const; 16 | float m4(int a) const CPPMM_NOEXCEPT; 17 | } CPPMM_OPAQUEBYTES; 18 | 19 | float f1(int a) CPPMM_THROWS(std::invalid_argument, STD_INVALID_ARGUMENT); 20 | void f2() CPPMM_THROWS(std::invalid_argument, STD_INVALID_ARGUMENT); 21 | 22 | } // namespace ex 23 | 24 | } // namespace cppmm_bind 25 | -------------------------------------------------------------------------------- /test/exceptions/include/ex.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ex { 6 | 7 | struct Struct { 8 | 9 | void m1() { throw std::runtime_error("It's runtime, this is an error!"); } 10 | 11 | float m2(float b) { 12 | if (b < 0.0f) { 13 | throw std::runtime_error("It's runtime, this is an error!"); 14 | } else { 15 | throw std::logic_error( 16 | "Your logic is bad. And you should feel bad"); 17 | } 18 | } 19 | 20 | float m3(int a) const noexcept { return 1.0f; } 21 | float m4(int a) const { return 1.0f; } 22 | 23 | private: 24 | bool _first = true; 25 | }; 26 | 27 | float f1(int a) { 28 | throw std::invalid_argument("Your argument is invalid. I win."); 29 | } 30 | 31 | void f2() { throw std::invalid_argument("Your argument is invalid. I win."); } 32 | 33 | } // namespace ex 34 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "exceptions-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(%ALIGNex::Struct%))] 2 | #[derive(Clone)] 3 | pub struct ex__Struct_t { 4 | _inner: [u8; %SIZEex::Struct%] 5 | } 6 | 7 | impl Default for ex__Struct_t { 8 | fn default() -> Self { 9 | Self { _inner: [0u8; %SIZEex::Struct%] } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/exceptions/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-ex.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_ex(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/abigen/c-ex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_ex(std::ostream& os) { 5 | os << "ex::Struct" << "|" << sizeof(ex::Struct) << "|" << alignof(ex::Struct) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/abigen/c-ex.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_ex(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/include/exceptions-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "exceptions-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | EXCEPTIONS_CPPMM_API const char* exceptions_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/private/exceptions-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/exceptions-c/src/exceptions-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "exceptions-errors.h" 2 | #include "exceptions-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | EXCEPTIONS_CPPMM_API const char* exceptions_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/exceptions/ref/exceptions-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/exceptions/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let mut s = ex_Struct_t::default(); 6 | let f = 0.0f32; 7 | let mut r = 0.0f32; 8 | let i = 0i32; 9 | 10 | unsafe { 11 | assert_eq!( 12 | ex_Struct_m1(&mut s).into_result(), 13 | Err(Error::StdRuntimeError(String::from( 14 | "It's runtime, this is an error!" 15 | ))) 16 | ); 17 | 18 | assert_eq!( 19 | ex_Struct_m2(&mut s, &mut r, -1.0f32).into_result(), 20 | Err(Error::StdRuntimeError(String::from( 21 | "It's runtime, this is an error!" 22 | ))) 23 | ); 24 | 25 | assert_eq!( 26 | ex_Struct_m2(&mut s, &mut r, 1.0f32).into_result(), 27 | Err(Error::StdLogicError(String::from( 28 | "Your logic is bad. And you should feel bad" 29 | ))) 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/function_pointers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname function_pointers) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/function_pointers/bind/c-fptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace fptr { 8 | 9 | // typedef bool (*ProgressCallback)(void* opaque_data, float portion_done); 10 | using ProgressCallback = ::fptr::ProgressCallback; 11 | 12 | inline void takes_ages(::fptr::ProgressCallback cb, void* data); 13 | 14 | } // namespace fptr 15 | 16 | } // namespace cppmm_bind 17 | -------------------------------------------------------------------------------- /test/function_pointers/include/fptr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace fptr { 6 | 7 | typedef bool (*ProgressCallback)(void* opaque_data, float portion_done); 8 | 9 | inline void takes_ages(ProgressCallback cb, void* data) { 10 | const int steps = 10; 11 | for (int i = 0; i < steps + 1; ++i) { 12 | float pc = float(i) / float(steps); 13 | cb(data, pc); 14 | } 15 | } 16 | 17 | } // namespace fptr 18 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "function_pointers-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/function_pointers/ref/function_pointers-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/function_pointers/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-fptr.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_fptr(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/abigen/c-fptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_fptr(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/abigen/c-fptr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_fptr(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/include.in/c-fptr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "function_pointers-api-export.h" 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef _Bool (*fptr_ProgressCallback_t)(void * , float ); 11 | FUNCTION_POINTERS_CPPMM_API unsigned int fptr_takes_ages( 12 | fptr_ProgressCallback_t cb 13 | , void * data); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/include/function_pointers-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "function_pointers-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | FUNCTION_POINTERS_CPPMM_API const char* function_pointers_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/private/c-fptr_private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | #include "function_pointers-errors-private.h" 6 | 7 | #include 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/private/function_pointers-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/src/c-fptr.cpp: -------------------------------------------------------------------------------- 1 | #include "c-fptr_private.h" 2 | 3 | 4 | #include 5 | 6 | FUNCTION_POINTERS_CPPMM_API unsigned int fptr_takes_ages( 7 | fptr_ProgressCallback_t cb 8 | , void * data) 9 | { 10 | try { 11 | fptr::takes_ages(cb, data); 12 | return 0; 13 | } catch (std::exception& e) { 14 | TLG_EXCEPTION_STRING = e.what(); 15 | return -1; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/function_pointers-c/src/function_pointers-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "function_pointers-errors.h" 2 | #include "function_pointers-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | FUNCTION_POINTERS_CPPMM_API const char* function_pointers_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/src/c_fptr.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | 10 | 11 | extern "C" { 12 | 13 | pub fn fptr_takes_ages(cb: Option bool>, data: *mut c_void) -> Exception; 14 | 15 | 16 | } // extern "C" 17 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/function_pointers/ref/function_pointers-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use std::os::raw::c_void; 3 | 4 | struct CallbackData { 5 | pub pc: Vec, 6 | } 7 | 8 | extern "C" fn callback(data: *mut c_void, pc: f32) -> bool { 9 | unsafe { 10 | (*(data as *mut CallbackData)).pc.push(pc); 11 | } 12 | true 13 | } 14 | 15 | #[test] 16 | fn it_works() { 17 | let mut cb = Box::new(CallbackData { pc: Vec::new() }); 18 | unsafe { 19 | fptr_takes_ages( 20 | Some(callback), 21 | (&mut *cb) as *mut CallbackData as *mut c_void, 22 | ); 23 | } 24 | assert_eq!( 25 | cb.pc, 26 | [0.0f32, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /test/function_pointers/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | use std::os::raw::c_void; 3 | 4 | struct CallbackData { 5 | pub pc: Vec, 6 | } 7 | 8 | extern "C" fn callback(data: *mut c_void, pc: f32) -> bool { 9 | unsafe { 10 | (*(data as *mut CallbackData)).pc.push(pc); 11 | } 12 | true 13 | } 14 | 15 | #[test] 16 | fn it_works() { 17 | let mut cb = Box::new(CallbackData { pc: Vec::new() }); 18 | unsafe { 19 | fptr_takes_ages( 20 | Some(callback), 21 | (&mut *cb) as *mut CallbackData as *mut c_void, 22 | ); 23 | } 24 | assert_eq!( 25 | cb.pc, 26 | [0.0f32, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0] 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /test/half/ref/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(half-c) 3 | 4 | add_library(half-c STATIC 5 | half.cpp 6 | cppmm_containers.cpp 7 | ) 8 | 9 | target_compile_options(half-c PRIVATE 10 | -fno-strict-aliasing 11 | ) 12 | 13 | target_include_directories(half-c PUBLIC 14 | /home/anders/packages/imath/3.0.0/include 15 | ) 16 | 17 | target_link_libraries(half-c PUBLIC 18 | /home/anders/packages/imath/3.0.0/lib/libhalf.so 19 | ) 20 | 21 | install(TARGETS half-c DESTINATION ${CMAKE_INSTALL_PREFIX}) 22 | -------------------------------------------------------------------------------- /test/half/ref/cppmm_containers.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cppmm_containers.h" 3 | #include 4 | #include 5 | 6 | namespace { 7 | #include "casts.h" 8 | 9 | CPPMM_DEFINE_POINTER_CASTS(std::vector, cppmm_string_vector); 10 | 11 | 12 | #undef CPPMM_DEFINE_POINTER_CASTS 13 | } 14 | 15 | extern "C" { 16 | 17 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index) { 18 | return (*to_cpp(vec))[index].c_str(); 19 | } 20 | 21 | int cppmm_string_vector_size(const cppmm_string_vector* vec) { 22 | return to_cpp(vec)->size(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/half/ref/cppmm_containers.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | 16 | typedef struct { char _private[24]; } cppmm_string_vector CPPMM_ALIGN(8); 17 | 18 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index); 19 | int cppmm_string_vector_size(const cppmm_string_vector* vec); 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/imath/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname imath) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I$ENV{OPENEXR_ROOT}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "imath-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/imath/ref/imath-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/packages/openexr/2.5.5/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "imath_vec.hpp" 4 | #include "imath_box.hpp" 5 | 6 | int main() { 7 | std::ofstream os("abigen.txt"); 8 | 9 | abi_gen_imath_vec(os); 10 | abi_gen_imath_box(os); 11 | } 12 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/imath_box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_imath_box(std::ostream& os) { 5 | os << "Imath_2_5::Box >" << "|" << sizeof(Imath_2_5::Box >) << "|" << alignof(Imath_2_5::Box >) << "\n"; 6 | os << "Imath_2_5::Box >" << "|" << sizeof(Imath_2_5::Box >) << "|" << alignof(Imath_2_5::Box >) << "\n"; 7 | } 8 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/imath_box.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_imath_box(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/imath_vec.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_imath_vec(std::ostream& os) { 6 | os << "Imath_2_5::Vec3" << "|" << sizeof(Imath_2_5::Vec3) << "|" << alignof(Imath_2_5::Vec3) << "\n"; 7 | os << "Imath_2_5::Vec3" << "|" << sizeof(Imath_2_5::Vec3) << "|" << alignof(Imath_2_5::Vec3) << "\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/abigen/imath_vec.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_imath_vec(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/include/imath-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "imath-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | IMATH_CPPMM_API const char* imath_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/private/imath-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/imath-c/src/imath-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "imath-errors.h" 2 | #include "imath-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | IMATH_CPPMM_API const char* imath_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/imath/ref/imath-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/mimpl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname mimpl) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/mimpl/bind/mimpl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cppmm_bind { 5 | namespace mimpl { 6 | 7 | struct Number { 8 | using BoundType = ::mimpl::Number; 9 | 10 | int _number; 11 | 12 | Number(); 13 | int get_number() const; 14 | 15 | } CPPMM_OPAQUEPTR; 16 | 17 | } 18 | 19 | int Number_do_get_number(const ::mimpl::Number& self) CPPMM_IMPL { 20 | return self.get_number(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /test/mimpl/include/mimpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace mimpl { 4 | 5 | class Number { 6 | int _number; 7 | 8 | public: 9 | Number() : _number(42) {} 10 | 11 | int get_number() const { return _number; } 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "mimpl-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/mimpl/ref/mimpl-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/mimpl/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "mimpl.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_mimpl(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/abigen/mimpl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_mimpl(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/abigen/mimpl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_mimpl(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/include.in/mimpl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "mimpl-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct mimpl__Number_t_s { 10 | char _unused; 11 | } MIMPL_CPPMM_ALIGN(4) mimpl__Number_t; 12 | typedef mimpl__Number_t mimpl_Number_t; 13 | 14 | 15 | MIMPL_CPPMM_API unsigned int mimpl__Number_ctor( 16 | mimpl_Number_t * * this_); 17 | #define mimpl_Number_ctor mimpl__Number_ctor 18 | 19 | 20 | MIMPL_CPPMM_API unsigned int mimpl__Number_get_number( 21 | mimpl_Number_t const * this_ 22 | , int * return_); 23 | #define mimpl_Number_get_number mimpl__Number_get_number 24 | 25 | 26 | MIMPL_CPPMM_API unsigned int Number_do_get_number( 27 | int * return_ 28 | , mimpl_Number_t const * self); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/include/mimpl-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mimpl-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | MIMPL_CPPMM_API const char* mimpl_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/private/mimpl-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/mimpl-c/src/mimpl-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "mimpl-errors.h" 2 | #include "mimpl-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | MIMPL_CPPMM_API const char* mimpl_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/src/mimpl.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct mimpl__Number_t { 11 | _unused: [u8; 0], 12 | } 13 | 14 | 15 | extern "C" { 16 | 17 | pub fn mimpl__Number_ctor(this_: *mut *mut mimpl_Number_t) -> Exception; 18 | 19 | pub fn mimpl__Number_get_number(this_: *const mimpl_Number_t, return_: *mut c_int) -> Exception; 20 | 21 | pub fn Number_do_get_number(return_: *mut c_int, self_: *const mimpl_Number_t) -> Exception; 22 | 23 | 24 | } // extern "C" 25 | -------------------------------------------------------------------------------- /test/mimpl/ref/mimpl-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/nested/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname nested) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/nested/bind/a/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace nest { 8 | 9 | struct NestAE { 10 | using BoundType = ::nest::NestAE; 11 | 12 | int a; 13 | 14 | void do_something() {} 15 | } CPPMM_VALUETYPE; 16 | 17 | } // namespace nest 18 | 19 | } // namespace cppmm_bind 20 | -------------------------------------------------------------------------------- /test/nested/bind/b/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace nest { 8 | 9 | struct NestBE { 10 | using BoundType = ::nest::NestBE; 11 | 12 | int b; 13 | 14 | void do_something() {} 15 | } CPPMM_VALUETYPE; 16 | 17 | } // namespace nest 18 | 19 | } // namespace cppmm_bind 20 | -------------------------------------------------------------------------------- /test/nested/bind/c/d/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace nest { 8 | 9 | struct NestCDE { 10 | using BoundType = ::nest::NestCDE; 11 | 12 | int cd; 13 | 14 | void do_something() {} 15 | } CPPMM_VALUETYPE; 16 | 17 | } // namespace nest 18 | 19 | } // namespace cppmm_bind 20 | -------------------------------------------------------------------------------- /test/nested/include/a/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nest { 4 | 5 | struct NestAE { 6 | int a; 7 | 8 | void do_something() {} 9 | }; 10 | 11 | } // namespace nest 12 | -------------------------------------------------------------------------------- /test/nested/include/b/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nest { 4 | 5 | struct NestBE { 6 | int b; 7 | 8 | void do_something() {} 9 | }; 10 | 11 | } // namespace nest 12 | -------------------------------------------------------------------------------- /test/nested/include/c/d/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace nest { 4 | 5 | struct NestCDE { 6 | int cd; 7 | 8 | void do_something() {} 9 | }; 10 | 11 | } // namespace nest 12 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "nested-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/nested/ref/nested-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/nested/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/a/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_a_neste(std::ostream& os) { 5 | os << "nest::NestAE" << "|" << sizeof(nest::NestAE) << "|" << alignof(nest::NestAE) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/a/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_a_neste(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "a/neste.hpp" 4 | #include "b/neste.hpp" 5 | #include "c/d/neste.hpp" 6 | 7 | int main() { 8 | std::ofstream os("abigen.txt"); 9 | 10 | abi_gen_a_neste(os); 11 | abi_gen_b_neste(os); 12 | abi_gen_c_d_neste(os); 13 | } 14 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/b/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_b_neste(std::ostream& os) { 5 | os << "nest::NestBE" << "|" << sizeof(nest::NestBE) << "|" << alignof(nest::NestBE) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/b/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_b_neste(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/c/d/neste.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_d_neste(std::ostream& os) { 5 | os << "nest::NestCDE" << "|" << sizeof(nest::NestCDE) << "|" << alignof(nest::NestCDE) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/abigen/c/d/neste.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_d_neste(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/include.in/a/neste.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nested-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct nest__NestAE_t_s { 10 | int a; 11 | } NESTED_CPPMM_ALIGN(4) nest__NestAE_t; 12 | typedef nest__NestAE_t nest_NestAE_t; 13 | 14 | 15 | NESTED_CPPMM_API unsigned int nest__NestAE_do_something( 16 | nest_NestAE_t * this_); 17 | #define nest_NestAE_do_something nest__NestAE_do_something 18 | 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/include.in/b/neste.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nested-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct nest__NestBE_t_s { 10 | int b; 11 | } NESTED_CPPMM_ALIGN(4) nest__NestBE_t; 12 | typedef nest__NestBE_t nest_NestBE_t; 13 | 14 | 15 | NESTED_CPPMM_API unsigned int nest__NestBE_do_something( 16 | nest_NestBE_t * this_); 17 | #define nest_NestBE_do_something nest__NestBE_do_something 18 | 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/include.in/c/d/neste.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "nested-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct nest__NestCDE_t_s { 10 | int cd; 11 | } NESTED_CPPMM_ALIGN(4) nest__NestCDE_t; 12 | typedef nest__NestCDE_t nest_NestCDE_t; 13 | 14 | 15 | NESTED_CPPMM_API unsigned int nest__NestCDE_do_something( 16 | nest_NestCDE_t * this_); 17 | #define nest_NestCDE_do_something nest__NestCDE_do_something 18 | 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/include/nested-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "nested-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | NESTED_CPPMM_API const char* nested_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/private/nested-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/src/a/neste.cpp: -------------------------------------------------------------------------------- 1 | #include "a/neste_private.h" 2 | 3 | 4 | #include 5 | 6 | NESTED_CPPMM_API unsigned int nest__NestAE_do_something( 7 | nest_NestAE_t * this_) 8 | { 9 | try { 10 | (to_cpp(this_)) -> do_something(); 11 | return 0; 12 | } catch (std::exception& e) { 13 | TLG_EXCEPTION_STRING = e.what(); 14 | return -1; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/src/b/neste.cpp: -------------------------------------------------------------------------------- 1 | #include "b/neste_private.h" 2 | 3 | 4 | #include 5 | 6 | NESTED_CPPMM_API unsigned int nest__NestBE_do_something( 7 | nest_NestBE_t * this_) 8 | { 9 | try { 10 | (to_cpp(this_)) -> do_something(); 11 | return 0; 12 | } catch (std::exception& e) { 13 | TLG_EXCEPTION_STRING = e.what(); 14 | return -1; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/src/c/d/neste.cpp: -------------------------------------------------------------------------------- 1 | #include "c/d/neste_private.h" 2 | 3 | 4 | #include 5 | 6 | NESTED_CPPMM_API unsigned int nest__NestCDE_do_something( 7 | nest_NestCDE_t * this_) 8 | { 9 | try { 10 | (to_cpp(this_)) -> do_something(); 11 | return 0; 12 | } catch (std::exception& e) { 13 | TLG_EXCEPTION_STRING = e.what(); 14 | return -1; 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/nested-c/src/nested-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "nested-errors.h" 2 | #include "nested-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | NESTED_CPPMM_API const char* nested_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/a/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod neste; 2 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/a/neste.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C, align(4))] 10 | #[derive(Clone)] 11 | pub struct nest__NestAE_t { 12 | pub a: c_int, 13 | } 14 | 15 | 16 | 17 | extern "C" { 18 | 19 | pub fn nest__NestAE_do_something(this_: *mut nest_NestAE_t) -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/b/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod neste; 2 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/b/neste.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C, align(4))] 10 | #[derive(Clone)] 11 | pub struct nest__NestBE_t { 12 | pub b: c_int, 13 | } 14 | 15 | 16 | 17 | extern "C" { 18 | 19 | pub fn nest__NestBE_do_something(this_: *mut nest_NestBE_t) -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/c/d/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod neste; 2 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/c/d/neste.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C, align(4))] 10 | #[derive(Clone)] 11 | pub struct nest__NestCDE_t { 12 | pub cd: c_int, 13 | } 14 | 15 | 16 | 17 | extern "C" { 18 | 19 | pub fn nest__NestCDE_do_something(this_: *mut nest_NestCDE_t) -> Exception; 20 | 21 | 22 | } // extern "C" 23 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/c/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod d; 2 | pub use d::*; 3 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/nested/ref/nested-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/oiio.old/bind/c-typedesc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define CPPMM_IGNORE __attribute__((annotate("cppmm:ignore"))) 4 | #define CPPMM_RENAME(x) __attribute__((annotate("cppmm:rename:" #x))) 5 | #define CPPMM_MANUAL(x) __attribute__((annotate("cppmm:manual:" #x))) 6 | 7 | #define CPPMM_OPAQUEPTR __attribute__((annotate("cppmm:opaqueptr"))) 8 | #define CPPMM_VALUETYPE __attribute__((annotate("cppmm:valuetype"))) 9 | 10 | namespace cppmm_bind { 11 | namespace OIIO_NAMESPACE { 12 | 13 | // alias the main library namespace with a convenient short form here 14 | namespace OIIO = ::OIIO_NAMESPACE; 15 | 16 | struct TypeDesc { 17 | enum BASETYPE {}; 18 | enum AGGREGATE {}; 19 | enum VECSEMANTICS {}; 20 | 21 | } CPPMM_VALUETYPE; 22 | 23 | } // namespace OIIO 24 | } // namespace cppmm_bind 25 | -------------------------------------------------------------------------------- /test/oiio.old/ref/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(oiio_min-c) 3 | 4 | add_library(oiio_min-c STATIC 5 | c-filesystem.cpp 6 | c-typedesc.cpp 7 | c-imageio.cpp 8 | cppmm_containers.cpp 9 | ) 10 | 11 | target_compile_options(oiio_min-c PRIVATE 12 | -fno-strict-aliasing 13 | ) 14 | 15 | target_include_directories(oiio_min-c PUBLIC 16 | /home/anders/packages/oiio/2.2.8/include 17 | /home/anders/packages/openexr/2.4.0/include 18 | ) 19 | 20 | target_link_libraries(oiio_min-c PUBLIC 21 | /home/anders/packages/oiio/2.2.8/lib/libOpenImageIO.so 22 | ) 23 | 24 | install(TARGETS oiio_min-c DESTINATION ${CMAKE_INSTALL_PREFIX}) 25 | -------------------------------------------------------------------------------- /test/oiio.old/ref/cppmm_containers.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cppmm_containers.h" 3 | #include 4 | #include 5 | 6 | namespace { 7 | #include "casts.h" 8 | 9 | CPPMM_DEFINE_POINTER_CASTS(std::vector, cppmm_string_vector); 10 | 11 | 12 | #undef CPPMM_DEFINE_POINTER_CASTS 13 | } 14 | 15 | extern "C" { 16 | 17 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index) { 18 | return (*to_cpp(vec))[index].c_str(); 19 | } 20 | 21 | int cppmm_string_vector_size(const cppmm_string_vector* vec) { 22 | return to_cpp(vec)->size(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/oiio.old/ref/cppmm_containers.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | 16 | typedef struct { char _private[24]; } cppmm_string_vector CPPMM_ALIGN(8); 17 | 18 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index); 19 | int cppmm_string_vector_size(const cppmm_string_vector* vec); 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/oiio.old/test_filesystem.c: -------------------------------------------------------------------------------- 1 | #include "c-filesystem.h" 2 | #include "cppmm.h" 3 | 4 | void main(void) { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /test/oiio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname oiio) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I$ENV{OIIO_ROOT}/include 14 | -I$ENV{OPENEXR_ROOT}/include 15 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 16 | ) 17 | -------------------------------------------------------------------------------- /test/oiio/bind/c-typedesc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | namespace OIIO_NAMESPACE { 7 | 8 | // alias the main library namespace with a convenient short form here 9 | namespace OIIO = ::OIIO_NAMESPACE; 10 | 11 | struct TypeDesc { 12 | using BoundType = OIIO::TypeDesc; 13 | 14 | enum BASETYPE {}; 15 | enum AGGREGATE {}; 16 | enum VECSEMANTICS {}; 17 | 18 | } CPPMM_VALUETYPE; 19 | 20 | } // namespace OIIO_NAMESPACE 21 | } // namespace cppmm_bind 22 | -------------------------------------------------------------------------------- /test/oiio/bind/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace std { 8 | 9 | class basic_string { 10 | public: 11 | using BoundType = ::std::string; 12 | 13 | basic_string(); 14 | basic_string(const ::std::string & rhs); 15 | 16 | ::std::string& assign(const char* s, ::std::string::size_type count); 17 | const char* c_str() const; 18 | 19 | } CPPMM_OPAQUEBYTES; 20 | 21 | using string = ::std::string; 22 | 23 | } // namespace std 24 | 25 | } // namespace cppmm_bind 26 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(oiio-c VERSION 0.1.0) 3 | set(CMAKE_CXX_STANDARD 14 CACHE STRING "") 4 | set(LIBNAME oiio-c-0_1) 5 | add_library(${LIBNAME} SHARED 6 | std_vector.cpp 7 | c-filesystem.cpp 8 | c-typedesc.cpp 9 | c-imageio.cpp 10 | std_string.cpp 11 | ) 12 | target_include_directories(${LIBNAME} PRIVATE .) 13 | target_include_directories(${LIBNAME} PRIVATE /home/anders/packages/oiio/2.2.8/include) 14 | target_include_directories(${LIBNAME} PRIVATE /home/anders/packages/openexr/2.5.5/include) 15 | install(TARGETS ${LIBNAME} DESTINATION ${CMAKE_INSTALL_PREFIX}) -------------------------------------------------------------------------------- /test/oiio/ref/oiio-c/c-typedesc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-c/std_vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | unsigned int std__vector_std__string__vector( 6 | std_vector_string_t * * this_) 7 | { 8 | try { 9 | to_c(this_, new std::vector()); 10 | return 0; 11 | } catch (std::exception& e) { 12 | return -1; 13 | } 14 | } 15 | unsigned int std__vector_std__string__dtor( 16 | std_vector_string_t * this_) 17 | { 18 | try { 19 | delete to_cpp(this_); 20 | return 0; 21 | } catch (std::exception& e) { 22 | return -1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-c/std_vector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | typedef struct std__vector_std__string__t_s { 8 | char _unused; 9 | } __attribute__((aligned(8))) std__vector_std__string__t; 10 | typedef std__vector_std__string__t std_vector_string_t; 11 | 12 | 13 | 14 | unsigned int std__vector_std__string__vector( 15 | std_vector_string_t * * this_); 16 | #define std_vector_string_vector std__vector_std__string__vector 17 | 18 | 19 | unsigned int std__vector_std__string__dtor( 20 | std_vector_string_t * this_); 21 | #define std_vector_string_dtor std__vector_std__string__dtor 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "oiio-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | 11 | [dependencies] 12 | thiserror = "^1.0" 13 | 14 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-sys/build.rs: -------------------------------------------------------------------------------- 1 | 2 | fn main() { 3 | let dst = cmake::Config::new("/home/anders/code/cppmm/build/test/oiio/output/oiio-c").build(); 4 | println!("cargo:rustc-link-search=native={}", dst.display()); 5 | println!("cargo:rustc-link-lib=dylib=oiio-c-0_1"); 6 | 7 | 8 | #[cfg(target_os = "linux")] 9 | println!("cargo:rustc-link-lib=dylib=stdc++"); 10 | #[cfg(target_os = "macos")] 11 | println!("cargo:rustc-link-lib=dylib=c++"); 12 | } 13 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-sys/src/std_string.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | use std::os::raw::*; 7 | 8 | #[repr(C)] 9 | pub struct std____cxx11__basic_string_char__t { 10 | _unused: [u8; 0], 11 | } 12 | 13 | 14 | extern "C" { 15 | 16 | pub fn std____cxx11__basic_string_char__basic_string(this_: *mut *mut std___cxx11_string_t) -> Exception; 17 | 18 | pub fn std____cxx11__basic_string_char__basic_string_1(this_: *mut *mut std___cxx11_string_t, rhs: *const std___cxx11_string_t) -> Exception; 19 | 20 | pub fn std____cxx11__basic_string_char__assign(this_: *mut std___cxx11_string_t, return_: *mut *mut std___cxx11_string_t, s: *const c_char, count: c_ulong) -> Exception; 21 | 22 | pub fn std____cxx11__basic_string_char__c_str(this_: *const std___cxx11_string_t, return_: *mut *const c_char) -> Exception; 23 | 24 | 25 | } // extern "C" 26 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-sys/src/std_vector.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | use std::os::raw::*; 7 | 8 | #[repr(C)] 9 | pub struct std__vector_std__string__t { 10 | _unused: [u8; 0], 11 | } 12 | 13 | 14 | extern "C" { 15 | 16 | pub fn std__vector_std__string__vector(this_: *mut *mut std_vector_string_t) -> Exception; 17 | 18 | pub fn std__vector_std__string__dtor(this_: *mut std_vector_string_t) -> Exception; 19 | 20 | 21 | } // extern "C" 22 | -------------------------------------------------------------------------------- /test/oiio/ref/oiio-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/opaquebytes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname opaquebytes) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /test/opaquebytes/bind/obyte.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace cppmm_bind { 5 | 6 | namespace obyte { 7 | 8 | struct Foo { 9 | using BoundType = ::obyte::Foo; 10 | } CPPMM_OPAQUEBYTES; 11 | 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /test/opaquebytes/include/obyte.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace obyte { 8 | 9 | struct Foo { 10 | std::string a; 11 | std::vector b; 12 | std::map c; 13 | }; 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "opaquebytes-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(%ALIGNobyte::Foo%))] 2 | #[derive(Clone)] 3 | pub struct obyte__Foo_t { 4 | _inner: [u8; %SIZEobyte::Foo%] 5 | } 6 | 7 | impl Default for obyte__Foo_t { 8 | fn default() -> Self { 9 | Self { _inner: [0u8; %SIZEobyte::Foo%] } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/opaquebytes/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "obyte.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_obyte(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/abigen/obyte.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_obyte(std::ostream& os) { 5 | os << "obyte::Foo" << "|" << sizeof(obyte::Foo) << "|" << alignof(obyte::Foo) << "\n"; 6 | } 7 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/abigen/obyte.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_obyte(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/include.in/obyte.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "opaquebytes-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct obyte__Foo_t_s { 10 | char data[%SIZEobyte::Foo%]; 11 | } OPAQUEBYTES_CPPMM_ALIGN(%ALIGNobyte::Foo%) obyte__Foo_t; 12 | typedef obyte__Foo_t obyte_Foo_t; 13 | 14 | 15 | /** returns the size of this type in bytes */ 16 | OPAQUEBYTES_CPPMM_API unsigned int obyte__Foo_sizeof(); 17 | #define obyte_Foo_sizeof obyte__Foo_sizeof 18 | 19 | 20 | /** returns the size of this type in bytes */ 21 | OPAQUEBYTES_CPPMM_API unsigned int obyte__Foo_alignof(); 22 | #define obyte_Foo_alignof obyte__Foo_alignof 23 | 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/include/opaquebytes-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "opaquebytes-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | OPAQUEBYTES_CPPMM_API const char* opaquebytes_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/private/opaquebytes-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/src/obyte.cpp: -------------------------------------------------------------------------------- 1 | #include "obyte_private.h" 2 | 3 | 4 | #include 5 | 6 | OPAQUEBYTES_CPPMM_API unsigned int obyte__Foo_sizeof() 7 | { 8 | return sizeof(obyte::Foo); 9 | } 10 | 11 | OPAQUEBYTES_CPPMM_API unsigned int obyte__Foo_alignof() 12 | { 13 | return alignof(obyte::Foo); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/opaquebytes-c/src/opaquebytes-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "opaquebytes-errors.h" 2 | #include "opaquebytes-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | OPAQUEBYTES_CPPMM_API const char* opaquebytes_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/src/obyte.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | 10 | impl obyte__Foo_t { 11 | pub fn layout() -> std::alloc::Layout { 12 | unsafe { 13 | std::alloc::Layout::from_size_align( 14 | obyte__Foo_sizeof(), 15 | obyte__Foo_alignof(), 16 | ).unwrap() 17 | } 18 | } 19 | } 20 | 21 | 22 | 23 | extern "C" { 24 | 25 | pub fn obyte__Foo_sizeof() -> usize; 26 | 27 | pub fn obyte__Foo_alignof() -> usize; 28 | 29 | 30 | } // extern "C" 31 | -------------------------------------------------------------------------------- /test/opaquebytes/ref/opaquebytes-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/opaqueptr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname opaqueptr) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/opaqueptr/bind/c-optr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace optr { 8 | 9 | struct PubCtor { 10 | using BoundType = ::optr::PubCtor; 11 | 12 | PubCtor() CPPMM_RENAME(ctor); 13 | ~PubCtor(); 14 | 15 | void doit(); 16 | 17 | } CPPMM_OPAQUEPTR; 18 | 19 | struct PrvCtor { 20 | using BoundType = ::optr::PrvCtor; 21 | void doit(); 22 | }; 23 | 24 | struct AllPrv { 25 | using BoundType = ::optr::AllPrv; 26 | }; 27 | 28 | struct Opaque { 29 | using BoundType = ::optr::Opaque; 30 | } CPPMM_OPAQUETYPE; 31 | 32 | } // namespace optr 33 | 34 | } // namespace cppmm_bind 35 | -------------------------------------------------------------------------------- /test/opaqueptr/include/optr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace optr { 4 | 5 | struct PubCtor { 6 | PubCtor(); 7 | ~PubCtor(); 8 | 9 | void doit() {} 10 | }; 11 | 12 | class PrvCtor { 13 | PrvCtor(); 14 | ~PrvCtor(); 15 | 16 | public: 17 | void doit() {} 18 | }; 19 | 20 | class AllPrv { 21 | AllPrv(); 22 | ~AllPrv(); 23 | 24 | void doit() {} 25 | }; 26 | 27 | class Opaque; 28 | 29 | } // namespace optr 30 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "opaqueptr-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/opaqueptr/ref/opaqueptr-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/opaqueptr/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-optr.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_optr(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/abigen/c-optr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_optr(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/abigen/c-optr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_optr(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/include/opaqueptr-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "opaqueptr-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | OPAQUEPTR_CPPMM_API const char* opaqueptr_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/private/opaqueptr-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/opaqueptr-c/src/opaqueptr-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "opaqueptr-errors.h" 2 | #include "opaqueptr-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | OPAQUEPTR_CPPMM_API const char* opaqueptr_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/src/c_optr.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct optr__PubCtor_t { 11 | _unused: [u8; 0], 12 | } 13 | #[repr(C)] 14 | pub struct optr__PrvCtor_t { 15 | _unused: [u8; 0], 16 | } 17 | #[repr(C)] 18 | pub struct optr__AllPrv_t { 19 | _unused: [u8; 0], 20 | } 21 | #[repr(C)] 22 | pub struct optr__Opaque_t { 23 | _unused: [u8; 0], 24 | } 25 | 26 | 27 | extern "C" { 28 | 29 | pub fn optr__PubCtor_ctor(this_: *mut *mut optr_PubCtor_t) -> Exception; 30 | 31 | pub fn optr__PubCtor_dtor(this_: *mut optr_PubCtor_t) -> Exception; 32 | 33 | pub fn optr__PubCtor_doit(this_: *mut optr_PubCtor_t) -> Exception; 34 | 35 | pub fn optr__PrvCtor_doit(this_: *mut optr_PrvCtor_t) -> Exception; 36 | 37 | 38 | } // extern "C" 39 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/opaqueptr/ref/opaqueptr-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/openexr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname openexr) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I$ENV{OPENEXR_ROOT}/include 14 | -I$ENV{OPENEXR_ROOT}/include/OpenEXR 15 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 16 | ) 17 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_chromaticities.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | class Chromaticities { 12 | public: 13 | using BoundType = Imf::Chromaticities; 14 | } CPPMM_VALUETYPE; 15 | 16 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 17 | 18 | } // namespace cppmm_bind 19 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_compression.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum Compression {}; 12 | 13 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 14 | 15 | } // namespace cppmm_bind 16 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_convert.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | IMF_EXPORT unsigned int halfToUint(half h); 12 | IMF_EXPORT unsigned int floatToUint(float f); 13 | 14 | IMF_EXPORT half uintToHalf(unsigned int ui); 15 | IMF_EXPORT half floatToHalf(float f); 16 | 17 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 18 | 19 | } // namespace cppmm_bind 20 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_deepimagestate.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum DeepImageState {}; 12 | 13 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 14 | 15 | } // namespace cppmm_bind 16 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_framespersecond.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | inline Imf::Rational fps_23_976(); 12 | inline Imf::Rational fps_24(); 13 | inline Imf::Rational fps_25(); 14 | inline Imf::Rational fps_29_97(); 15 | inline Imf::Rational fps_30(); 16 | inline Imf::Rational fps_47_952(); 17 | inline Imf::Rational fps_48(); 18 | inline Imf::Rational fps_50(); 19 | inline Imf::Rational fps_59_94(); 20 | inline Imf::Rational fps_60(); 21 | 22 | IMF_EXPORT Imf::Rational guessExactFps(double fps) 23 | CPPMM_RENAME(guessExactFps_f64); 24 | IMF_EXPORT Imf::Rational guessExactFps(const Imf::Rational& fps); 25 | 26 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 27 | 28 | } // namespace cppmm_bind 29 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_huf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | IMF_EXPORT 12 | int hufCompress(const unsigned short raw[/*nRaw*/], int nRaw, 13 | char compressed[/*2 * nRaw + 65536*/]); 14 | 15 | IMF_EXPORT 16 | void hufUncompress(const char compressed[/*nCompressed*/], int nCompressed, 17 | unsigned short raw[/*nRaw*/], int nRaw); 18 | 19 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 20 | 21 | } // namespace cppmm_bind 22 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_imagechannel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct ImageChannel { 12 | using BoundType = Imf::ImageChannel; 13 | 14 | // Inherited from ImageChannel 15 | virtual Imf::PixelType pixelType() const = 0; 16 | IMFUTIL_EXPORT 17 | Imf::Channel channel() const; 18 | int xSampling() const; 19 | int ySampling() const; 20 | bool pLinear() const; 21 | int pixelsPerRow() const; 22 | int pixelsPerColumn() const; 23 | size_t numPixels() const; 24 | Imf::ImageLevel& level(); 25 | const Imf::ImageLevel& level() const; 26 | 27 | } CPPMM_OPAQUEBYTES; 28 | 29 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 30 | 31 | } // namespace cppmm_bind 32 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_imagechannelrenaming.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | typedef std::map RenamingMap; 12 | 13 | template 14 | void renameChannelsInMap(const RenamingMap oldToNewNames, 15 | ChannelMap& channels) CPPMM_IGNORE; 16 | 17 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 18 | 19 | } // namespace cppmm_bind 20 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_imagedatawindow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum DataWindowSource {}; 12 | 13 | IMFUTIL_EXPORT 14 | IMATH_NAMESPACE::Box2i dataWindowForFile(const Imf::Header& hdr, 15 | const Imf::Image& img, 16 | Imf::DataWindowSource dws); 17 | 18 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 19 | 20 | } // namespace cppmm_bind 21 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_imageio.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | IMFUTIL_EXPORT 12 | void saveImage(const std::string& fileName, const Imf::Header& hdr, 13 | const Imf::Image& img, Imf::DataWindowSource dws); 14 | 15 | IMFUTIL_EXPORT 16 | void saveImage(const std::string& fileName, const Imf::Image& img); 17 | 18 | IMFUTIL_EXPORT 19 | Imf::Image* loadImage(const std::string& fileName, Imf::Header& hdr); 20 | 21 | IMFUTIL_EXPORT 22 | Imf::Image* loadImage(const std::string& fileName); 23 | 24 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 25 | 26 | } // namespace cppmm_bind 27 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_imagelevel.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct ImageLevel { 12 | using BoundType = Imf::ImageLevel; 13 | 14 | Imf::Image& image(); 15 | const Imf::Image& image() const CPPMM_RENAME(image_const); 16 | 17 | int xLevelNumber(); 18 | int yLevelNumber(); 19 | 20 | const IMATH_NAMESPACE::Box2i& dataWindow(); 21 | 22 | } CPPMM_OPAQUEPTR; 23 | 24 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 25 | 26 | } // namespace cppmm_bind 27 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_lineorder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum LineOrder {}; 12 | 13 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 14 | 15 | } // namespace cppmm_bind 16 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_name.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct Name { 12 | using BoundType = Imf::Name; 13 | 14 | IMF_EXPORT 15 | Name() CPPMM_RENAME(default); 16 | IMF_EXPORT 17 | Name(const char text[]); 18 | 19 | IMF_EXPORT 20 | Imf::Name& operator=(const char text[]); 21 | 22 | inline const char* text(); 23 | inline const char* operator*(); 24 | 25 | static const int SIZE = 256; 26 | static const int MAX_LENGTH = SIZE - 1; 27 | 28 | } CPPMM_OPAQUEBYTES; 29 | 30 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 31 | 32 | } // namespace cppmm_bind 33 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_parthelper.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct MultiViewChannelName { 12 | using BoundType = Imf::MultiViewChannelName; 13 | 14 | std::string getLayer() const; 15 | std::string getSuffix() const; 16 | } CPPMM_OPAQUEBYTES; 17 | 18 | // // FIXME: what do we do with these? 19 | // template 20 | // int SplitChannels(const T& begin, const T& end, bool multipart = true, 21 | // const std::string& heroView = ""); 22 | 23 | // template 24 | // void GetChannelsInMultiPartFile(const Imf::MultiPartInputFile& file, T& 25 | // chans); 26 | 27 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 28 | 29 | } // namespace cppmm_bind 30 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_parttype.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | IMF_EXPORT bool isImage(const std::string& name); 12 | 13 | IMF_EXPORT bool isTiled(const std::string& name); 14 | 15 | IMF_EXPORT bool isDeepData(const std::string& name); 16 | 17 | IMF_EXPORT bool isSupportedType(const std::string& name); 18 | 19 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 20 | 21 | } // namespace cppmm_bind 22 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_pixeltype.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum PixelType {}; 12 | 13 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 14 | 15 | } // namespace cppmm_bind 16 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_rational.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct Rational { 12 | using BoundType = Imf::Rational; 13 | 14 | Rational() CPPMM_RENAME(default); 15 | Rational(int n, int d); 16 | 17 | IMF_EXPORT 18 | explicit Rational(double x) CPPMM_RENAME(from_f64); 19 | 20 | operator double() const CPPMM_RENAME(as_f64); 21 | } CPPMM_VALUETYPE; 22 | 23 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 24 | 25 | } // namespace cppmm_bind 26 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_rgba.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | struct Rgba { 12 | using BoundType = Imf::Rgba; 13 | 14 | } CPPMM_VALUETYPE; 15 | 16 | enum RgbaChannels {}; 17 | 18 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 19 | 20 | } // namespace cppmm_bind 21 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_standardattributes.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // FIXME: get this working 4 | 5 | #include 6 | 7 | namespace cppmm_bind { 8 | 9 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 10 | 11 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 12 | 13 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 14 | 15 | } // namespace cppmm_bind 16 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_threading.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | IMF_EXPORT int globalThreadCount(); 12 | IMF_EXPORT void setGlobalThreadCount(int count); 13 | 14 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 15 | 16 | } // namespace cppmm_bind 17 | -------------------------------------------------------------------------------- /test/openexr/bind/imf_tiledescription.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace OPENEXR_IMF_INTERNAL_NAMESPACE { 8 | 9 | namespace Imf = ::OPENEXR_IMF_INTERNAL_NAMESPACE; 10 | 11 | enum LevelMode {}; 12 | enum LevelRoundingMode {}; 13 | 14 | struct TileDescription { 15 | using BoundType = Imf::TileDescription; 16 | 17 | TileDescription(unsigned int xs, unsigned int ys, Imf::LevelMode m, 18 | Imf::LevelRoundingMode r); 19 | bool operator==(const Imf::TileDescription& other); 20 | 21 | } CPPMM_VALUETYPE; 22 | 23 | } // namespace OPENEXR_IMF_INTERNAL_NAMESPACE 24 | 25 | } // namespace cppmm_bind 26 | -------------------------------------------------------------------------------- /test/openexr/bind/std.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/openexr/bind/std.cpp -------------------------------------------------------------------------------- /test/openexr/bind/std_map.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // CPPMM_ macro definitions etc automatically inserted in this virtual header 5 | #include 6 | 7 | namespace cppmm_bind { 8 | 9 | namespace std { 10 | 11 | template class map { 12 | public: 13 | // This allows us to see through to the type in Imath 14 | using BoundType = ::std::map; 15 | 16 | map(); 17 | ~map(); 18 | 19 | } CPPMM_OPAQUEBYTES; 20 | 21 | // explicit instantiation 22 | template class map<::std::string, ::std::string>; 23 | 24 | using map_string_string = ::std::map<::std::string, ::std::string>; 25 | 26 | } // namespace std 27 | 28 | } // namespace cppmm_bind 29 | 30 | template class std::map; 31 | -------------------------------------------------------------------------------- /test/openexr/bind/std_set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // CPPMM_ macro definitions etc automatically inserted in this virtual header 5 | #include 6 | 7 | namespace cppmm_bind { 8 | 9 | namespace std { 10 | 11 | template class set { 12 | public: 13 | // This allows us to see through to the type in Imath 14 | using BoundType = ::std::set; 15 | 16 | set(); 17 | ~set(); 18 | 19 | } CPPMM_OPAQUEBYTES; 20 | 21 | // explicit instantiation 22 | template class set<::std::string>; 23 | 24 | using set_string = ::std::set<::std::string>; 25 | 26 | } // namespace std 27 | 28 | } // namespace cppmm_bind 29 | 30 | template class std::set; 31 | -------------------------------------------------------------------------------- /test/openexr/bind/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace std { 8 | 9 | class basic_string { 10 | public: 11 | using BoundType = ::std::string; 12 | 13 | basic_string(); 14 | basic_string(const ::std::string & rhs); 15 | 16 | ::std::string& assign(const char* s, ::std::string::size_type count); 17 | const char* c_str() const; 18 | 19 | } CPPMM_OPAQUEBYTES; 20 | 21 | using string = ::std::string; 22 | 23 | } // namespace std 24 | 25 | } // namespace cppmm_bind 26 | -------------------------------------------------------------------------------- /test/openexr/bind/std_vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // CPPMM_ macro definitions etc automatically inserted in this virtual header 5 | #include 6 | 7 | namespace cppmm_bind { 8 | 9 | namespace std { 10 | 11 | template class vector { 12 | public: 13 | // This allows us to see through to the type in Imath 14 | using BoundType = ::std::vector; 15 | 16 | vector(); 17 | ~vector(); 18 | 19 | } CPPMM_OPAQUEBYTES; 20 | 21 | // explicit instantiation 22 | template class vector<::std::string>; 23 | 24 | using vector_string = ::std::vector<::std::string>; 25 | 26 | } // namespace std 27 | 28 | } // namespace cppmm_bind 29 | 30 | template class std::vector; 31 | -------------------------------------------------------------------------------- /test/openexr/ref/ast/imf_huf.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "TranslationUnit", 3 | "filename": "/home/anders/code/cppmm/test/openexr/bind/imf_huf.cpp", 4 | "source_includes": [ 5 | "#include ", 6 | "#include " 7 | ], 8 | "include_paths": [ 9 | "/home/anders/packages/openexr/2.5.5/include", 10 | "/home/anders/packages/openexr/2.5.5/include/OpenEXR" 11 | ], 12 | "id": 974, 13 | "decls": [ 14 | { 15 | "kind": "Namespace", 16 | "name": "cppmm_bind::Imf_2_5", 17 | "id": 3, 18 | "short_name": "Imf_2_5" 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /test/property/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname property) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/property/bind/prop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | namespace cppmm_bind { 5 | 6 | namespace prop { 7 | 8 | struct Bar { 9 | using BoundType = ::prop::Bar; 10 | 11 | } CPPMM_OPAQUEPTR; 12 | 13 | struct Foo { 14 | using BoundType = ::prop::Foo; 15 | static void bum(); 16 | } CPPMM_PROPERTIES(a; b; bar; u); 17 | 18 | uint64_t fuz(uint64_t& a, uint64_t* b, uint64_t c); 19 | 20 | } // namespace prop 21 | 22 | } // namespace cppmm_bind 23 | -------------------------------------------------------------------------------- /test/property/include/prop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace prop { 6 | 7 | struct Bar { 8 | int baz; 9 | }; 10 | 11 | struct Foo { 12 | int a; 13 | float b; 14 | float c; 15 | Bar bar; 16 | uint64_t u; 17 | 18 | static void bum(){} 19 | }; 20 | 21 | uint64_t fuz(uint64_t& a, uint64_t* b, uint64_t c) {return 0;} 22 | 23 | } // namespace prop 24 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "property-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/property/ref/property-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/property/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "prop.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_prop(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/abigen/prop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_prop(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/abigen/prop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_prop(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/include/property-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "property-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | PROPERTY_CPPMM_API const char* property_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/private/property-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/property-c/src/property-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "property-errors.h" 2 | #include "property-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | PROPERTY_CPPMM_API const char* property_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/property/ref/property-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/rustify_enum/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname rustify_enum) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/rustify_enum/include/renum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace rustify { 4 | 5 | enum Compression { 6 | NO_COMPRESSION = 0, 7 | RLE_COMPRESSION = 1, 8 | ZIPS_COMPRESSION = 2, 9 | ZIP_COMPRESSION = 3, 10 | PIZ_COMPRESSION = 4, 11 | PXR24_COMPRESSION = 5, 12 | B44_COMPRESSION = 6, 13 | B44A_COMPRESSION = 7, 14 | DWAA_COMPRESSION = 8, 15 | DWAB_COMPRESSION = 9, 16 | NUM_COMPRESSION_METHODS 17 | }; 18 | 19 | enum LineOrder { 20 | INCREASING_Y = 0, 21 | DECREASING_Y = 1, 22 | RANDOM_Y = 2, 23 | NUM_LINEORDERS, 24 | }; 25 | 26 | enum RgbaChannels { 27 | RGBA_CHANNELS_R, 28 | RGBA_CHANNELS_G, 29 | RGBA_CHANNELS_B, 30 | RGBA_CHANNELS_A, 31 | RGBA_CHANNELS_ALL, 32 | }; 33 | 34 | class Foo { 35 | public: 36 | enum Bar { 37 | Baz = 0, 38 | Qux = 1, 39 | }; 40 | }; 41 | 42 | } // namespace rustify 43 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "rustify_enum-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/rustify_enum/ref/rustify_enum-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/rustify_enum/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-renum.hpp" 4 | 5 | int main() { 6 | std::ofstream os("abigen.txt"); 7 | 8 | abi_gen_c_renum(os); 9 | } 10 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/abigen/c-renum.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_renum(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/abigen/c-renum.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_renum(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/include/rustify_enum-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rustify_enum-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | RUSTIFY_ENUM_CPPMM_API const char* rustify_enum_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/private/rustify_enum-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/src/c-renum.cpp: -------------------------------------------------------------------------------- 1 | #include "c-renum_private.h" 2 | 3 | 4 | #include 5 | 6 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/rustify_enum-c/src/rustify_enum-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "rustify_enum-errors.h" 2 | #include "rustify_enum-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | RUSTIFY_ENUM_CPPMM_API const char* rustify_enum_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/rustify_enum/ref/rustify_enum-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::c_renum::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let e = rustify__Compression_e(4); 6 | assert_eq!(Compression::from(e), Compression::Piz); 7 | } 8 | -------------------------------------------------------------------------------- /test/rustify_enum/test.rs: -------------------------------------------------------------------------------- 1 | use crate::c_renum::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let e = rustify__Compression_e(4); 6 | assert_eq!(Compression::from(e), Compression::Piz); 7 | } 8 | -------------------------------------------------------------------------------- /test/std/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_test(NAME std 2 | COMMAND 3 | python 4 | ${CMAKE_SOURCE_DIR}/test/runtest.py 5 | $ 6 | $ 7 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 8 | ${CMAKE_BINARY_DIR}/test/std/output 9 | std 10 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 11 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 12 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 13 | ) 14 | -------------------------------------------------------------------------------- /test/std/bind/c-usestd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace cppmm_bind { 4 | 5 | namespace usestd { 6 | 7 | void takes_string(const ::std::string& s); 8 | void takes_vector_string(const ::std::vector<::std::string>& v); 9 | 10 | } // namespace usestd 11 | 12 | } // namespace cppmm_bind 13 | -------------------------------------------------------------------------------- /test/std/include/usestd.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace usestd { 5 | 6 | void takes_string(const std::string& s) {} 7 | void takes_vector_string(const std::vector& v) {} 8 | 9 | } // namespace usestd 10 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "std-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/src/c_usestd.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | 10 | 11 | extern "C" { 12 | 13 | pub fn usestd_takes_string(s: *const std_string_t) -> Exception; 14 | 15 | pub fn usestd_takes_vector_string(v: *const std_vector_string_t) -> Exception; 16 | 17 | 18 | } // extern "C" 19 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let lay = std_string_t::layout(); 6 | assert_eq!(lay.size(), std::mem::size_of::()); 7 | assert_eq!(lay.align(), std::mem::align_of::()); 8 | 9 | let lay = std_vector_string_t::layout(); 10 | assert_eq!(lay.size(), std::mem::size_of::()); 11 | assert_eq!(lay.align(), std::mem::align_of::()); 12 | } 13 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/std/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-usestd.hpp" 4 | #include "std_list.hpp" 5 | #include "std_set.hpp" 6 | #include "std_string.hpp" 7 | 8 | int main() { 9 | std::ofstream os("abigen.txt"); 10 | 11 | abi_gen_c_usestd(os); 12 | abi_gen_std_list(os); 13 | abi_gen_std_set(os); 14 | abi_gen_std_string(os); 15 | } 16 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/c-usestd.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_usestd(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/c-usestd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_usestd(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_std_list(std::ostream& os) { 6 | } 7 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_std_list(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_set.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_std_set(std::ostream& os) { 6 | os << "std::set" << "|" << sizeof(std::set) << "|" << alignof(std::set) << "\n"; 7 | os << "std::set::const_iterator" << "|" << sizeof(std::set::const_iterator) << "|" << alignof(std::set::const_iterator) << "\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_set.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_std_set(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_std_string(std::ostream& os) { 6 | os << "std::string" << "|" << sizeof(std::string) << "|" << alignof(std::string) << "\n"; 7 | os << "std::vector" << "|" << sizeof(std::vector) << "|" << alignof(std::vector) << "\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/abigen/std_string.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_std_string(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/include.in/c-usestd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "std-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct std__string_t_s std__string_t; 10 | typedef std__string_t std_string_t; 11 | typedef struct std__vector_std__string__t_s std__vector_std__string__t; 12 | typedef std__vector_std__string__t std_vector_string_t; 13 | 14 | STD_CPPMM_API unsigned int usestd_takes_string( 15 | std_string_t const * s); 16 | 17 | STD_CPPMM_API unsigned int usestd_takes_vector_string( 18 | std_vector_string_t const * v); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/include/std-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | STD_CPPMM_API const char* std_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/private/c-usestd_private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | #include "std-errors-private.h" 6 | 7 | #include 8 | #include 9 | 10 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/private/std-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/src/c-usestd.cpp: -------------------------------------------------------------------------------- 1 | #include "c-usestd_private.h" 2 | 3 | #include "std_string_private.h" 4 | 5 | #include 6 | 7 | STD_CPPMM_API unsigned int usestd_takes_string( 8 | std_string_t const * s) 9 | { 10 | try { 11 | usestd::takes_string(to_cpp_ref(s)); 12 | return 0; 13 | } catch (std::exception& e) { 14 | TLG_EXCEPTION_STRING = e.what(); 15 | return -1; 16 | } 17 | } 18 | 19 | STD_CPPMM_API unsigned int usestd_takes_vector_string( 20 | std_vector_string_t const * v) 21 | { 22 | try { 23 | usestd::takes_vector_string(to_cpp_ref(v)); 24 | return 0; 25 | } catch (std::exception& e) { 26 | TLG_EXCEPTION_STRING = e.what(); 27 | return -1; 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /test/std/ref/std-sys/std-c/src/std-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "std-errors.h" 2 | #include "std-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | STD_CPPMM_API const char* std_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust" 3 | version = "0.1.0" 4 | authors = ["Anders Langlands "] 5 | edition = "2018" 6 | 7 | [build-dependencies] 8 | cmake = "0.1" 9 | 10 | [dependencies] 11 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let dst = cmake::Config::new("clib").build(); 3 | println!("cargo:rustc-link-search=native={}", dst.display()); 4 | println!("cargo:rustc-link-lib=static=clib"); 5 | 6 | #[cfg(target_os = "linux")] 7 | println!("cargo:rustc-link-lib=dylib=stdc++"); 8 | #[cfg(target_os = "macos")] 9 | println!("cargo:rustc-link-lib=dylib=c++"); 10 | } 11 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/clib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(clib) 3 | 4 | set (CMAKE_CXX_STANDARD 11) 5 | 6 | add_library(clib STATIC 7 | test_bind.cpp 8 | cppmm_containers.cpp 9 | std_string.cpp 10 | ) 11 | 12 | target_compile_options(clib PRIVATE 13 | -fno-strict-aliasing 14 | ) 15 | 16 | target_include_directories(clib PUBLIC 17 | ../test/std/bind 18 | /Volumes/src/cppmm/build/../test/std/bind 19 | ) 20 | 21 | target_link_libraries(clib PUBLIC 22 | 23 | ) 24 | 25 | install(TARGETS clib DESTINATION ${CMAKE_INSTALL_PREFIX}) 26 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/clib/cppmm_containers.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cppmm_containers.h" 3 | #include 4 | #include 5 | 6 | namespace { 7 | #include "casts.h" 8 | 9 | CPPMM_DEFINE_POINTER_CASTS(std::vector, cppmm_string_vector); 10 | 11 | 12 | #undef CPPMM_DEFINE_POINTER_CASTS 13 | } 14 | 15 | extern "C" { 16 | 17 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index) { 18 | return (*to_cpp(vec))[index].c_str(); 19 | } 20 | 21 | int cppmm_string_vector_size(const cppmm_string_vector* vec) { 22 | return to_cpp(vec)->size(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/clib/cppmm_containers.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | 16 | typedef struct { char _private[24]; } cppmm_string_vector CPPMM_ALIGN(8); 17 | 18 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index); 19 | int cppmm_string_vector_size(const cppmm_string_vector* vec); 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/clib/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include "std_string.h" 2 | 3 | #include 4 | 5 | namespace { 6 | #include "casts.h" 7 | 8 | CPPMM_DEFINE_POINTER_CASTS(std::string, std_string) 9 | 10 | #undef CPPMM_DEFINE_POINTER_CASTS 11 | } 12 | 13 | void std_string_ctor(std_string* self){ 14 | new (self) std::string(); 15 | } 16 | 17 | void std_string_from_cstr(std_string* self, const char * str){ 18 | new (self) std::string(str); 19 | } 20 | 21 | void std_string_dtor(std_string* self){ 22 | to_cpp(self)->~basic_string(); 23 | } 24 | 25 | int std_string_size(const std_string* self){ // TODO: Should this be unsigned long int to match size_t? 26 | return to_cpp(self)->size(); 27 | } 28 | 29 | const char * std_string_c_str(const std_string* self){ 30 | return to_cpp(self)->c_str(); 31 | } 32 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/clib/std_string.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | typedef struct { char _private[24]; } std_string CPPMM_ALIGN(8); 16 | 17 | void std_string_ctor(std_string* self); 18 | void std_string_from_cstr(std_string* self, const char * str); 19 | void std_string_dtor(std_string* self); 20 | int std_string_size(const std_string* self); 21 | const char * std_string_c_str(const std_string* self); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/cppmm_containers.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(8))] 2 | pub struct cppmm_string_vector { 3 | unused: [u8; 24], 4 | } 5 | 6 | extern "C" { 7 | 8 | pub fn cppmm_string_vector_get( 9 | vec: *const cppmm_string_vector, 10 | index: i32, 11 | ) -> *const std::os::raw::c_char; 12 | pub fn cppmm_string_vector_size(vec: *const cppmm_string_vector) -> i32; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_upper_case_globals)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_snake_case)] 4 | 5 | mod std_string_bind; 6 | pub use std_string_bind::*; 7 | 8 | #[cfg(test)] 9 | mod test; 10 | 11 | pub mod cppmm_containers; 12 | use cppmm_containers::*; 13 | pub mod test_bind; 14 | use test_bind::*; 15 | 16 | pub use test_bind::test_Test; 17 | pub use test_bind::test_Test_Test; 18 | pub use test_bind::test_Test_clone_value; 19 | pub use test_bind::test_Test_edit_value; 20 | pub use test_bind::test_Test_get_value; 21 | pub use test_bind::test_Test_set_value; 22 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/std_string.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(8))] 2 | pub struct std_string { unused: [u8; 24] } // TODO: Figure out what we want to do to allow users to create one of these 3 | 4 | extern "C" { 5 | 6 | pub fn std_string_ctor(_self: *mut std_string) -> std::os::raw::c_void; 7 | pub fn std_string_from_cstr(_self: *mut std_string, 8 | _str: * const std::os::raw::c_char) 9 | -> std::os::raw::c_void; 10 | 11 | pub fn std_string_dtor(_self: * mut std_string) -> std::os::raw::c_void; 12 | 13 | pub fn std_string_size(_self: * const std_string) -> i32; 14 | 15 | pub fn std_string_size(_self: * const std_string) -> i32; 16 | 17 | pub fn std_string_c_str(_self : * const std_string) -> 18 | * const std::os::raw::c_char; 19 | } 20 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/std_string_bind.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(8))] 2 | pub struct std_string { 3 | pub(self) _unused: [u8; 24], 4 | } // TODO: Figure out what we want to do to allow users to create one of these 5 | 6 | impl std_string { 7 | pub fn new() -> std_string { 8 | std_string { _unused: [0u8; 24] } 9 | } 10 | } 11 | 12 | extern "C" { 13 | 14 | pub fn std_string_ctor(_self: *mut std_string) -> std::os::raw::c_void; 15 | pub fn std_string_from_cstr( 16 | _self: *mut std_string, 17 | _str: *const std::os::raw::c_char, 18 | ) -> std::os::raw::c_void; 19 | 20 | pub fn std_string_dtor(_self: *mut std_string) -> std::os::raw::c_void; 21 | 22 | pub fn std_string_size(_self: *const std_string) -> i32; 23 | 24 | pub fn std_string_c_str(_self: *const std_string) -> *const std::os::raw::c_char; 25 | } 26 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let s = std::ffi::CString::new("this_is_a_test_string").unwrap(); 6 | unsafe { 7 | let mut std_str = std_string::new(); 8 | std_string_from_cstr(&mut std_str, s.as_ptr()); 9 | 10 | // Check that the contents of the std_string is correct 11 | assert_eq!( 12 | std::ffi::CStr::from_ptr(std_string_c_str(&std_str)), 13 | s.as_c_str() 14 | ); 15 | 16 | let t = test_Test_Test(&std_str); 17 | 18 | // Check that the Test class also contains a valid copy of the value 19 | assert_eq!( 20 | std::ffi::CStr::from_ptr(std_string_c_str(test_Test_get_value(t))), 21 | s.as_c_str() 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/std/test-rust-sys/src/test_bind.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[repr(C)] 4 | pub struct test_Test_t { 5 | _unused: [u8; 0], 6 | } 7 | pub type test_Test = *mut test_Test_t; 8 | extern "C" { 9 | 10 | pub fn test_Test_edit_value(_self: *mut test_Test) -> *mut std_string; 11 | 12 | pub fn test_Test_get_value(_self: *const test_Test) -> *const std_string; 13 | 14 | pub fn test_Test_set_value( 15 | _self: *mut test_Test, 16 | value: *const std_string, 17 | ) -> std::os::raw::c_void; 18 | 19 | pub fn test_Test_clone_value(_self: *const test_Test) -> std_string; 20 | 21 | pub fn test_Test_Test(value: *const std_string) -> *mut test_Test; 22 | } 23 | -------------------------------------------------------------------------------- /test/std/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let lay = std_string_t::layout(); 6 | assert_eq!(lay.size(), std::mem::size_of::()); 7 | assert_eq!(lay.align(), std::mem::align_of::()); 8 | 9 | let lay = std_vector_string_t::layout(); 10 | assert_eq!(lay.size(), std::mem::size_of::()); 11 | assert_eq!(lay.align(), std::mem::align_of::()); 12 | } 13 | -------------------------------------------------------------------------------- /test/templates/ref/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(templates-c) 3 | 4 | add_library(templates-c STATIC 5 | templates_bind.cpp 6 | cppmm_containers.cpp 7 | ) 8 | 9 | target_compile_options(templates-c PRIVATE 10 | -fno-strict-aliasing 11 | ) 12 | 13 | target_include_directories(templates-c PUBLIC 14 | /home/anders/code/cppmm/test/templates/bind 15 | ) 16 | 17 | target_link_libraries(templates-c PUBLIC 18 | 19 | ) 20 | 21 | install(TARGETS templates-c DESTINATION ${CMAKE_INSTALL_PREFIX}) 22 | -------------------------------------------------------------------------------- /test/templates/ref/bind.cpp: -------------------------------------------------------------------------------- 1 | // 2 | #include "bind.h" 3 | 4 | 5 | namespace { 6 | #include "casts.h" 7 | 8 | 9 | #undef CPPMM_DEFINE_POINTER_CASTS 10 | } 11 | 12 | extern "C" { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /test/templates/ref/bind.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "cppmm_containers.h" 4 | 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #else 9 | #include 10 | #endif 11 | 12 | #if defined(_WIN32) || defined(__CYGWIN__) 13 | #define CPPMM_ALIGN(x) __declspec(align(x)) 14 | #else 15 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 16 | #endif 17 | 18 | 19 | 20 | #undef CPPMM_ALIGN 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/templates/ref/cppmm_containers.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cppmm_containers.h" 3 | #include 4 | #include 5 | 6 | namespace { 7 | #include "casts.h" 8 | 9 | CPPMM_DEFINE_POINTER_CASTS(std::vector, cppmm_string_vector); 10 | 11 | 12 | #undef CPPMM_DEFINE_POINTER_CASTS 13 | } 14 | 15 | extern "C" { 16 | 17 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index) { 18 | return (*to_cpp(vec))[index].c_str(); 19 | } 20 | 21 | int cppmm_string_vector_size(const cppmm_string_vector* vec) { 22 | return to_cpp(vec)->size(); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /test/templates/ref/cppmm_containers.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #else 6 | #include 7 | #endif 8 | 9 | #if defined(_WIN32) || defined(__CYGWIN__) 10 | #define CPPMM_ALIGN(x) __declspec(align(x)) 11 | #else 12 | #define CPPMM_ALIGN(x) __attribute__((aligned(x))) 13 | #endif 14 | 15 | 16 | typedef struct { char _private[24]; } cppmm_string_vector CPPMM_ALIGN(8); 17 | 18 | const char* cppmm_string_vector_get(const cppmm_string_vector* vec, int index); 19 | int cppmm_string_vector_size(const cppmm_string_vector* vec); 20 | 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | -------------------------------------------------------------------------------- /test/tmp_specs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname tmp_specs) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /test/tmp_specs/include/tmp_specs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace specs { 6 | 7 | template struct Attribute { 8 | T t; 9 | const T& value(); 10 | static void do_something(T& v){} 11 | Attribute(){} 12 | }; 13 | 14 | using IntAttribute = Attribute; 15 | using FloatAttribute = Attribute; 16 | 17 | struct Specs { 18 | void doSomething(int) {} 19 | template T* findAttribute(const char* name) { return nullptr; } 20 | template const T* findAttribute(const char* name) const { 21 | return nullptr; 22 | } 23 | }; 24 | 25 | } // namespace specs 26 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "tmp_specs-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | #[repr(C, align(%ALIGNstd::__cxx11::basic_string%))] 2 | #[derive(Clone)] 3 | pub struct std____cxx11__basic_string_char__t { 4 | _inner: [u8; %SIZEstd::__cxx11::basic_string%] 5 | } 6 | 7 | impl Default for std____cxx11__basic_string_char__t { 8 | fn default() -> Self { 9 | Self { _inner: [0u8; %SIZEstd::__cxx11::basic_string%] } 10 | } 11 | } 12 | #[repr(C, align(%ALIGNstd::vector%))] 13 | #[derive(Clone)] 14 | pub struct std__vector_std__string__t { 15 | _inner: [u8; %SIZEstd::vector%] 16 | } 17 | 18 | impl Default for std__vector_std__string__t { 19 | fn default() -> Self { 20 | Self { _inner: [0u8; %SIZEstd::vector%] } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/tmp_specs/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "c-specs.hpp" 4 | #include "std_string.hpp" 5 | 6 | int main() { 7 | std::ofstream os("abigen.txt"); 8 | 9 | abi_gen_c_specs(os); 10 | abi_gen_std_string(os); 11 | } 12 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/c-specs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_c_specs(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/c-specs.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_c_specs(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/std_string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_std_string(std::ostream& os) { 6 | os << "std::__cxx11::basic_string" << "|" << sizeof(std::__cxx11::basic_string) << "|" << alignof(std::__cxx11::basic_string) << "\n"; 7 | os << "std::vector" << "|" << sizeof(std::vector) << "|" << alignof(std::vector) << "\n"; 8 | } 9 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/abigen/std_string.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_std_string(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/include/tmp_specs-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "tmp_specs-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | TMP_SPECS_CPPMM_API const char* tmp_specs_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/private/tmp_specs-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/tmp_specs/ref/tmp_specs-sys/tmp_specs-c/src/tmp_specs-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "tmp_specs-errors.h" 2 | #include "tmp_specs-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | TMP_SPECS_CPPMM_API const char* tmp_specs_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/uniqueptr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname uniqueptr) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I${CMAKE_CURRENT_SOURCE_DIR}/include 14 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 15 | ) 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/uniqueptr/bind/foo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // CPPMM_ macro definitions etc automatically inserted in this virtual header 4 | #include 5 | 6 | namespace cppmm_bind { 7 | 8 | namespace foo { 9 | 10 | struct Foo { 11 | using BoundType = ::foo::Foo; 12 | 13 | Foo(); 14 | ~Foo(); 15 | 16 | static std::unique_ptr<::foo::Foo> create(); 17 | }; 18 | 19 | } // namespace foo 20 | 21 | } // namespace cppmm_bind 22 | -------------------------------------------------------------------------------- /test/uniqueptr/bind/uptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | // CPPMM_ macro definitions etc automatically inserted in this virtual header 6 | #include 7 | 8 | namespace cppmm_bind { 9 | 10 | namespace std { 11 | 12 | #if defined(_LIBCPP_VERSION) 13 | namespace std = ::std::_LIBCPP_ABI_NAMESPACE; 14 | #else 15 | namespace std = ::std; 16 | #endif 17 | 18 | template class unique_ptr { 19 | public: 20 | // This allows us to see through to the type in Imath 21 | using BoundType = ::std::unique_ptr; 22 | 23 | unique_ptr(T* p) CPPMM_RENAME(ctor); 24 | ~unique_ptr() CPPMM_RENAME(dtor); 25 | 26 | T* get() const; 27 | } CPPMM_OPAQUEPTR; 28 | 29 | // explicit instantiation 30 | template class unique_ptr; 31 | using FooPtr = ::std::unique_ptr; 32 | 33 | } // namespace std 34 | 35 | } // namespace cppmm_bind 36 | 37 | template class std::unique_ptr; 38 | -------------------------------------------------------------------------------- /test/uniqueptr/include/foo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace foo { 7 | 8 | struct Foo { 9 | Foo() { printf("Foo()\n"); } 10 | ~Foo() { printf("~Foo()\n"); } 11 | 12 | static std::unique_ptr create() { return std::make_unique(); } 13 | }; 14 | 15 | } // namespace foo 16 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "uniqueptr-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | regex = "^1.5" 11 | quick-xml = "0.22" 12 | 13 | [dependencies] 14 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/cppmm_abi_in/cppmmabi.rs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vfx-rs/cppmm/ea860e16573270ec45ed310963bcbfdf8d7f50a7/test/uniqueptr/ref/uniqueptr-sys/cppmm_abi_in/cppmmabi.rs -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/src/cppmmabi.rs: -------------------------------------------------------------------------------- 1 | 2 | include!(concat!(env!("OUT_DIR"), "/cppmm_abi_out/", "cppmmabi.rs")); 3 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/src/foo.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct foo__Foo_t { 11 | _unused: [u8; 0], 12 | } 13 | 14 | 15 | extern "C" { 16 | 17 | pub fn foo__Foo_ctor(this_: *mut *mut foo_Foo_t) -> Exception; 18 | 19 | pub fn foo__Foo_dtor(this_: *mut foo_Foo_t) -> Exception; 20 | 21 | pub fn foo__Foo_create(return_: *mut *mut std_FooPtr_t) -> Exception; 22 | 23 | 24 | } // extern "C" 25 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let mut p = std::ptr::null_mut(); 6 | unsafe { 7 | std_FooPtr_ctor(&mut p, std::ptr::null_mut()); 8 | 9 | foo_Foo_create(&mut p); 10 | 11 | std_FooPtr_dtor(p); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/src/uptr.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_snake_case)] 2 | #![allow(non_camel_case_types)] 3 | #![allow(non_upper_case_globals)] 4 | #![allow(unused_imports)] 5 | use crate::*; 6 | pub use crate::cppmmabi::*; 7 | use std::os::raw::*; 8 | 9 | #[repr(C)] 10 | pub struct std__unique_ptr_foo__Foo__t { 11 | _unused: [u8; 0], 12 | } 13 | 14 | 15 | extern "C" { 16 | 17 | pub fn std__unique_ptr_foo__Foo__ctor(this_: *mut *mut std_FooPtr_t, p: *mut foo_Foo_t) -> Exception; 18 | 19 | pub fn std__unique_ptr_foo__Foo__dtor(this_: *mut std_FooPtr_t) -> Exception; 20 | 21 | pub fn std__unique_ptr_foo__Foo__get(this_: *const std_FooPtr_t, return_: *mut *mut foo_Foo_t) -> Exception; 22 | 23 | 24 | } // extern "C" 25 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB_RECURSE ABIGEN_SOURCE *.cpp) 2 | add_executable(abigen ${ABIGEN_SOURCE}) 3 | target_include_directories(abigen PRIVATE /home/anders/code/cppmm/test/uniqueptr/include) 4 | target_include_directories(abigen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..) 5 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/abigen.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "foo.hpp" 4 | #include "uptr.hpp" 5 | 6 | int main() { 7 | std::ofstream os("abigen.txt"); 8 | 9 | abi_gen_foo(os); 10 | abi_gen_uptr(os); 11 | } 12 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/foo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void abi_gen_foo(std::ostream& os) { 5 | } 6 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/foo.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_foo(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/uptr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void abi_gen_uptr(std::ostream& os) { 6 | } 7 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/abigen/uptr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | void abi_gen_uptr(std::ostream& os); 5 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/include.in/foo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "uniqueptr-api-export.h" 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | typedef struct std__unique_ptr_foo__Foo__t_s std__unique_ptr_foo__Foo__t; 10 | typedef std__unique_ptr_foo__Foo__t std_FooPtr_t; 11 | 12 | typedef struct foo__Foo_t_s { 13 | char _unused; 14 | } UNIQUEPTR_CPPMM_ALIGN(1) foo__Foo_t; 15 | typedef foo__Foo_t foo_Foo_t; 16 | 17 | 18 | UNIQUEPTR_CPPMM_API unsigned int foo__Foo_ctor( 19 | foo_Foo_t * * this_); 20 | #define foo_Foo_ctor foo__Foo_ctor 21 | 22 | 23 | UNIQUEPTR_CPPMM_API unsigned int foo__Foo_dtor( 24 | foo_Foo_t * this_); 25 | #define foo_Foo_dtor foo__Foo_dtor 26 | 27 | 28 | UNIQUEPTR_CPPMM_API unsigned int foo__Foo_create( 29 | std_FooPtr_t * * return_); 30 | #define foo_Foo_create foo__Foo_create 31 | 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/include/uniqueptr-errors.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "uniqueptr-api-export.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | UNIQUEPTR_CPPMM_API const char* uniqueptr_get_exception_string(); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/private/uniqueptr-errors-private.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | extern thread_local std::string TLG_EXCEPTION_STRING; 4 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/src/uniqueptr-errors.cpp: -------------------------------------------------------------------------------- 1 | #include "uniqueptr-errors.h" 2 | #include "uniqueptr-errors-private.h" 3 | 4 | thread_local std::string TLG_EXCEPTION_STRING; 5 | 6 | UNIQUEPTR_CPPMM_API const char* uniqueptr_get_exception_string() { 7 | return TLG_EXCEPTION_STRING.c_str(); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /test/uniqueptr/ref/uniqueptr-sys/uniqueptr-c/src/uptr.cpp: -------------------------------------------------------------------------------- 1 | #include "uptr_private.h" 2 | 3 | #include "foo_private.h" 4 | #include 5 | 6 | #include 7 | 8 | UNIQUEPTR_CPPMM_API unsigned int std__unique_ptr_foo__Foo__ctor( 9 | std_FooPtr_t * * this_ 10 | , foo_Foo_t * p) 11 | { 12 | to_c(this_, new std::unique_ptr(to_cpp(p))); 13 | return 0; 14 | } 15 | 16 | UNIQUEPTR_CPPMM_API unsigned int std__unique_ptr_foo__Foo__dtor( 17 | std_FooPtr_t * this_) 18 | { 19 | delete to_cpp(this_); 20 | return 0; 21 | } 22 | 23 | UNIQUEPTR_CPPMM_API unsigned int std__unique_ptr_foo__Foo__get( 24 | std_FooPtr_t const * this_ 25 | , foo_Foo_t * * return_) 26 | { 27 | to_c(return_, (to_cpp(this_)) -> get()); 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /test/uniqueptr/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | #[test] 4 | fn it_works() { 5 | let mut p = std::ptr::null_mut(); 6 | unsafe { 7 | std_FooPtr_ctor(&mut p, std::ptr::null_mut()); 8 | 9 | foo_Foo_create(&mut p); 10 | 11 | std_FooPtr_dtor(p); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/usd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(testname usd) 2 | 3 | add_test(NAME ${testname} 4 | COMMAND 5 | python 6 | ${CMAKE_SOURCE_DIR}/test/runtest.py 7 | $ 8 | $ 9 | ${CMAKE_CURRENT_SOURCE_DIR}/bind 10 | ${CMAKE_BINARY_DIR}/test/${testname}/output 11 | ${testname} 12 | ${CMAKE_CURRENT_SOURCE_DIR}/ref 13 | -I$ENV{OPENEXR_ROOT}/include 14 | -I$ENV{USD_ROOT}/include 15 | -I$ENV{BOOST_ROOT}/include 16 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 17 | ) 18 | -------------------------------------------------------------------------------- /test/usd/ref-c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(/home/anders/code/cppmm/test/usd/ref-c) 3 | set(CMAKE_CXX_STANDARD 14 CACHE STRING "") 4 | add_library(/home/anders/code/cppmm/test/usd/ref-c SHARED 5 | tftoken-c.cpp 6 | ) 7 | target_include_directories(/home/anders/code/cppmm/test/usd/ref-c PRIVATE .) 8 | target_include_directories(/home/anders/code/cppmm/test/usd/ref-c PRIVATE /home/anders/packages/boost/1.70.0/include) 9 | target_include_directories(/home/anders/code/cppmm/test/usd/ref-c PRIVATE /home/anders/packages/usd/20.05/include) 10 | install(TARGETS /home/anders/code/cppmm/test/usd/ref-c DESTINATION ${CMAKE_INSTALL_PREFIX}) -------------------------------------------------------------------------------- /test/usd/ref-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "/home/anders/code/cppmm/test/usd/ref" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | 11 | [dependencies] 12 | 13 | -------------------------------------------------------------------------------- /test/usd/ref-sys/build.rs: -------------------------------------------------------------------------------- 1 | 2 | fn main() { 3 | let dst = cmake::Config::new("/home/anders/code/cppmm/test/usd/ref-c").build(); 4 | println!("cargo:rustc-link-search=native={}", dst.display()); 5 | println!("cargo:rustc-link-lib=dylib=/home/anders/code/cppmm/test/usd/ref-c"); 6 | 7 | 8 | #[cfg(target_os = "linux")] 9 | println!("cargo:rustc-link-lib=dylib=stdc++"); 10 | #[cfg(target_os = "macos")] 11 | println!("cargo:rustc-link-lib=dylib=c++"); 12 | } 13 | -------------------------------------------------------------------------------- /test/usd/ref/usd-c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(usd-c VERSION 0.1.0) 3 | set(CMAKE_CXX_STANDARD 14 CACHE STRING "") 4 | set(LIBNAME usd-c-0_1) 5 | add_library(${LIBNAME} SHARED 6 | tftoken-c.cpp 7 | ) 8 | target_include_directories(${LIBNAME} PRIVATE .) 9 | target_include_directories(${LIBNAME} PRIVATE /home/anders/packages/boost/1.70.0/include) 10 | target_include_directories(${LIBNAME} PRIVATE /home/anders/packages/openexr/2.5.5/include) 11 | target_include_directories(${LIBNAME} PRIVATE /home/anders/packages/usd/20.05/include) 12 | install(TARGETS ${LIBNAME} DESTINATION ${CMAKE_INSTALL_PREFIX}) -------------------------------------------------------------------------------- /test/usd/ref/usd-sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "usd-sys" 4 | version = "0.1.0" 5 | authors = ["Anders Langlands "] 6 | edition = "2018" 7 | 8 | [build-dependencies] 9 | cmake = "0.1" 10 | 11 | [dependencies] 12 | thiserror = "^1.0" 13 | 14 | -------------------------------------------------------------------------------- /test/usd/ref/usd-sys/build.rs: -------------------------------------------------------------------------------- 1 | 2 | fn main() { 3 | let dst = cmake::Config::new("/home/anders/code/cppmm/build/test/usd/output/usd-c").build(); 4 | println!("cargo:rustc-link-search=native={}", dst.display()); 5 | println!("cargo:rustc-link-lib=dylib=usd-c-0_1"); 6 | 7 | 8 | #[cfg(target_os = "linux")] 9 | println!("cargo:rustc-link-lib=dylib=stdc++"); 10 | #[cfg(target_os = "macos")] 11 | println!("cargo:rustc-link-lib=dylib=c++"); 12 | } 13 | -------------------------------------------------------------------------------- /test/usd/ref/usd-sys/src/test.rs: -------------------------------------------------------------------------------- 1 | // Empty dummy test file for automated testing. This will be replaced by a 2 | // file copied in from the test suite 3 | 4 | #[test] 5 | fn it_works() { 6 | assert!(true, "It works!"); 7 | } -------------------------------------------------------------------------------- /test/usd/test-rust-sys/test.rs: -------------------------------------------------------------------------------- 1 | use crate::*; 2 | 3 | use std::ffi::{CString, CStr}; 4 | 5 | #[test] 6 | fn it_works() { 7 | let mut tok = pxr_TfToken::new(); 8 | 9 | let s = CString::new("Hello, world!").unwrap(); 10 | 11 | unsafe { 12 | pxr_TfToken_from_string(&mut tok, s.as_ptr()); 13 | let ptr = pxr_TfToken_GetText(&tok); 14 | let s2 = CStr::from_ptr(ptr).to_string_lossy().into_owned(); 15 | assert_eq!(s2, "Hello, world!"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tutorial/01_simple_class/bind/c-hello.cpp: -------------------------------------------------------------------------------- 1 | #include "hello.hpp" 2 | 3 | namespace cppmm_bind { 4 | 5 | namespace hello { 6 | 7 | struct Hello { 8 | using BoundType = ::hello::Hello; 9 | void hello() const; 10 | }; 11 | 12 | } // namespace hello 13 | 14 | } // namespace cppmm_bind 15 | -------------------------------------------------------------------------------- /tutorial/01_simple_class/include/hello.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace hello { 6 | 7 | class Hello { 8 | public: 9 | void hello() const { std::cout << "Hello, world!\n"; } 10 | }; 11 | 12 | } // namespace hello 13 | -------------------------------------------------------------------------------- /tutorial/02_customizing_methods/bind/c-hello.cpp: -------------------------------------------------------------------------------- 1 | #include "hello.hpp" 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace hello { 8 | 9 | struct Hello { 10 | using BoundType = ::hello::Hello; 11 | void hello(const char* msg) const CPPMM_RENAME(hello_string); 12 | void hello(const int msg) const CPPMM_RENAME(hello_int); 13 | void hello(const float msg) const CPPMM_RENAME(hello_float); 14 | }; 15 | 16 | } // namespace hello 17 | 18 | } // namespace cppmm_bind 19 | -------------------------------------------------------------------------------- /tutorial/02_customizing_methods/include/hello.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace hello { 6 | 7 | class Hello { 8 | public: 9 | void hello(const char* msg) const { 10 | std::cout << "Hello, " << msg << "!\n"; 11 | } 12 | void hello(const int msg) const { std::cout << "Hello, " << msg << "!\n"; } 13 | void hello(const float msg) const { 14 | std::cout << "Hello, " << msg << "!\n"; 15 | } 16 | }; 17 | 18 | } // namespace hello 19 | -------------------------------------------------------------------------------- /tutorial/03_math/bind/c-math.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace cppmm_bind { 6 | 7 | namespace MYMATH_INTERNAL_NAMESPACE { 8 | 9 | namespace Mymath = ::MYMATH_INTERNAL_NAMESPACE; 10 | 11 | struct Vec3 { 12 | using BoundType = Mymath::Vec3; 13 | 14 | Vec3() CPPMM_RENAME(default); 15 | Vec3(float x, float y, float z) CPPMM_RENAME(new); 16 | Vec3(float v) CPPMM_RENAME(from_scalar); 17 | Vec3(const Mymath::Vec3& v) CPPMM_RENAME(copy); 18 | 19 | float length() const; 20 | } CPPMM_VALUETYPE; 21 | 22 | } // namespace MYMATH_INTERNAL_NAMESPACE 23 | 24 | } // namespace cppmm_bind 25 | -------------------------------------------------------------------------------- /tutorial/04_templates/include/math.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // Define the internal versioned namespace 4 | #define MYMATH_INTERNAL_NAMESPACE Mymath_1_1 5 | 6 | // Declare everything in the versioned namespace 7 | namespace MYMATH_INTERNAL_NAMESPACE { 8 | 9 | // A simple 3d vector type 10 | template struct Vec3 { 11 | T x; 12 | T y; 13 | T z; 14 | 15 | // Default 0-initialize 16 | Vec3() : x(0), y(0), z(0) {} 17 | // Initialize all members 18 | Vec3(T x, T y, T z) : x(x), y(y), z(z) {} 19 | // Initialize all members with a single value 20 | Vec3(T v) : x(v), y(v), z(v) {} 21 | // Copy constructor 22 | Vec3(const Vec3& v) : x(v.x), y(v.y), z(v.z) {} 23 | 24 | T length() const { return sqrt(x * x + y * y + z * z); } 25 | }; 26 | 27 | } // namespace MYMATH_INTERNAL_NAMESPACE 28 | 29 | // Pull all symbols into public namespace 30 | namespace Mymath { 31 | using namespace MYMATH_INTERNAL_NAMESPACE; 32 | } 33 | --------------------------------------------------------------------------------