Permalink
Browse files

Fixed reg_replace (again), and made the argument names more concise.

  • Loading branch information...
1 parent 44bea9d commit 53c1bbb1272568ae37d39f87d9273bc0024d54e4 @LadyCailin LadyCailin committed Oct 24, 2012
View
2 .logs/debug/2012-10-24-debug.log
@@ -0,0 +1,2 @@
+2012-10-24 10:59.40 - Unreachable code. Consider removing this code. Unknown File:1
+2012-10-24 10:59.40 - Unreachable code. Consider removing this code. Unknown File:1
View
60 src/main/java/com/laytonsmith/core/functions/ArrayHandling.java
@@ -13,8 +13,11 @@
import com.laytonsmith.core.functions.BasicLogic.equals_ic;
import com.laytonsmith.core.functions.Exceptions.ExceptionType;
import com.laytonsmith.core.natives.interfaces.ArrayAccess;
+import java.util.AbstractSet;
import java.util.ArrayList;
import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Random;
@@ -1468,4 +1471,61 @@ public CHVersion since() {
}
+
+// @api
+// public static class array_unique extends AbstractFunction{
+//
+// public ExceptionType[] thrown() {
+// return new ExceptionType[]{ExceptionType.CastException};
+// }
+//
+// public boolean isRestricted() {
+// return false;
+// }
+//
+// public Boolean runAsync() {
+// return null;
+// }
+//
+// public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
+// CArray array = Static.getArray(args[0], t);
+// boolean compareTypes = true;
+// if(args.length == 2){
+// compareTypes = Static.getBoolean(args[1]);
+// }
+//
+//
+//
+// }
+//
+// public String getName() {
+// return "array_unique";
+// }
+//
+// public Integer[] numArgs() {
+// return new Integer[]{1, 2};
+// }
+//
+// public String docs() {
+// return "array {array, [compareTypes]} Removes all non-unique values from an array. ---- compareTypes is true by default, which means that in the array"
+// + " array(1, '1'), nothing would be removed from the array, since both values are different data types. However, if compareTypes is true,"
+// + " then the first value would remain, but the second value would be removed. A reference to the array is returned, however, note that the removals"
+// + " are in-place, so the reference will be to the same array passed in. After values are removed, (if a normal array) the array will be resized"
+// + " down to fit the new size.";
+// }
+//
+// public CHVersion since() {
+// return CHVersion.V3_3_1;
+// }
+//
+// @Override
+// public ExampleScript[] examples() throws ConfigCompileException {
+// return new ExampleScript[]{
+// new ExampleScript("Basic usage", "array_unique(array(1, 2, 2, 3, 4))"),
+// new ExampleScript("No removal of different datatypes", "array_unique(array(1, '1'))"),
+// new ExampleScript("Removal of different datatypes, by setting compareTypes to false", "array_unique(array(1, '1'), false)"),
+// };
+// }
+//
+// }
}
View
4 src/main/java/com/laytonsmith/core/functions/Regex.java
@@ -228,8 +228,8 @@ public ParseTree optimizeDynamic(Target t, List<ParseTree> children) throws Conf
//Note the alternative order of arguments
ParseTree replace = new ParseTree(new CFunction("replace", t), data.getFileOptions());
replace.addChildAt(0, children.get(2)); //subject -> main
- replace.addChildAt(1, children.get(1)); //replacement -> that
- replace.addChildAt(2, new ParseTree(new CString(getLiteralRegex(pattern), t), replace.getFileOptions())); //pattern -> what
+ replace.addChildAt(1, new ParseTree(new CString(getLiteralRegex(pattern), t), replace.getFileOptions())); //pattern -> what
+ replace.addChildAt(2, children.get(1)); //replacement -> that
return replace;
} else {
getPattern(data.getData(), t);
View
2 src/main/java/com/laytonsmith/core/functions/StringHandling.java
@@ -302,7 +302,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance
}
public String docs() {
- return "string {main, what, that} Replaces all instances of 'what' with 'that' in 'main'";
+ return "string {subject, search, replacement} Replaces all instances of 'search' with 'replacement' in 'subject'";
}
public ExceptionType[] thrown() {

0 comments on commit 53c1bbb

Please sign in to comment.