Skip to content

Commit 7e71e38

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix-bug-1828
2 parents f0f4557 + 3991042 commit 7e71e38

File tree

5 files changed

+136
-6
lines changed

5 files changed

+136
-6
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
August 9, 2012 - Release 1.4.1
2+
3+
* Added String.matches() [#1886]
4+
* Fixed canvas not receiving focus [#1883]
5+
16
July 31, 2012 - Release 1.4.0
27

38
* Added a PJS object inspector [#1867]

processing.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@
471471
function ArrayList(a) {
472472
var array;
473473

474-
if (a instanceof ArrayList) {
474+
if (a && a.toArray) {
475475
array = a.toArray();
476476
} else {
477477
array = [];
@@ -9373,8 +9373,7 @@
93739373
return subject.equals.apply(subject, removeFirstArgument(arguments));
93749374
}
93759375

9376-
// TODO use virtEquals for HashMap here
9377-
return subject.valueOf() === other.valueOf();
9376+
return virtEquals(subject, other);
93789377
};
93799378
/**
93809379
* The __equalsIgnoreCase() function compares two strings to see if they are the same.
@@ -9480,6 +9479,17 @@
94809479
p.match = function(str, regexp) {
94819480
return str.match(regexp);
94829481
};
9482+
/**
9483+
* The matches() function checks whether or not a string matches a given regular expression.
9484+
*
9485+
* @param {String} str the String on which the match is tested
9486+
* @param {String} regexp the regexp for which a match is tested
9487+
*
9488+
* @return {boolean} true if the string fits the regexp, false otherwise
9489+
*/
9490+
p.__matches = function(str, regexp) {
9491+
return (new RegExp(regexp)).test(str);
9492+
};
94839493
/**
94849494
* The startsWith() function tests if a string starts with the specified prefix. If the prefix
94859495
* is the empty String or equal to the subject String, startsWith() will also return true.
@@ -17661,7 +17671,11 @@
1766117671
});
1766217672

1766317673
// Disable browser's default handling for click-drag of a canvas.
17664-
curElement.onmousedown = function () { return false; };
17674+
curElement.onmousedown = function () {
17675+
// make sure focus happens, but nothing else
17676+
curElement.focus();
17677+
return false;
17678+
};
1766517679

1766617680
attachEventHandler(curElement, "mousedown", function(e) {
1766717681
p.__mousePressed = true;
@@ -18050,7 +18064,7 @@
1805018064
"__equalsIgnoreCase", "__frameRate", "__hashCode", "__int_cast",
1805118065
"__instanceof", "__keyPressed", "__mousePressed", "__printStackTrace",
1805218066
"__replace", "__replaceAll", "__replaceFirst", "__toCharArray", "__split",
18053-
"__codePointAt", "__startsWith", "__endsWith"];
18067+
"__codePointAt", "__startsWith", "__endsWith", "__matches"];
1805418068

1805518069
var members = {};
1805618070
var i, l;
@@ -18442,7 +18456,7 @@
1844218456
}
1844318457
do {
1844418458
repeatJavaReplacement = false;
18445-
s = s.replace(/((?:'\d+'|\b[A-Za-z_$][\w$]*\s*(?:"[BC]\d+")*)\s*\.\s*(?:[A-Za-z_$][\w$]*\s*(?:"[BC]\d+"\s*)*\.\s*)*)(replace|replaceAll|replaceFirst|contains|equals|equalsIgnoreCase|hashCode|toCharArray|printStackTrace|split|startsWith|endsWith|codePointAt)\s*"B(\d+)"/g,
18459+
s = s.replace(/((?:'\d+'|\b[A-Za-z_$][\w$]*\s*(?:"[BC]\d+")*)\s*\.\s*(?:[A-Za-z_$][\w$]*\s*(?:"[BC]\d+"\s*)*\.\s*)*)(replace|replaceAll|replaceFirst|contains|equals|equalsIgnoreCase|hashCode|toCharArray|printStackTrace|split|startsWith|endsWith|codePointAt|matches)\s*"B(\d+)"/g,
1844618460
replacePrototypeMethods);
1844718461
} while (repeatJavaReplacement);
1844818462
// xxx instanceof yyy -> __instanceof(xxx, yyy)

test/unit/arrayListFromSet.pde

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
HashMap<String,String> map = new HashMap<String,String>();
2+
map.put("a","1");
3+
4+
ArrayList<String> keys = new ArrayList(map.keySet());
5+
_checkEqual(keys.get(0), "a");
6+
7+
ArrayList<String> vals = new ArrayList(map.values());
8+
_checkEqual(vals.get(0), "1");

test/unit/string_equals_null.pde

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
String test = "test";
2+
String nullTest = null;
3+
_checkEqual(test.equals(nullTest), false);

test/unit/string_matches.pde

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Unit tests for String.matches() method that emulates Java's behaviour.
2+
// See #1886 for more info.
3+
String s = "abc";
4+
String d = "123";
5+
6+
_checkEqual(s.matches("\\w+"), true);
7+
_checkEqual(s.matches("[a-z]+"), true);
8+
_checkEqual(s.matches("\\d+"), false);
9+
10+
_checkEqual(d.matches("\\w+"), true);
11+
_checkEqual(d.matches("[a-z]+"), false);
12+
_checkEqual(d.matches("\\d+"), true);
13+
14+
String email = "[email protected]";
15+
String regexp = "(?:(?:\\r\\n)?[ \\t])*(?:(?:(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t]" +
16+
")+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:" +
17+
"\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(" +
18+
"?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ " +
19+
"\\t]))*\"(?:(?:\\r\\n)?[ \\t])*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\0" +
20+
"31]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\" +
21+
"](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+" +
22+
"(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:" +
23+
"(?:\\r\\n)?[ \\t])*))*|(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z" +
24+
"|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)" +
25+
"?[ \\t])*)*\\<(?:(?:\\r\\n)?[ \\t])*(?:@(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\" +
26+
"r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[" +
27+
" \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)" +
28+
"?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t]" +
29+
")*))*(?:,@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[" +
30+
" \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*" +
31+
")(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t]" +
32+
")+|\\Z|(?=[\\[\"()<>@,;:\\\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:@(?:[^()<>@,;" +
54+
":\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([" +
55+
"^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\"" +
56+
".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\" +
57+
"]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*(?:,@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\" +
58+
"[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\" +
59+
"r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] " +
60+
"\\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]" +
61+
"|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*)*:(?:(?:\\r\\n)?[ \\t])*)?(?:[^()<>@,;:\\\\\".\\[\\] \\0" +
62+
"00-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\" +
63+
".|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@," +
64+
";:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[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:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\" +
87+
"\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*)*:(?:(?:\\r\\n)?[ \\t])*)?" +
88+
"(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[\"()<>@,;:\\\\\"." +
89+
"\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])*)(?:\\.(?:(?:" +
90+
"\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z|(?=[\\[" +
91+
"\"()<>@,;:\\\\\".\\[\\]]))|\"(?:[^\\\"\\r\\\\]|\\\\.|(?:(?:\\r\\n)?[ \\t]))*\"(?:(?:\\r\\n)?[ \\t])" +
92+
"*))*@(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])" +
93+
"+|\\Z|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*)(?:\\" +
94+
".(?:(?:\\r\\n)?[ \\t])*(?:[^()<>@,;:\\\\\".\\[\\] \\000-\\031]+(?:(?:(?:\\r\\n)?[ \\t])+|\\Z" +
95+
"|(?=[\\[\"()<>@,;:\\\\\".\\[\\]]))|\\[([^\\[\\]\\r\\\\]|\\\\.)*\\](?:(?:\\r\\n)?[ \\t])*))*\\>(?:(" +
96+
"?:\\r\\n)?[ \\t])*))*)?;\\s*)";
97+
98+
_checkEqual(email.matches(regexp), true);
99+
100+

0 commit comments

Comments
 (0)