Skip to content

Commit

Permalink
Fixed a possible casting issue, switched to collection expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Apr 9, 2024
1 parent 380cb50 commit 033db78
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void SendDialog(DialogType type, string title, string message, IReadOnlyL

private void SendDialogNative(ReadOnlySpan<char> type, ReadOnlySpan<char> title, ReadOnlySpan<char> message, IReadOnlyList<DialogFileFilter> filters, Action<string> onResult)
{
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
static void Callback(param_ptr* p_ptr, param_string* p_result)
{
Logger.LogInput($"{nameof(SendDialogNative)}_{nameof(Callback)}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Bannerlord.LauncherManager.Native;

public static unsafe partial class Bindings
{
[UnmanagedCallersOnly(EntryPoint = "bfv_get_change_set", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bfv_get_change_set", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_uint32* GetChangeSet([IsConst<IsPtrConst>] param_string* p_game_folder_path, [IsConst<IsPtrConst>] param_string* p_lib_assembly)
{
Logger.LogInput(p_game_folder_path, p_lib_assembly);
Expand All @@ -32,7 +32,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bfv_get_version", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bfv_get_version", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_string* GetVersion([IsConst<IsPtrConst>] param_string* p_game_folder_path, [IsConst<IsPtrConst>] param_string* p_lib_assembly)
{
Logger.LogInput(p_game_folder_path, p_lib_assembly);
Expand All @@ -53,7 +53,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bfv_get_version_type", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bfv_get_version_type", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_uint32* GetVersionType([IsConst<IsPtrConst>] param_string* p_game_folder_path, [IsConst<IsPtrConst>] param_string* p_lib_assembly)
{
Logger.LogInput(p_game_folder_path, p_lib_assembly);
Expand Down
79 changes: 42 additions & 37 deletions src/Bannerlord.LauncherManager.Native/Bindings.LauncherManager.cs

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/Bannerlord.LauncherManager.Native/Bindings.ModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static unsafe partial class Bindings

private static readonly ApplicationVersionComparer _applicationVersionComparer = new();

[UnmanagedCallersOnly(EntryPoint = "bmm_sort", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_sort", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* Sort([IsConst<IsPtrConst>] param_json* p_source)
{
Logger.LogInput(p_source);
Expand All @@ -46,7 +46,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_sort_with_options", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_sort_with_options", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* SortWithOptions([IsConst<IsPtrConst>] param_json* p_source, [IsConst<IsPtrConst>] param_json* p_options)
{
Logger.LogInput(p_source, p_options);
Expand All @@ -68,7 +68,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_are_all_dependencies_of_module_present", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_are_all_dependencies_of_module_present", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_bool* AreAllDependenciesOfModulePresent([IsConst<IsPtrConst>] param_json* p_source, [IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_source, p_module);
Expand All @@ -90,7 +90,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependent_modules_of", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependent_modules_of", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependentModulesOf([IsConst<IsPtrConst>] param_json* p_source, [IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_source, p_module);
Expand All @@ -111,7 +111,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependent_modules_of_with_options", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependent_modules_of_with_options", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependentModulesOfWithOptions([IsConst<IsPtrConst>] param_json* p_source, [IsConst<IsPtrConst>] param_json* p_module, [IsConst<IsPtrConst>] param_json* p_options)
{
Logger.LogInput(p_source, p_module, p_options);
Expand All @@ -134,7 +134,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_validate_module", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_validate_module", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* ValidateModule([IsConst<IsPtrConst>] param_ptr* p_owner, [IsConst<IsPtrConst>] param_json* p_modules, [IsConst<IsPtrConst>] param_json* p_target_module,
[ConstMeta<IsConst<IsPtrConst>, IsConst<IsPtrConst>, IsNotConst<IsPtrConst>>]
delegate* unmanaged[Cdecl]<param_ptr*, param_string*, return_value_bool*> p_is_selected)
Expand Down Expand Up @@ -171,7 +171,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_validate_load_order", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_validate_load_order", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* ValidateLoadOrder([IsConst<IsPtrConst>] param_json* p_modules, [IsConst<IsPtrConst>] param_json* p_target_module)
{
Logger.LogInput(p_modules, p_target_module);
Expand All @@ -193,7 +193,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_enable_module", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_enable_module", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_void* EnableModule([IsConst<IsPtrConst>] param_ptr* p_owner, [IsConst<IsPtrConst>] param_json* p_module, [IsConst<IsPtrConst>] param_json* p_target_module,
[ConstMeta<IsConst<IsPtrConst>, IsConst<IsPtrConst>, IsNotConst<IsPtrConst>>]
delegate* unmanaged[Cdecl]<param_ptr*, param_string*, return_value_bool*> p_get_selected,
Expand Down Expand Up @@ -273,7 +273,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_disable_module", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_disable_module", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_void* DisableModule([IsConst<IsPtrConst>] param_ptr* p_owner, [IsConst<IsPtrConst>] param_json* p_module, [IsConst<IsPtrConst>] param_json* p_target_module,
[ConstMeta<IsConst<IsPtrConst>, IsConst<IsPtrConst>, IsNotConst<IsPtrConst>>]
delegate* unmanaged[Cdecl]<param_ptr*, param_string*, return_value_bool*> p_get_selected,
Expand Down Expand Up @@ -354,7 +354,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_get_module_info", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_module_info", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetModuleInfo([IsConst<IsPtrConst>] param_string* p_xml_content)
{
Logger.LogInput(p_xml_content);
Expand All @@ -375,7 +375,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_get_module_info_with_path", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_module_info_with_path", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetModuleInfoWithPath([IsConst<IsPtrConst>] param_string* p_xml_content, [IsConst<IsPtrConst>] param_string* p_path)
{
Logger.LogInput(p_xml_content, p_path);
Expand All @@ -397,7 +397,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_get_sub_module_info", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_sub_module_info", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetSubModuleInfo([IsConst<IsPtrConst>] param_string* p_xml_content)
{
Logger.LogInput(p_xml_content);
Expand All @@ -423,7 +423,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_parse_application_version", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_parse_application_version", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* ParseApplicationVersion([IsConst<IsPtrConst>] param_string* p_application_version)
{
Logger.LogInput(p_application_version);
Expand All @@ -440,7 +440,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "bmm_compare_versions", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_compare_versions", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_int32* CompareVersions([IsConst<IsPtrConst>] param_json* p_x, [IsConst<IsPtrConst>] param_json* p_y)
{
Logger.LogInput(p_x, p_y);
Expand All @@ -462,7 +462,7 @@ public static unsafe partial class Bindings
}


[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_all", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_all", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependenciesAll([IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_module);
Expand All @@ -481,7 +481,7 @@ public static unsafe partial class Bindings
return return_value_json.AsException(e, false);
}
}
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_load_before_this", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_load_before_this", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependenciesLoadBeforeThis([IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_module);
Expand All @@ -500,7 +500,7 @@ public static unsafe partial class Bindings
return return_value_json.AsException(e, false);
}
}
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_load_after_this", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_load_after_this", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependenciesLoadAfterThis([IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_module);
Expand All @@ -519,7 +519,7 @@ public static unsafe partial class Bindings
return return_value_json.AsException(e, false);
}
}
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_incompatibles", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "bmm_get_dependencies_incompatibles", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* GetDependenciesIncompatibles([IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_module);
Expand Down
6 changes: 3 additions & 3 deletions src/Bannerlord.LauncherManager.Native/Bindings.Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Bannerlord.LauncherManager.Native;

public static unsafe partial class Bindings
{
[UnmanagedCallersOnly(EntryPoint = "common_alloc", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "common_alloc", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static void* CommonAlloc(nuint size)
{
Logger.LogInput(size);
Expand All @@ -26,7 +26,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "common_dealloc", CallConvs = new[] { typeof(CallConvCdecl) })]
[UnmanagedCallersOnly(EntryPoint = "common_dealloc", CallConvs = [typeof(CallConvCdecl)])]
public static void Common_Dealloc([IsConst<IsPtrConst>] param_ptr* ptr)
{
Logger.LogInput(ptr);
Expand All @@ -42,7 +42,7 @@ public static void Common_Dealloc([IsConst<IsPtrConst>] param_ptr* ptr)
}
}

[UnmanagedCallersOnly(EntryPoint = "common_alloc_alive_count", CallConvs = new[] { typeof(CallConvCdecl) })]
[UnmanagedCallersOnly(EntryPoint = "common_alloc_alive_count", CallConvs = [typeof(CallConvCdecl)])]
public static int CommonAllocAliveCount()
{
Logger.LogInput();
Expand Down
4 changes: 2 additions & 2 deletions src/Bannerlord.LauncherManager.Native/Bindings.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Bannerlord.LauncherManager.Native;

public static unsafe partial class Bindings
{
[UnmanagedCallersOnly(EntryPoint = "utils_is_load_order_correct", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "utils_is_load_order_correct", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_json* IsLoadOrderCorrect([IsConst<IsPtrConst>] param_json* p_modules)
{
Logger.LogInput(p_modules);
Expand All @@ -31,7 +31,7 @@ public static unsafe partial class Bindings
}
}

[UnmanagedCallersOnly(EntryPoint = "utils_get_dependency_hint", CallConvs = new[] { typeof(CallConvCdecl) }), IsNotConst<IsPtrConst>]
[UnmanagedCallersOnly(EntryPoint = "utils_get_dependency_hint", CallConvs = [typeof(CallConvCdecl)]), IsNotConst<IsPtrConst>]
public static return_value_string* GetDependencyHint([IsConst<IsPtrConst>] param_json* p_module)
{
Logger.LogInput(p_module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ public ModuleViewModel(ModuleInfoExtendedWithPath moduleInfoExtended, bool isVal
ModuleInfoExtended = moduleInfoExtended;
IsValid = isValid;
}

}

0 comments on commit 033db78

Please sign in to comment.