Merge pull request #1106 from marco-c/self_host_GestureEvent

Self host GestureEventImpl and allow running benchmarks using SpiderMonkey
This commit is contained in:
Tim Abraldes 2015-02-17 13:21:03 -08:00
Родитель 859e000844 2aae7086a1
Коммит edfbc2fcdc
5 изменённых файлов: 95 добавлений и 128 удалений

Просмотреть файл

@ -297,4 +297,13 @@ java/util/Hashtable$HashtableEnumerator.nextElement.()Ljava/lang/Object;
com/sun/midp/lcdui/DisplayDevice.isPrimaryDisplay.()Z
com/sun/midp/main/MIDletProxy.getClassName.()Ljava/lang/String;
com/sun/midp/rms/RmsEnvironment.getSecureFilenameBase.(I)Ljava/lang/String;
com/sun/midp/midletsuite/SuiteContainerAdapter.getSecureFilenameBase.(I)Ljava/lang/String;
com/sun/midp/midletsuite/SuiteContainerAdapter.getSecureFilenameBase.(I)Ljava/lang/String;
com/nokia/mid/ui/gestures/GestureEventImpl.getType.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceX.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceY.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getStartX.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getStartY.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getFlickDirection.()F
com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeed.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeedX.()I
com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeedY.()I

Просмотреть файл

