From 5dfb83005975a43f8144d56769410f878ec2009d Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 20 Jul 2021 16:41:08 -0600 Subject: [PATCH] fix C# fork() error --- build-scripts/cs/test-cs.sh | 2 +- src/kiss/EmbeddedScript.hx | 3 ++- src/kiss/cloner/Cloner.hx | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build-scripts/cs/test-cs.sh b/build-scripts/cs/test-cs.sh index 80bc7a6..64d417e 100644 --- a/build-scripts/cs/test-cs.sh +++ b/build-scripts/cs/test-cs.sh @@ -1,2 +1,2 @@ #! /bin/bash -mono bin/cs/test/bin/TestMain.exe || echo "C# tests failed" \ No newline at end of file +mono bin/cs/test/bin/TestMain.exe \ No newline at end of file diff --git a/src/kiss/EmbeddedScript.hx b/src/kiss/EmbeddedScript.hx index 8be5bc4..b389fef 100644 --- a/src/kiss/EmbeddedScript.hx +++ b/src/kiss/EmbeddedScript.hx @@ -212,7 +212,8 @@ class EmbeddedScript { var fork = new kiss.cloner.Cloner().clone(this); fork.instructions[instructionPointer] = command; if (fork.breakPoints == null) { - throw 'cloning failed'; + // This field is so much trouble to clone in C# because of its type + fork.breakPoints = [for (point => condition in this.breakPoints) point => condition]; } // trace('running a fork from ' + Std.string(instructionPointer + 1)); fork.run(); diff --git a/src/kiss/cloner/Cloner.hx b/src/kiss/cloner/Cloner.hx index 3473477..801b47a 100644 --- a/src/kiss/cloner/Cloner.hx +++ b/src/kiss/cloner/Cloner.hx @@ -100,13 +100,12 @@ class Cloner { var classValue = Type.getClass(inValue); var outValue:T = Type.createEmptyInstance(classValue); var fields:Array = Type.getInstanceFields(classValue); - for (i in 0...fields.length) { - var field = fields[i]; + for (field in fields) { var property = Reflect.getProperty(inValue, field); try { Reflect.setField(outValue, field, _clone(property)); } catch (s) { - // There will be errors on C++ when trying to assign to a member function. + // There will be errors on C++ and C# when trying to assign to a member function. // They're not important, because the function will already be on the clone. } }