Skip to content

Commit 21ac4f3

Browse files
authored
Merge branch 'master' into jdk17
2 parents e05bb70 + af0d237 commit 21ac4f3

File tree

6 files changed

+80
-68
lines changed

6 files changed

+80
-68
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**v3.11.0** Suggest use of JRuby-9.3.0.0+, some refactoring of GfxRender and ShapeRender.
1+
**v3.11.0** Suggest use of JRuby-9.3.1.0+, some refactoring of GfxRender and ShapeRender. Change `declared_field` to field possible since JRuby-9.3.0.0, required since JRuby-9.3.1.0
22

33
**v3.10.0** Default to using FastNoise module, with alternative of SmoothNoise module.
44

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
This version is intended to work with openjdk11+.
44

5-
A slim layer to communicate with Processing from JRuby, features maven build. We have created a configuration free version of ruby processing, for processing-4.0+, where we include a modified processing core (`public runPropane()` to replace `protected runSketch()`. These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby. Currently JavaFX is unsupported. It would be nice make use of java modules, but I think we should let jruby project do that first (unless processing.org beat them to it). It would be a good idea to update examples with this release.
5+
A slim layer to communicate with Processing from JRuby, features maven build. We have created a configuration free version of ruby processing, for processing-4.0+, where we include a modified processing core (`public runPropane()` to replace `protected runSketch()`. These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby. Currently JavaFX is unsupported. Using maven to create an automatic module, to be refined.
66

77
adjust above for your OS/distro setup.
88

99
## Requirements
1010

11-
Previously there has been linker issue with P2D or P3D sketches with stock openjdk with some linux distros, but that seems to have gone away. [Adopt open jdk binaries][adopt] have always worked.
11+
Tested with OpenJDK11 and OpenJDK17.
1212

1313
- `jdk-17+`
14-
- `jruby-9.3.0.0`
14+
- `jruby-9.3.1.0`
1515

1616
## Building and testing
1717

lib/propane/helper_methods.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ def find_method(method_name)
117117
def proxy_java_fields
118118
fields = %w[key frameRate mousePressed keyPressed]
119119
methods = fields.map { |field| java_class.field(field) }
120-
@declared_fields = Hash[fields.zip(methods)]
120+
@jfields = Hash[fields.zip(methods)]
121121
end
122122

123123
# Fix java conversion problems getting the last key
124124
# If it's ASCII, return the character, otherwise the integer
125125
def key
126-
int = @declared_fields['key'].value(java_self)
126+
int = @jfields['key'].value(java_self)
127127
int < 256 ? int.chr : int
128128
end
129129

@@ -160,19 +160,19 @@ def save_strings(filename, strings)
160160

161161
# frame_rate needs to support reading and writing
162162
def frame_rate(fps = nil)
163-
return @declared_fields['frameRate'].value(java_self) unless fps
163+
return @jfields['frameRate'].value(java_self) unless fps
164164

165165
super(fps)
166166
end
167167

168168
# Is the mouse pressed for this frame?
169169
def mouse_pressed?
170-
@declared_fields['mousePressed'].value(java_self)
170+
@jfields['mousePressed'].value(java_self)
171171
end
172172

173173
# Is a key pressed for this frame?
174174
def key_pressed?
175-
@declared_fields['keyPressed'].value(java_self)
175+
@jfields['keyPressed'].value(java_self)
176176
end
177177

178178
private

pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
'polyglot.dump.pom' => 'pom.xml',
4545
'project.build.sourceEncoding' => 'utf-8',
4646
'jogl.version' => '2.3.2', # for compiling actual included 2.4.0-rc
47-
'jruby.version' => '9.3.0.0',
47+
'jruby.version' => '9.3.1.0',
4848
'batik.version' => '1.14',
4949
'itextpdf.version' => '5.5.13.2',
5050
'jruby.api' => 'http://jruby.org/apidocs/')

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ DO NOT MODIFY - GENERATED CODE
6666
<itextpdf.version>5.5.13.2</itextpdf.version>
6767
<jogl.version>2.3.2</jogl.version>
6868
<jruby.api>http://jruby.org/apidocs/</jruby.api>
69-
<jruby.version>9.3.0.0</jruby.version>
69+
<jruby.version>9.3.1.0</jruby.version>
7070
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
7171
<processing.api>http://processing.github.io/processing-javadocs/core/</processing.api>
7272
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>

src/main/java/processing/core/PApplet.java

Lines changed: 69 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,17 +1336,19 @@ protected int findIndex(Object object) {
13361336
* @param target the target object that should receive the event
13371337
*/
13381338
public void registerMethod(String methodName, Object target) {
1339-
if (methodName.equals("mouseEvent")) {
1340-
registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1341-
1342-
} else if (methodName.equals("keyEvent")) {
1343-
registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1344-
1345-
} else if (methodName.equals("touchEvent")) {
1346-
registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1347-
1348-
} else {
1349-
registerNoArgs(methodName, target);
1339+
switch (methodName) {
1340+
case "mouseEvent":
1341+
registerWithArgs("mouseEvent", target, new Class[]{processing.event.MouseEvent.class});
1342+
break;
1343+
case "keyEvent":
1344+
registerWithArgs("keyEvent", target, new Class[]{processing.event.KeyEvent.class});
1345+
break;
1346+
case "touchEvent":
1347+
registerWithArgs("touchEvent", target, new Class[]{processing.event.TouchEvent.class});
1348+
break;
1349+
default:
1350+
registerNoArgs(methodName, target);
1351+
break;
13501352
}
13511353
}
13521354

@@ -2115,6 +2117,7 @@ protected PGraphics makeGraphics(int w, int h,
21152117
/**
21162118
* Create default renderer, likely to be resized, but needed for surface
21172119
* init.
2120+
* @return
21182121
*/
21192122
protected PGraphics createPrimaryGraphics() {
21202123
return makeGraphics(sketchWidth(), sketchHeight(),
@@ -2124,9 +2127,9 @@ protected PGraphics createPrimaryGraphics() {
21242127
/**
21252128
* ( begin auto-generated from createImage.xml )
21262129
*
2127-
* Creates a new PImage (the datatype for storing images). This provides a
2128-
* fresh buffer of pixels to play with. Set the size of the buffer with the
2129-
* <b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
2130+
* Creates a new PImage (the datatype for storing images).This provides a
2131+
fresh buffer of pixels to play with. Set the size of the buffer with the
2132+
<b>width</b> and <b>height</b> parameters. The <b>format</b> parameter
21302133
* defines how the pixels are stored. See the PImage reference for more
21312134
* information.
21322135
*
@@ -2142,6 +2145,7 @@ protected PGraphics createPrimaryGraphics() {
21422145
* to the parent PApplet is included, which makes save() work without
21432146
* needing an absolute path.
21442147
*
2148+
* @return
21452149
* @webref image
21462150
* @param w width in pixels
21472151
* @param h height in pixels
@@ -2400,6 +2404,7 @@ public boolean isLooping() {
24002404
/**
24012405
* Add an event to the internal event queue, or process it immediately if
24022406
* the sketch is not currently looping.
2407+
* @param pe
24032408
*/
24042409
public void postEvent(processing.event.Event pe) {
24052410
eventQueue.add(pe);
@@ -3186,14 +3191,14 @@ public void link(String url) {
31863191
/**
31873192
* ( begin auto-generated from launch.xml )
31883193
*
3189-
* Attempts to open an application or file using your platform's launcher.
3190-
* The <b>file</b> parameter is a String specifying the file name and
3191-
* location. The location parameter must be a full path name, or the name of
3192-
* an executable in the system's PATH. In most cases, using a full path is
3193-
* the best option, rather than relying on the system PATH. Be sure to make
3194-
* the file executable before attempting to open it (chmod +x).
3195-
*
3196-
* The <b>args</b> parameter is a String or String array which is passed to
3194+
* Attempts to open an application or file using your platform's launcher.The <b>file</b> parameter is a String specifying the file name and
3195+
location.
3196+
* The location parameter must be a full path name, or the name of
3197+
an executable in the system's PATH. In most cases, using a full path is
3198+
the best option, rather than relying on the system PATH. Be sure to make
3199+
the file executable before attempting to open it (chmod +x).
3200+
3201+
The <b>args</b> parameter is a String or String array which is passed to
31973202
* the command line. If you have multiple parameters, e.g. an application
31983203
* and a document, or a command with multiple switches, use the version that
31993204
* takes a String array, and place each individual item in a separate
@@ -3218,49 +3223,52 @@ public void link(String url) {
32183223
*
32193224
* ( end auto-generated )
32203225
*
3226+
* @return
32213227
* @webref input:files
32223228
* @param args arguments to the launcher, eg. a filename.
32233229
* @usage Application
32243230
*/
32253231
static public Process launch(String... args) {
32263232
String[] params = null;
32273233

3228-
if (platform == WINDOWS) {
3229-
// just launching the .html file via the shell works
3230-
// but make sure to chmod +x the .html files first
3231-
// also place quotes around it in case there's a space
3232-
// in the user.dir part of the url
3233-
params = new String[]{"cmd", "/c"};
3234-
3235-
} else if (platform == MACOS) {
3236-
params = new String[]{"open"};
3237-
3238-
} else if (platform == LINUX) {
3239-
// xdg-open is in the Free Desktop Specification and really should just
3240-
// work on desktop Linux. Not risking it though.
3241-
final String[] launchers = {"xdg-open", "gnome-open", "kde-open"};
3242-
for (String launcher : launchers) {
3243-
if (openLauncher != null) {
3244-
break;
3245-
}
3246-
try {
3247-
Process p = Runtime.getRuntime().exec(new String[]{launcher});
3248-
/*int result =*/ p.waitFor();
3249-
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3250-
openLauncher = launcher;
3251-
} catch (Exception e) {
3234+
switch (platform) {
3235+
case WINDOWS:
3236+
// just launching the .html file via the shell works
3237+
// but make sure to chmod +x the .html files first
3238+
// also place quotes around it in case there's a space
3239+
// in the user.dir part of the url
3240+
params = new String[]{"cmd", "/c"};
3241+
break;
3242+
case MACOS:
3243+
params = new String[]{"open"};
3244+
break;
3245+
case LINUX:
3246+
// xdg-open is in the Free Desktop Specification and really should just
3247+
// work on desktop Linux. Not risking it though.
3248+
final String[] launchers = {"xdg-open", "gnome-open", "kde-open"};
3249+
for (String launcher : launchers) {
3250+
if (openLauncher != null) {
3251+
break;
3252+
}
3253+
try {
3254+
Process p = Runtime.getRuntime().exec(new String[]{launcher});
3255+
/*int result =*/ p.waitFor();
3256+
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3257+
openLauncher = launcher;
3258+
} catch (Exception e) {
3259+
}
3260+
} if (openLauncher == null) {
3261+
System.err.println("Could not find xdg-open, gnome-open, or kde-open: "
3262+
+ "the open() command may not work.");
3263+
} if (openLauncher != null) {
3264+
params = new String[]{openLauncher};
32523265
}
3253-
}
3254-
if (openLauncher == null) {
3255-
System.err.println("Could not find xdg-open, gnome-open, or kde-open: "
3256-
+ "the open() command may not work.");
3257-
}
3258-
if (openLauncher != null) {
3259-
params = new String[]{openLauncher};
3260-
}
3261-
//} else { // give up and just pass it to Runtime.exec()
3262-
//open(new String[] { filename });
3263-
//params = new String[] { filename };
3266+
//} else { // give up and just pass it to Runtime.exec()
3267+
//open(new String[] { filename });
3268+
//params = new String[] { filename };
3269+
break;
3270+
default:
3271+
break;
32643272
}
32653273
if (params != null) {
32663274
// If the 'open', 'gnome-open' or 'cmd' are already included
@@ -7526,6 +7534,7 @@ static public String[] expand(String[] list, int newSize) {
75267534
}
75277535

75287536
/**
7537+
* @param array
75297538
* @nowebref
75307539
*/
75317540
static public Object expand(Object array) {
@@ -9648,6 +9657,7 @@ public void frameResized(int w, int h) {
96489657
* All parameters *after* the sketch class name are passed to the sketch
96499658
* itself and available from its 'args' array while the sketch is running.
96509659
*
9660+
* @param args
96519661
* @see PApplet#args
96529662
* </PRE>
96539663
*/
@@ -9658,6 +9668,8 @@ static public void main(final String[] args) {
96589668
/**
96599669
* Convenience method so that PApplet.main(YourSketch.class) launches a
96609670
* sketch, rather than having to call getName() on it.
9671+
* @param mainClass
9672+
* @param args
96619673
*/
96629674
static public void main(final Class<?> mainClass, String... args) {
96639675
main(mainClass.getName(), args);

0 commit comments

Comments
 (0)