Append allocation and generics fixes

This commit is contained in:
Simon Lübeß
2025-01-31 13:17:12 +01:00
parent 577cca5886
commit 2f0505241f
6 changed files with 15 additions and 20 deletions
+5 -3
View File
@@ -10,7 +10,7 @@ using internal GlitchyEngine.Scripting;
class SharpClass : RefCounter
{
protected String _fullName ~ delete:append _;
protected String _fullName ~ delete _; // TODO APPEND
protected StringView _namespace;
protected StringView _className;
@@ -24,7 +24,10 @@ class SharpClass : RefCounter
[AllowAppend]
public this(StringView classNamespace, StringView className, MonoImage* image)
{
String fullName = append $"{classNamespace}.{className}";
// TODO APPEND
String fullName = new String(classNamespace.Length + 1 + className.Length);
//append $"{classNamespace}.{className}";
fullName.AppendF($"{classNamespace}.{className}");
_fullName = fullName;
_namespace = _fullName.Substring(0, classNamespace.Length);
@@ -66,7 +69,6 @@ class ScriptClass : SharpClass
_onCreate = (OnCreateMethod)GetMethodThunk("OnCreate");
_onUpdate = (OnUpdateMethod)GetMethodThunk("OnUpdate", 1);
_onDestroy = (OnDestroyMethod)GetMethodThunk("OnDestroy");
_onCollisionEnter2D = (.)GetMethodThunk("OnCollisionEnter2D", 1);
_onCollisionLeave2D = (.)GetMethodThunk("OnCollisionLeave2D", 1);
+2 -2
View File
@@ -14,7 +14,7 @@ using internal GlitchyEngine.Scripting;
class EngineClasses
{
// TODO: Not all of there are actually ScriptClasses (actually none of them are...)
// TODO: Not all of these are actually ScriptClasses (actually none of them are...)
private ScriptClass s_ComponentRoot ~ _?.ReleaseRef();
private ScriptClass s_EntityRoot ~ _?.ReleaseRef();
@@ -90,7 +90,7 @@ static class ScriptEngine
private static Scene s_Context ~ _?.ReleaseRef();
private static append EngineClasses _classes = .();
private static EngineClasses _classes = new .() ~ delete _;
public static EngineClasses Classes => _classes;