Skip to content

Commit faa85cf

Browse files
committed
Remove missing and obsolete methods
1 parent cc4143b commit faa85cf

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

Editor/EcsactRuntimeBuilder.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
using System.IO;
44
using System.Diagnostics;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using Ecsact.Editor;
78

9+
#nullable enable
10+
811
[System.Serializable]
912
struct MessageBase {
1013
public string type;
@@ -44,12 +47,13 @@ struct SuccessMessage {
4447
struct ModuleMethodsMessage {
4548
[System.Serializable]
4649
public struct MethodInfo {
50+
public string method_name;
4751
public bool available;
4852
}
4953

5054
public const string type = "module_methods";
5155
public string module_name;
52-
public Dictionary<string, MethodInfo> methods;
56+
public List<MethodInfo> methods;
5357
}
5458

5559
[System.Serializable]
@@ -284,12 +288,59 @@ private static void ReceiveMessage
284288
UnityEngine.Debug.Log(message.content);
285289
}
286290

291+
private static void CheckMethods
292+
( IEnumerable<string> methods
293+
, ModuleMethodsMessage message
294+
)
295+
{
296+
var methodsList = methods.ToList();
297+
298+
foreach(var methodName in methods) {
299+
var methodInfoIndex = message.methods.FindIndex(
300+
v => v.method_name == methodName
301+
);
302+
if(methodInfoIndex == -1) {
303+
UnityEngine.Debug.LogWarning(
304+
$"Old method '{methodName}' should be <color=red>removed</color> " +
305+
$"from module <b>{message.module_name}</b>. It no longer exists. " +
306+
"(reported by ecsact_rtb)"
307+
);
308+
}
309+
}
310+
311+
foreach(var methodInfo in message.methods) {
312+
var methodName = methodInfo.method_name;
313+
if(!methods.Contains(methodName)) {
314+
UnityEngine.Debug.LogWarning(
315+
$"New method '{methodName}' should be <color=green>added</color> " +
316+
$"to module <b>{message.module_name}</b>. (reported by ecsact_rtb)"
317+
);
318+
}
319+
}
320+
}
321+
287322
private static void ReceiveMessage
288323
( int progressId
289324
, ModuleMethodsMessage message
290325
)
291326
{
292-
327+
switch(message.module_name) {
328+
case "core":
329+
CheckMethods(EcsactRuntime.Core.methods, message);
330+
break;
331+
case "dynamic":
332+
CheckMethods(EcsactRuntime.Dynamic.methods, message);
333+
break;
334+
case "meta":
335+
CheckMethods(EcsactRuntime.Meta.methods, message);
336+
break;
337+
case "static":
338+
CheckMethods(EcsactRuntime.Static.methods, message);
339+
break;
340+
case "serialize":
341+
CheckMethods(EcsactRuntime.Serialize.methods, message);
342+
break;
343+
}
293344
}
294345

295346
private static void ReceiveMessage

Runtime/Ecsact.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace Ecsact {
1212
/// <summary>Ecsact Component Marker Interface</summary>
1313
public interface Component {}
1414

15+
/// <summary>Ecsact Transient Marker Interface</summary>
16+
public interface Transient {}
17+
1518
/// <summary>Ecsact Action Marker Interface</summary>
1619
public interface Action {}
1720

Runtime/EcsactRuntime.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public enum AsyncError : Int32 {
2525

2626
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
2727
internal static class NativeLibrary {
28+
private static Dictionary<IntPtr, string> libraryPaths = new();
29+
2830
[DllImport("Kernel32.dll",
2931
EntryPoint = "LoadLibrary",
3032
CharSet = CharSet.Ansi,
@@ -56,14 +58,20 @@ public static IntPtr Load
5658
( string libraryPath
5759
)
5860
{
59-
return LoadLibrary(libraryPath);
61+
UnityEngine.Debug.Log($"Loading Ecsact Runtime: {libraryPath}");
62+
var libIntPtr = LoadLibrary(libraryPath);
63+
libraryPaths.Add(libIntPtr, libraryPath);
64+
return libIntPtr;
6065
}
6166

6267
public static void Free
6368
( IntPtr handle
6469
)
6570
{
71+
var libraryPath = libraryPaths[handle];
72+
UnityEngine.Debug.Log($"Unloading Ecsact Runtime: {libraryPath}");
6673
FreeLibrary(handle);
74+
libraryPaths.Remove(handle);
6775
}
6876

6977
public static bool TryGetExport

0 commit comments

Comments
 (0)