More jiggery pokery to create blank TypedArray instances of the proper type
when we encounter the pattern "new SomeClass[0]". Le whee! git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4410 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -61,9 +61,19 @@ public class ActionScriptSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setInitialValue (String initValue) {
|
public void setInitialValue (String initValue) {
|
||||||
|
// if we're a typed array and we're being set to "new Something[0]"
|
||||||
|
// then convert that
|
||||||
|
if (definition.indexOf("TypedArray") != -1) {
|
||||||
|
Matcher m = ARRAYINIT.matcher(initValue);
|
||||||
|
if (m.matches()) {
|
||||||
|
initValue = "TypedArray.create(" + m.group(1) + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// do not-very-smart array conversion
|
// do not-very-smart array conversion
|
||||||
initValue = initValue.replaceAll("\\{", "[");
|
initValue = initValue.replaceAll("\\{", "[");
|
||||||
initValue = initValue.replaceAll("\\}", "]");
|
initValue = initValue.replaceAll("\\}", "]");
|
||||||
|
|
||||||
// stick the initial value before the semicolon
|
// stick the initial value before the semicolon
|
||||||
definition = definition.substring(0, definition.length()-1) +
|
definition = definition.substring(0, definition.length()-1) +
|
||||||
" = " + initValue + ";";
|
" = " + initValue + ";";
|
||||||
@@ -988,4 +998,6 @@ public class ActionScriptSource
|
|||||||
".*(?:public|protected)" +
|
".*(?:public|protected)" +
|
||||||
"(?:\\s+/\\*\\s*abstract\\s*\\*/)?" +
|
"(?:\\s+/\\*\\s*abstract\\s*\\*/)?" +
|
||||||
"\\s+function\\s+([a-zA-Z]\\w*) \\(.*");
|
"\\s+function\\s+([a-zA-Z]\\w*) \\(.*");
|
||||||
|
|
||||||
|
protected static Pattern ARRAYINIT = Pattern.compile("new (\\w+)\\[0\\]");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user