feat(nativegen)!: refactor to struct-based native wrappers

Major overhaul of native wrapper generation for ufbx and nvtt.
Replaces all hand-written and class-based wrappers with auto-generated partial struct wrappers that directly expose native API methods via pointers. Introduces a new JSON-driven configuration system using "remaps" and "actions" for flexible parameter/return mapping and method routing. Removes legacy config sections and helper classes, focusing solely on method wrappers. Updates all usages and tests to use the new pointer-based API. Cleans up obsolete code and ensures resource management is handled via struct Dispose methods. The result is a thinner, more direct, and maintainable interop layer.

BREAKING CHANGE: All managed wrapper classes and helpers are removed in favor of struct-based pointer wrappers. API usage and resource management patterns have changed.
This commit is contained in:
2026-03-15 20:48:54 +09:00
parent 3e4084c42a
commit 6cadd8edeb
278 changed files with 5387 additions and 12057 deletions

View File

@@ -0,0 +1,96 @@
{
"libraryName": "nvtt",
"nativeNamespace": "Ghost.Nvtt",
"outputNamespace": "Ghost.Nvtt",
"nativeTypePrefix": "Nvtt",
"skipTypes": [
"NativeAnnotationAttribute",
"NativeTypeNameAttribute"
],
"skipFunctions": [],
"remaps": [
{
// sbyte* parameters whose names match name/filename/path/prop patterns
// get remapped to ReadOnlySpan<byte>, with a fixed() wrapper and _len sibling consumed.
"src": "sbyte*",
"dst": "ReadOnlySpan<byte>",
"scope": [ "parameter" ],
"filter": [ ".*name", ".*filename", ".*path", ".*prop$" ],
"adapter": {
"convertBack": {
"wrapCall": "fixed (byte* p$arg = $arg) { $CALL }",
"passAs": "(sbyte*)p$arg"
}
}
}
],
"actions": [
{
// Dispose pattern: void return + T* param + name matches .*Destroy<Struct> → IDisposable.Dispose on T
// Must come BEFORE the general INSTANCE_METHOD rule so it matches first.
"comment": "Dispose pattern: void return + T* param → Dispose method on T",
"filter": "EXTERN_API",
"conditions": [ "VOID_RETURN", "SELF_PTR", "NAME_CONDITION(.*Destroy$TBare)" ],
"targetType": "FIRST_PARAM_TYPE",
"apply": [
{
"type": "INSTANCE_METHOD",
"opts": {
"removeFirstParam": true,
"passAs": "($TSelf*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)",
"name": {
"set": "Dispose"
}
}
},
{
"type": "INHERITANCE",
"opts": {
"baseType": [ "System.IDisposable" ]
}
}
]
},
{
// Instance method: first param is T* of a known binding struct → method on T
"comment": "First param is T* of a known binding struct → instance method on T",
"filter": "EXTERN_API",
"conditions": [ "SELF_PTR" ],
"targetType": "FIRST_PARAM_TYPE",
"apply": {
"type": "INSTANCE_METHOD",
"opts": {
"removeFirstParam": true,
"passAs": "($TSelf*)System.Runtime.CompilerServices.Unsafe.AsPointer(ref this)",
// Change "nvttCreateSurface" to "Create"
"name": {
"remove": [
"PREFIX",
"NO_PREFIX($TSelf)" // NO_PREFIX(NvttSurface) will change "NvttSurface" to "Surface", the prefix is determined by the "nativeTypePrefix" field at the top level of this config
]
}
}
}
},
{
// Static method: first param is NOT a known struct pointer, but return type is T* → static on T
"comment": "Return type is T* of a known binding struct → static method on T",
"filter": "EXTERN_API",
"conditions": [ "FIRST_PARAM_OTHER_TYPE", "RETURN_BINDING_TYPE" ],
"targetType": "RETURN_TYPE",
"apply": {
"type": "STATIC_METHOD",
"opts": {
"name": {
"remove": [
"PREFIX",
"NO_PREFIX($TSelf)"
]
}
}
}
}
]
}