@ -1,27 +1,71 @@
package com.nokia.mid.ui.gestures;
import com.sun.midp.events.NativeEvent;
public class GestureEventImpl implements GestureEvent {
public GestureEventImpl(int type, int dragDistanceX, int dragDistanceY, int startX, int startY,
float flickDirection, int flickSpeed, int flickSpeedX, int flickSpeedY,
int pinchDistanceStarting, int pinchDistanceCurrent, int pinchDistanceChange,
int pinchCenterX, int pinchCenterY, int pinchCenterChangeX, int pinchCenterChangeY) {
// Overridden in midp/gestures.js
protected NativeEvent nativeEvent;
public int getType() {
return nativeEvent.intParam1;
}
native public int getType();
native public int getDragDistanceX();
native public int getDragDistanceY();
native public int getStartX();
native public int getStartY();
native public float getFlickDirection();
native public int getFlickSpeed();
native public int getFlickSpeedX();
native public int getFlickSpeedY();
native public int getPinchDistanceStarting();
native public int getPinchDistanceCurrent();
native public int getPinchDistanceChange();
native public int getPinchCenterX();
native public int getPinchCenterY();
native public int getPinchCenterChangeX();
native public int getPinchCenterChangeY();
public int getDragDistanceX() {
return nativeEvent.intParam2;
}
public int getDragDistanceY() {
return nativeEvent.intParam3;
}
public int getStartX() {
return nativeEvent.intParam5;
}
public int getStartY() {
return nativeEvent.intParam6;
}
public float getFlickDirection() {
return nativeEvent.floatParam1;
}
public int getFlickSpeed() {
return nativeEvent.intParam7;
}
public int getFlickSpeedX() {
return nativeEvent.intParam8;
}
public int getFlickSpeedY() {
return nativeEvent.intParam9;
}
public int getPinchDistanceStarting() {
return nativeEvent.intParam10;
}
public int getPinchDistanceCurrent() {
return nativeEvent.intParam11;
}
public int getPinchDistanceChange() {
return nativeEvent.intParam12;
}
public int getPinchCenterX() {
return nativeEvent.intParam13;
}
public int getPinchCenterY() {
return nativeEvent.intParam14;
}
public int getPinchCenterChangeX() {
return nativeEvent.intParam15;
}
public int getPinchCenterChangeY() {
return nativeEvent.intParam16;
}
}

Просмотреть файл

@ -21,6 +21,11 @@ public class GestureRegistrationManager implements EventListener {
private static Vector zoneRegistrations = new Vector();
private static Hashtable listenerRegistrations = new Hashtable();
// http://developer.nokia.com/resources/library/Java/_zip/GUID-237420DE-CCBE-4A74-A129-572E0708D428/com/nokia/mid/ui/gestures/GestureEvent.html
// The API imposes the restriction that the gesture event data is only valid during the call to
// GestureListener.gestureAction(Object, GestureInteractiveZone, GestureEvent).
private static GestureEventImpl gestureEvent = new GestureEventImpl();
static {
EventQueue eventQueue = EventQueue.getEventQueue();
eventQueue.registerEventListener(EventTypes.GESTURE_EVENT, GestureRegistrationManager.getRegistrationManagerInstance());
@ -40,23 +45,7 @@ public class GestureRegistrationManager implements EventListener {
}
public void process(Event event) {
NativeEvent nativeEvent = (NativeEvent)event;
GestureEvent gestureEvent = new GestureEventImpl(nativeEvent.intParam1,
nativeEvent.intParam2,
nativeEvent.intParam3,
nativeEvent.intParam5,
nativeEvent.intParam6,
nativeEvent.floatParam1,
nativeEvent.intParam7,
nativeEvent.intParam8,
nativeEvent.intParam9,
nativeEvent.intParam10,
nativeEvent.intParam11,
nativeEvent.intParam12,
nativeEvent.intParam13,
nativeEvent.intParam14,
nativeEvent.intParam15,
nativeEvent.intParam16);
gestureEvent.nativeEvent = (NativeEvent)event;
for (int i = 0; i < zoneRegistrations.size(); i++) {
ZoneRegistration zoneReg = (ZoneRegistration)zoneRegistrations.elementAt(i);

Просмотреть файл

@ -65,13 +65,22 @@ var document = {
},
getBoundingClientRect: function() {
return { top: 0, left: 0, width: 0, height: 0 };
}
},
querySelector: function() {
return { style: "" };
},
dispatchEvent: function(event) {
},
style: "",
};
},
addEventListener: function() {
},
};
var Event = function() {
}
var config = {
logConsole: "native",
args: "",
@ -81,8 +90,9 @@ try {
load("libs/relooper.js", "build/j2me.js","libs/zipfile.js", "blackBox.js",
"libs/encoding.js", "util.js",
"override.js", "native.js", "tests/override.js",
"string.js", "midp/midp.js",
"libs/long.js", "midp/crypto.js", "libs/forge/md5.js", "libs/forge/util.js");
"string.js", "midp/midp.js", "midp/gestures.js",
"libs/long.js", "midp/crypto.js", "libs/forge/md5.js", "libs/forge/util.js",
"build/classes.jar.js");
// load("build/classes.jar.js");
// load("build/program.jar.js");
@ -96,6 +106,7 @@ try {
CLASSES.addPath("java/classes.jar", snarf("java/classes.jar", "binary").buffer);
CLASSES.addPath("tests/tests.jar", snarf("tests/tests.jar", "binary").buffer);
CLASSES.addPath("bench/benchmark.jar", snarf("bench/benchmark.jar", "binary").buffer);
//CLASSES.addPath("program.jar", snarf("program.jar", "binary").buffer);
CLASSES.initializeBuiltinClasses();

Просмотреть файл

@ -29,89 +29,3 @@ Native["com/nokia/mid/ui/gestures/GestureInteractiveZone.contains.(II)Z"] = func
Native["com/nokia/mid/ui/gestures/GestureInteractiveZone.supports.(I)Z"] = function(type) {
return ((type & this.gestures) == type) ? 1 : 0;
};
Override["com/nokia/mid/ui/gestures/GestureEventImpl.<init>.(IIIIIFIIIIIIIIII)V"] =
function(type, dragDistanceX, dragDistanceY, startX, startY, flickDirection, flickSpeed, flickSpeedX, flickSpeedY,
pinchDistanceStarting, pinchDistanceCurrent, pinchDistanceChange, pinchCenterX, pinchCenterY,
pinchCenterChangeX, pinchCenterChangeY) {
this.type = type;
this.dragDistanceX = dragDistanceX;
this.dragDistanceY = dragDistanceY;
this.startX = startX;
this.startY = startY;
this.flickDirection = flickDirection;
this.flickSpeed = flickSpeed;
this.flickSpeedX = flickSpeedX;
this.flickSpeedY = flickSpeedY;
this.pinchDistanceStarting = pinchDistanceStarting;
this.pinchDistanceCurrent = pinchDistanceCurrent;
this.pinchDistanceChange = pinchDistanceChange;
this.pinchCenterX = pinchCenterX;
this.pinchCenterY = pinchCenterY;
this.pinchCenterChangeX = pinchCenterChangeX;
this.pinchCenterChangeY = pinchCenterChangeY;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getType.()I"] = function() {
return this.type;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceX.()I"] = function() {
return this.dragDistanceX;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getDragDistanceY.()I"] = function() {
return this.dragDistanceY;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getStartX.()I"] = function() {
return this.startX;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getStartY.()I"] = function() {
return this.startY;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getFlickDirection.()F"] = function() {
return this.flickDirection;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeed.()I"] = function() {
return this.flickSpeed;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeedX.()I"] = function() {
return this.flickSpeedX;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getFlickSpeedY.()I"] = function() {
return this.flickSpeedY;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchDistanceStarting.()I"] = function() {
return this.pinchDistanceStarting;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchDistanceCurrent.()I"] = function() {
return this.pinchDistanceCurrent;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchDistanceChange.()I"] = function() {
return this.pinchDistanceChange;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchCenterX.()I"] = function() {
return this.pinchCenterX;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchCenterY.()I"] = function() {
return this.pinchCenterY;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchCenterChangeX.()I"] = function() {
return this.pinchCenterChangeX;
};
Native["com/nokia/mid/ui/gestures/GestureEventImpl.getPinchCenterChangeY.()I"] = function() {
return this.pinchCenterChangeY;
};