1
0

feat: update BMapSharp binding

This commit is contained in:
2026-02-06 17:52:13 +08:00
parent 37b8f2d023
commit c379c00a3f
4 changed files with 523 additions and 400 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@ def _get_libcmo21_repo_directory() -> Path:
def get_input_file_path() -> Path:
return _get_libcmo21_repo_directory() / "BMap" / "BMap" / "BMExports.hpp"
return _get_libcmo21_repo_directory() / "Ballance" / "BMap" / "BMap" / "BMExports.hpp"
def _get_bmap_binder_directory() -> Path:

View File

@@ -32,6 +32,7 @@ CPP_PY_TYPE_MAP: dict[str, str] = {
"VXSHADE_MODE": "enum",
"VXCMPFUNC": "enum",
"VXMESH_LITMODE": "enum",
"CK_CAMERA_PROJECTION": "enum",
}
CS_ENUM_LIKE: set[str] = set((
@@ -46,6 +47,7 @@ CS_ENUM_LIKE: set[str] = set((
"VXSHADE_MODE",
"VXCMPFUNC",
"VXMESH_LITMODE",
"CK_CAMERA_PROJECTION",
))
@dataclass(frozen=True)
@@ -108,10 +110,12 @@ class RenderUtils:
# only allow 0 and 1 pointer level for string.
match vt_pointer_level:
case 0:
marshal_as = f'UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "{direction_cookie}"'
marshaler = 'BMOwnedStringMarshaler' if param.is_input else 'BMStringMarshaler'
marshal_as = f'UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof({marshaler})'
cs_type = "string"
case 1:
marshal_as = f'UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringArrayMarshaler), MarshalCookie = "{direction_cookie}"'
marshaler = 'BMOwnedStringArrayMarshaler' if param.is_input else 'BMStringArrayMarshaler'
marshal_as = f'UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof({marshaler})'
cs_type = "string[]"
case "CKDWORD":
if vt_pointer_level == 0:

View File

@@ -4,7 +4,7 @@
/// <param name="{{ param.var_name }}">Direction: {% if param.is_input -%} input {%- else -%} output {%- endif %}. C++ type: {{ param.var_type.to_c_type() }}. {{ param.var_desc }}</param>
{%- endfor %}
/// <returns>True if no error, otherwise False.</returns>
[DllImport(g_DllName, EntryPoint = "{{ fct.fct_name }}", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
[DllImport(DLL_NAME, EntryPoint = "{{ fct.fct_name }}", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.U1)]
internal static extern bool {{ fct.fct_name }}(
{%- for param in fct.fct_params -%}