diff --git a/cloner/.gitignore b/cloner/.gitignore deleted file mode 100644 index 4a9238b1..00000000 --- a/cloner/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bin/test/ \ No newline at end of file diff --git a/cloner/.travis.yml b/cloner/.travis.yml deleted file mode 100644 index cffcfeda..00000000 --- a/cloner/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: objective-c - -install: - - brew install neko haxe - - cd .. - - mkdir haxelib - - haxelib setup haxelib - - haxelib install hxcpp > /dev/null - - haxelib install hx3compat > /dev/null -before_script: - - cd $TRAVIS_BUILD_DIR -script: - - sh test.sh -e \ No newline at end of file diff --git a/cloner/appveyor.yml b/cloner/appveyor.yml deleted file mode 100644 index bd2bca94..00000000 --- a/cloner/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -version: "{build}" - -clone_folder: C:\projects\cloner - -environment: - global: - HAXELIB_ROOT: C:\projects\haxelib - -install: - # Install haxe and neko - - cinst neko --version 2.2.0 -y - - cinst haxe -y - - RefreshEnv - - neko -version - - haxe -version - # Setup haxelib - - mkdir "%HAXELIB_ROOT%" - - haxelib setup "%HAXELIB_ROOT%" - - haxelib install record-macros - - haxelib install hxcpp - -build_script: - - cd test - - haxe compile.hxml - - cd .. - -test_script: - - echo CPP - - bin\test\TestMain-debug.exe - - echo NEKO - - neko bin\test\TestMain.n - - diff --git a/cloner/haxelib.json b/cloner/haxelib.json deleted file mode 100644 index 5b13ea02..00000000 --- a/cloner/haxelib.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "cloner", - "url" : "https://github.com/thomasuster/cloner", - "license": "MIT", - "tags": ["clone", "copy", "deep"], - "description": "A deep copy algorithm for haxe", - "version": "1.0.0", - "classPath": "src/", - "releasenote": "", - "contributors": ["thomasuster"], - "dependencies": { - } -} \ No newline at end of file diff --git a/cloner/test.sh b/cloner/test.sh deleted file mode 100644 index 7a58e0e7..00000000 --- a/cloner/test.sh +++ /dev/null @@ -1,8 +0,0 @@ -set -e -cd test -haxe compile.hxml -cd .. -echo CPP -bin/test/TestMain-debug -echo NEKO -neko bin/test/TestMain.n \ No newline at end of file diff --git a/cloner/test/TestCloner.hx b/cloner/test/TestCloner.hx deleted file mode 100644 index ed8f1d06..00000000 --- a/cloner/test/TestCloner.hx +++ /dev/null @@ -1,94 +0,0 @@ -import classes.ClassTypeProperty; -import classes.ABCEnum; -import cloner.Cloner; -import classes.ArrayProperty; -import classes.ClassProperty; -import classes.BoolProperty; -import classes.NullClass; -class TestCloner extends haxe.unit.TestCase { - - var cloner:Cloner; - - override public function setup() { - cloner = new Cloner(); - } - - public function testclone() { - var value:NullClass = new NullClass(); - assertTrue(cloner.clone(value) != null); - } - - public function testBoolProperty() { - var value:BoolProperty = new BoolProperty(true); - assertTrue(cloner.clone(value).property); - } - - public function testArrayProperty() { - var value:ArrayProperty = new ArrayProperty([true]); - assertTrue(cloner.clone(value).property[0]); - } - - public function testStringMap():Void { - var value:Map = new Map(); - value.set('you',1); - assertTrue(cloner.clone(value).get('you') == 1); - } - - public function testIntMap():Void { - var value:Map = new Map(); - value.set(1,2); - assertTrue(cloner.clone(value).get(1) == 2); - } - - public function testObjectsInMap():Void { - var value:Map = new Map(); - var v:NullClass = new NullClass(); - value.set(1,v); - assertTrue(cloner.clone(value).get(1) != v); - } - - public function testString():Void { - assertTrue(cloner.clone('a') == 'a'); - } - - public function testClassType():Void { - assertTrue(cloner.clone(NullClass) == NullClass); - } - - public function testEnum():Void { - assertTrue(cloner.clone(ABCEnum.b) == ABCEnum.b); - } - - public function testClassProperty():Void { - var value:ClassProperty = new ClassProperty(); - var inValue = new BoolProperty(true); - value.property = inValue; - var outValue:BoolProperty = cloner.clone(value).property; - assertTrue(outValue.property); - assertFalse(inValue == outValue); - } - - public function testAnonObjectAreDifferentCopies():Void { - var value = { a: 10, b: 20 }; - var clone = cloner.clone(value); - Reflect.setField(value, 'a', 33); - assertEquals(10, Reflect.getProperty(clone, 'a')); - } - - public function testEmbededAnonObject():Void { - var inner = {b: 5}; - var value = { a: 10, inner: inner }; - var clone = cloner.clone(value); - Reflect.setField(inner, 'b', 33); - - var cloneInner = Reflect.getProperty(clone, 'inner'); - assertEquals(5, Reflect.getProperty(cloneInner, 'b')); - } - - public function testClassRefInsideAnObj():Void { - var value:ClassTypeProperty = new ClassTypeProperty(); - value.property = BoolProperty; - var outValue:ClassTypeProperty = cloner.clone(value); - assertEquals(outValue.property, BoolProperty); - } -} \ No newline at end of file diff --git a/cloner/test/TestClonerCache.hx b/cloner/test/TestClonerCache.hx deleted file mode 100644 index 8f7a7bca..00000000 --- a/cloner/test/TestClonerCache.hx +++ /dev/null @@ -1,35 +0,0 @@ -import cloner.Cloner; -import classes.ClassProperty; -import classes.BoolProperty; -class TestClonerCache extends haxe.unit.TestCase { - - var cloner:Cloner; - var input:Array; - var outcome:Array; - - override public function setup() { - cloner = new Cloner(); - } - - public function testReferences():Void { - setupOutcomeWithReferences(); - assertTrue(outcome[0].property == outcome[1].property); - } - - public function testNoSideEffects():Void { - setupOutcomeWithReferences(); - outcome[0].property = true; - outcome = cloner.clone(input); - assertFalse(outcome[0].property); - } - - function setupOutcomeWithReferences():Void { - var a:ClassProperty = new ClassProperty(); - var b:ClassProperty = new ClassProperty(); - var c:BoolProperty = new BoolProperty(); - a.property = c; - b.property = c; - input = [a, b]; - outcome = cloner.clone(input); - } -} \ No newline at end of file diff --git a/cloner/test/TestMain.hx b/cloner/test/TestMain.hx deleted file mode 100644 index 8257874f..00000000 --- a/cloner/test/TestMain.hx +++ /dev/null @@ -1,11 +0,0 @@ -import haxe.unit.TestRunner; -class TestMain { - - static function main() { - var runner:TestRunner = new TestRunner(); - runner.add(new TestCloner()); - runner.add(new TestClonerCache()); - runner.run(); - } - -} \ No newline at end of file diff --git a/cloner/test/classes/ABCEnum.hx b/cloner/test/classes/ABCEnum.hx deleted file mode 100644 index 7b3769a6..00000000 --- a/cloner/test/classes/ABCEnum.hx +++ /dev/null @@ -1,6 +0,0 @@ -package classes; -enum ABCEnum { - a; - b; - c; -} \ No newline at end of file diff --git a/cloner/test/classes/ArrayProperty.hx b/cloner/test/classes/ArrayProperty.hx deleted file mode 100644 index bc103bcb..00000000 --- a/cloner/test/classes/ArrayProperty.hx +++ /dev/null @@ -1,7 +0,0 @@ -package classes; -class ArrayProperty { - public var property:Array; - public function new(v:Array):Void { - property = v; - } -} \ No newline at end of file diff --git a/cloner/test/classes/BoolProperty.hx b/cloner/test/classes/BoolProperty.hx deleted file mode 100644 index e90c2e07..00000000 --- a/cloner/test/classes/BoolProperty.hx +++ /dev/null @@ -1,7 +0,0 @@ -package classes; -class BoolProperty { - public var property:Bool; - public function new(v:Bool=false):Void { - property = v; - } -} \ No newline at end of file diff --git a/cloner/test/classes/ClassProperty.hx b/cloner/test/classes/ClassProperty.hx deleted file mode 100644 index c6f9be8e..00000000 --- a/cloner/test/classes/ClassProperty.hx +++ /dev/null @@ -1,5 +0,0 @@ -package classes; -class ClassProperty { - public var property:Dynamic; - public function new():Void {} -} \ No newline at end of file diff --git a/cloner/test/classes/ClassTypeProperty.hx b/cloner/test/classes/ClassTypeProperty.hx deleted file mode 100644 index 982a225c..00000000 --- a/cloner/test/classes/ClassTypeProperty.hx +++ /dev/null @@ -1,5 +0,0 @@ -package classes; -class ClassTypeProperty { - public var property:Class; - public function new():Void {} -} \ No newline at end of file diff --git a/cloner/test/classes/NullClass.hx b/cloner/test/classes/NullClass.hx deleted file mode 100644 index 8b0783c1..00000000 --- a/cloner/test/classes/NullClass.hx +++ /dev/null @@ -1,4 +0,0 @@ -package classes; -class NullClass { - public function new():Void {} -} \ No newline at end of file diff --git a/cloner/test/compile.hxml b/cloner/test/compile.hxml deleted file mode 100644 index 79c1a2aa..00000000 --- a/cloner/test/compile.hxml +++ /dev/null @@ -1,15 +0,0 @@ --cp . --cp ../src --lib hx3compat --main TestMain --debug --cpp ../bin/test - ---next - --cp . --cp ../src --lib hx3compat --main TestMain --debug --neko ../bin/test/TestMain.n \ No newline at end of file diff --git a/kiss/src/kiss/EmbeddedScript.hx b/kiss/src/kiss/EmbeddedScript.hx index daa6842a..b0655d3d 100644 --- a/kiss/src/kiss/EmbeddedScript.hx +++ b/kiss/src/kiss/EmbeddedScript.hx @@ -7,7 +7,7 @@ import haxe.macro.PositionTools; import sys.io.File; #end import kiss.Kiss; -import cloner.Cloner; +import kiss.cloner.Cloner; typedef Command = () -> Void; @@ -183,7 +183,7 @@ class EmbeddedScript { for (command in commands) { // a fork needs to be a thorough copy that includes all of the EmbeddedScript subclass's // fields, otherwise DSL state will be lost when forking, which is unacceptable - var fork = new cloner.Cloner().clone(this); + var fork = new kiss.cloner.Cloner().clone(this); fork.instructions[instructionPointer] = command; fork.run(); fork; diff --git a/cloner/src/cloner/Cloner.hx b/kiss/src/kiss/cloner/Cloner.hx similarity index 90% rename from cloner/src/cloner/Cloner.hx rename to kiss/src/kiss/cloner/Cloner.hx index e7568c94..41ea91d2 100644 --- a/cloner/src/cloner/Cloner.hx +++ b/kiss/src/kiss/cloner/Cloner.hx @@ -1,4 +1,4 @@ -package cloner; +package kiss.cloner; import Array; import haxe.ds.ObjectMap; import Type.ValueType; @@ -102,7 +102,12 @@ class Cloner { for (i in 0...fields.length) { var field = fields[i]; var property = Reflect.getProperty(inValue, field); - Reflect.setField(outValue, field, _clone(property)); + try { + Reflect.setField(outValue, field, _clone(property)); + } catch (s) { + // There will be errors on C++ when trying to assign to a member function. + // They're not important, because the function will already be on the clone. + } } return outValue; } diff --git a/cloner/LICENSE.md b/kiss/src/kiss/cloner/LICENSE.md similarity index 100% rename from cloner/LICENSE.md rename to kiss/src/kiss/cloner/LICENSE.md diff --git a/cloner/src/cloner/MapCloner.hx b/kiss/src/kiss/cloner/MapCloner.hx similarity index 93% rename from cloner/src/cloner/MapCloner.hx rename to kiss/src/kiss/cloner/MapCloner.hx index 9ee4db12..59ced48d 100644 --- a/cloner/src/cloner/MapCloner.hx +++ b/kiss/src/kiss/cloner/MapCloner.hx @@ -1,6 +1,6 @@ -package cloner; +package kiss.cloner; import haxe.Constraints.IMap; -import cloner.Cloner; +import kiss.cloner.Cloner; import Type.ValueType; class MapCloner{ diff --git a/cloner/README.md b/kiss/src/kiss/cloner/README.md similarity index 100% rename from cloner/README.md rename to kiss/src/kiss/cloner/README.md diff --git a/projects/aoc/test.sh b/projects/aoc/test.sh index 7d998f43..0ee8ae95 100755 --- a/projects/aoc/test.sh +++ b/projects/aoc/test.sh @@ -1,4 +1,3 @@ #! /bin/bash -haxelib dev kiss ../../kiss haxe build.hxml \ No newline at end of file diff --git a/projects/file-watch/test.sh b/projects/file-watch/test.sh index 23a938cb..206d2a7d 100755 --- a/projects/file-watch/test.sh +++ b/projects/file-watch/test.sh @@ -1,6 +1,5 @@ #! /bin/bash -haxelib dev kiss ../../kiss echo "" > test-output.txt expected=$'hey\nhey\nhey' if [[ $(uname) == *"MINGW"* ]] || [ $TRAVIS_OS_NAME = "windows" ]; then diff --git a/projects/pdf-salad/test.sh b/projects/pdf-salad/test.sh index 31dfce11..998c0b91 100755 --- a/projects/pdf-salad/test.sh +++ b/projects/pdf-salad/test.sh @@ -9,5 +9,4 @@ if [ ! -z "$TRAVIS_OS_NAME" ]; then npm install pdf-lib haxelib install hxnodejs fi -haxelib dev kiss ../../kiss haxe build.hxml \ No newline at end of file diff --git a/template/test.sh b/template/test.sh index 9eca0367..0ee8ae95 100755 --- a/template/test.sh +++ b/template/test.sh @@ -1,4 +1,3 @@ #! /bin/bash -haxelib dev kiss ../../ haxe build.hxml \ No newline at end of file diff --git a/test-projects.sh b/test-projects.sh index 533fd726..70756e72 100755 --- a/test-projects.sh +++ b/test-projects.sh @@ -9,6 +9,7 @@ fi for PROJECT_DIR in $PROJECT_DIRS do if [ ! -z "${TRAVIS_OS_NAME}" ]; then + haxelib dev kiss kiss (cd $PROJECT_DIR && haxelib install all) fi