Skip to content
Permalink
Browse files

Override deepClone in CByteArray to allow cloning byte_arrays

  • Loading branch information
LadyCailin committed Mar 16, 2020
1 parent 1101071 commit 74d1485790725520e7bc757dee072297f27eefcb
@@ -600,7 +600,7 @@ public CArray deepClone(Target t) {
return deepClone(this, t, new ArrayList<>());
}

private static CArray deepClone(CArray array, Target t, ArrayList<CArray[]> cloneRefs) {
protected CArray deepClone(CArray array, Target t, ArrayList<CArray[]> cloneRefs) {

// Return the clone reference if this array has been cloned before (both clones will have the same reference).
for(CArray[] refCouple : cloneRefs) {
@@ -18,6 +18,7 @@
import java.util.Set;
import java.util.SortedMap;
import com.laytonsmith.core.natives.interfaces.Sizeable;
import java.util.ArrayList;
import java.util.EnumSet;

/**
@@ -495,6 +496,15 @@ public boolean isAssociative() {
throw new UnsupportedOperationException("Not supported.");
}

@Override
protected CArray deepClone(CArray array, Target t, ArrayList<CArray[]> cloneRefs) {
CByteArray that = (CByteArray) array;
byte[] original = that.data.array();
byte[] newArray = new byte[that.maxValue];
System.arraycopy(original, 0, newArray, 0, that.maxValue);
return CByteArray.wrap(newArray, t);
}

@Override
public Mixed get(Mixed index, Target t) throws ConfigRuntimeException {
int i = Static.getInt32(index, t);
@@ -1,6 +1,8 @@
== Developing an extension ==

Extensions provide a means of adding functionality to CommandHelper and the MethodScript engine. While the API used is under construction still, it is still deemed stable enough for production use. Any breakages will be minimal, and deprecation will be used where it applies.
Extensions provide a means of adding functionality to CommandHelper and the MethodScript engine. While the API used is
under construction still, it is still deemed stable enough for production use. Any breakages will be minimal, and
deprecation will be used where it applies.

An extension currently consists of three core parts:

0 comments on commit 74d1485

Please sign in to comment.
You can’t perform that action at this time.