Permalink
Browse files

Added Box2DFlashAS3 Sample

git-svn-id: http://hotruby.googlecode.com/svn/trunk@18 4fb8041d-b042-0410-9571-f50be27af959
  • Loading branch information...
1 parent 821c489 commit 7981c6bb099b86450bb7c02609b76ee70ada250b yukoba@accelart.jp committed Jan 15, 2008
Showing with 16,227 additions and 70 deletions.
  1. +1 −1 src/ASHeader.as
  2. +14 −6 src/RubyNative.js
  3. +40 −21 src/RubyVM.js
  4. +33 −0 test/Box2DFlashAS3/Box2D/Collision/ClipVertex.as
  5. +64 −0 test/Box2DFlashAS3/Box2D/Collision/Features.as
  6. +39 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2BoxDef.as
  7. +39 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2CircleDef.as
  8. +180 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2CircleShape.as
  9. +34 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2MassData.as
  10. +45 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2PolyDef.as
  11. +471 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2PolyShape.as
  12. +340 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2Shape.as
  13. +115 −0 test/Box2DFlashAS3/Box2D/Collision/Shapes/b2ShapeDef.as
  14. +45 −0 test/Box2DFlashAS3/Box2D/Collision/b2AABB.as
  15. +45 −0 test/Box2DFlashAS3/Box2D/Collision/b2Bound.as
  16. +28 −0 test/Box2DFlashAS3/Box2D/Collision/b2BoundValues.as
  17. +901 −0 test/Box2DFlashAS3/Box2D/Collision/b2BroadPhase.as
  18. +28 −0 test/Box2DFlashAS3/Box2D/Collision/b2BufferedPair.as
  19. +743 −0 test/Box2DFlashAS3/Box2D/Collision/b2Collision.as
  20. +53 −0 test/Box2DFlashAS3/Box2D/Collision/b2ContactID.as
  21. +35 −0 test/Box2DFlashAS3/Box2D/Collision/b2ContactPoint.as
  22. +339 −0 test/Box2DFlashAS3/Box2D/Collision/b2Distance.as
  23. +41 −0 test/Box2DFlashAS3/Box2D/Collision/b2Manifold.as
  24. +32 −0 test/Box2DFlashAS3/Box2D/Collision/b2OBB.as
  25. +64 −0 test/Box2DFlashAS3/Box2D/Collision/b2Pair.as
  26. +35 −0 test/Box2DFlashAS3/Box2D/Collision/b2PairCallback.as
  27. +391 −0 test/Box2DFlashAS3/Box2D/Collision/b2PairManager.as
  28. +37 −0 test/Box2DFlashAS3/Box2D/Collision/b2Proxy.as
  29. +128 −0 test/Box2DFlashAS3/Box2D/Common/Math/b2Mat22.as
  30. +220 −0 test/Box2DFlashAS3/Box2D/Common/Math/b2Math.as
  31. +135 −0 test/Box2DFlashAS3/Box2D/Common/Math/b2Vec2.as
  32. +74 −0 test/Box2DFlashAS3/Box2D/Common/b2Settings.as
  33. +69 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2CircleContact.as
  34. +234 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2Conservative.as
  35. +207 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2Contact.as
  36. +49 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2ContactConstraint.as
  37. +39 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2ContactConstraintPoint.as
  38. +36 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2ContactNode.as
  39. +31 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2ContactRegister.as
  40. +541 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2ContactSolver.as
  41. +32 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2NullContact.as
  42. +71 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2PolyAndCircleContact.as
  43. +129 −0 test/Box2DFlashAS3/Box2D/Dynamics/Contacts/b2PolyContact.as
  44. +247 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2DistanceJoint.as
  45. +39 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2DistanceJointDef.as
  46. +289 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2GearJoint.as
  47. +52 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2GearJointDef.as
  48. +48 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2Jacobian.as
  49. +202 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2Joint.as
  50. +46 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2JointDef.as
  51. +36 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2JointNode.as
  52. +212 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2MouseJoint.as
  53. +43 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2MouseJointDef.as
  54. +656 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2PrismaticJoint.as
  55. +50 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2PrismaticJointDef.as
  56. +596 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2PulleyJoint.as
  57. +57 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2PulleyJointDef.as
  58. +469 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2RevoluteJoint.as
  59. +49 −0 test/Box2DFlashAS3/Box2D/Dynamics/Joints/b2RevoluteJointDef.as
  60. +474 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2Body.as
  61. +76 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2BodyDef.as
  62. +46 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2CollisionFilter.as
  63. +338 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2ContactManager.as
  64. +338 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2Island.as
  65. +30 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2TimeStep.as
  66. +530 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2World.as
  67. +55 −0 test/Box2DFlashAS3/Box2D/Dynamics/b2WorldListener.as
  68. +1 −0 test/Box2DFlashAS3/Box2DFlashAS3.js
  69. +136 −0 test/Box2DFlashAS3/Box2DFlashAS3.rb
  70. BIN test/Box2DFlashAS3/Box2DFlashAS3.swc
  71. +2,595 −0 test/Box2DFlashAS3/Box2DFlashAS3_pretty.json
  72. +49 −0 test/Box2DFlashAS3/General/FRateLimiter.as
  73. +131 −0 test/Box2DFlashAS3/General/FpsCounter.as
  74. +352 −0 test/Box2DFlashAS3/General/Input.as
  75. +13 −0 test/Box2DFlashAS3/HotRubyFlash-config.xml
  76. +1 −0 test/Box2DFlashAS3/ImportAS.as
  77. +17 −0 test/Box2DFlashAS3/LicenseOfBox2DFlashAS3.txt
  78. +379 −0 test/Box2DFlashAS3/TestBed/Test.as
  79. +156 −0 test/Box2DFlashAS3/TestBed/TestBridge.as
  80. +135 −0 test/Box2DFlashAS3/TestBed/TestCompound.as
  81. +118 −0 test/Box2DFlashAS3/TestBed/TestCrank.as
  82. +268 −0 test/Box2DFlashAS3/TestBed/TestExample.as
  83. +123 −0 test/Box2DFlashAS3/TestBed/TestGears.as
  84. +110 −0 test/Box2DFlashAS3/TestBed/TestPulley.as
  85. +252 −0 test/Box2DFlashAS3/TestBed/TestRagdoll.as
  86. +74 −0 test/Box2DFlashAS3/TestBed/TestStack.as
  87. +9 −0 test/Box2DFlashAS3/build.bat
  88. +9 −0 test/Box2DFlashAS3/buildDebug.bat
  89. +94 −42 web/js/HotRuby.js
View
@@ -1,6 +1,6 @@
package {
import flash.display.*;
- public class HotRubyFlash extends Sprite {
+ public class HotRubyFlash extends MovieClip {
public function HotRubyFlash() {
_root = this;
new HotRuby().run(src);
View
@@ -1,6 +1,20 @@
// The license of this source is "Ruby License"
HotRuby.prototype.classes = {
"<global>" : {
+ },
+
+ "Object" : {
+ "==" : function(recver, args) {
+ return recver == args[0] ? this.trueObj : this.falseObj;
+ },
+
+ "to_s" : function(recver) {
+ if(typeof(recver) == "number")
+ return recver.toString();
+ else
+ return recver.__native.toString();
+ },
+
"puts" : function(recver, args, sf) {
if(args.length == 0) {
this.printDebug("");
@@ -46,12 +60,6 @@ HotRuby.prototype.classes = {
}
},
- "Object" : {
- "to_s" : function(recver) {
- return recver.toString();
- }
- },
-
"TrueClass" : {
"&" : function(recver, args) {
return args[0] ? true : false;
View
@@ -221,6 +221,19 @@ HotRuby.prototype = {
ip = opcode.label2ip[cmd[1]];
}
break;
+ case "opt_case_dispatch":
+ var v = sf.stack[--sf.sp];
+ if(typeof(v) != "number") v = v.__native;
+ for(var i=0; i<cmd[1].length; i+=2) {
+ if(v === cmd[1][i]) {
+ ip = opcode.label2ip[cmd[1][i+1]];
+ break;
+ }
+ }
+ if(i == cmd[1].length) {
+ ip = opcode.label2ip[cmd[2]];
+ }
+ break;
case "leave" :
return;
case "putnil" :
@@ -386,8 +399,8 @@ HotRuby.prototype = {
var args = sf.stack.slice(sf.sp - cmd[2], sf.sp);
sf.sp -= cmd[2];
var recver = sf.stack[--sf.sp];
- if (recver == null || recver == this.nilObj)
- recver = sf.self;
+ //if (recver == null || recver == this.nilObj)
+ // recver = sf.self;
if(cmd[3] instanceof Array)
cmd[3] = this.createRubyProc(cmd[3], sf);
if(cmd[3] != null)
@@ -504,8 +517,10 @@ HotRuby.prototype = {
func = recver.__methods[methodName];
}
if (func == null) {
+ //trace("recverClassName = " + recverClassName);
var searchClass = this.classes[recverClassName];
while (true) {
+ //trace("methodName = " + methodName);
// Search method in class
func = searchClass[methodName];
if (func != null) break;
@@ -521,11 +536,13 @@ HotRuby.prototype = {
// Search Parent class
if ("__parentClass" in searchClass) {
searchClass = searchClass.__parentClass;
+ //trace("searchClass = " + searchClass);
if(searchClass == null) {
func = null;
break;
}
invokeClassName = searchClass.__className;
+ //trace("invokeClassName = " + invokeClassName);
continue;
}
break;
@@ -605,6 +622,16 @@ HotRuby.prototype = {
* Get variable from NativeEnviornment
*/
getNativeEnvVar: function(recver, varName, args, sf) {
+ //trace(varName);
+ if(this.env == "flash" && varName == "import") {
+ var imp = args[0].__native;
+ if(imp.charAt(imp.length - 1) != "*")
+ throw "[getNativeEnvVar] Param must ends with * : " + imp;
+ this.asPackages.push(imp.substr(0, imp.length - 1));
+ sf.stack[sf.sp++] = this.nilObj;
+ return;
+ }
+
if(varName in recver.__instanceVars) {
sf.stack[sf.sp++] = recver.__instanceVars[varName];
return;
@@ -723,6 +750,15 @@ HotRuby.prototype = {
* @param v native object
*/
nativeToRubyObject: function(v) {
+ if(v === null) {
+ return this.nilObj;
+ }
+ if(v === true) {
+ return this.trueObj;
+ }
+ if(v === false) {
+ return this.falseObj;
+ }
if(typeof(v) == "number") {
return v;
}
@@ -755,6 +791,7 @@ HotRuby.prototype = {
*/
invokeNativeNew: function(recver, methodName, args, sf) {
var obj;
+ var args = this.rubyObjectAryToNativeAry(args);
switch(args.length) {
case 0: obj = new recver.__native(); break;
case 1: obj = new recver.__native(args[0]); break;
@@ -1019,25 +1056,7 @@ HotRuby.prototype = {
HotRuby.debugTextField.text += str + "\n";
}
this.nativeClassObjCache = {};
- this.asPackages = [
- "",
- "flash.display.",
- "flash.text.",
- "flash.system.",
- "flash.geom.",
- "flash.events.",
- "flash.accessbility.",
- "flash.errors.",
- "flash.external.",
- "flash.filters.",
- "flash.media.",
- "flash.net.",
- "flash.printing.",
- "flash.profiler.",
- "flash.ui.",
- "flash.utils.",
- "flash.xml."
- ];
+ this.asPackages = [""];
// Create _root NativeObject
this.globalVars.$native.__instanceVars._root = {
__className : "NativeObject",
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
+*
+* This software is provided 'as-is', without any express or implied
+* warranty. In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+*/
+
+package Box2D.Collision{
+
+
+import Box2D.Common.Math.*
+import Box2D.Collision.*
+
+
+public class ClipVertex
+{
+ public var v:b2Vec2 = new b2Vec2();
+ public var id:b2ContactID = new b2ContactID();
+};
+
+
+}
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
+*
+* This software is provided 'as-is', without any express or implied
+* warranty. In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+*/
+
+package Box2D.Collision{
+
+// We use contact ids to facilitate warm starting.
+public class Features
+{
+ //
+ public function set referenceFace(value:int) : void{
+ _referenceFace = value;
+ _m_id._key = (_m_id._key & 0xffffff00) | (_referenceFace & 0x000000ff)
+ }
+ public function get referenceFace():int{
+ return _referenceFace;
+ }
+ public var _referenceFace:int;
+ //
+ public function set incidentEdge(value:int) : void{
+ _incidentEdge = value;
+ _m_id._key = (_m_id._key & 0xffff00ff) | ((_incidentEdge << 8) & 0x0000ff00)
+ }
+ public function get incidentEdge():int{
+ return _incidentEdge;
+ }
+ public var _incidentEdge:int;
+ //
+ public function set incidentVertex(value:int) : void{
+ _incidentVertex = value;
+ _m_id._key = (_m_id._key & 0xff00ffff) | ((_incidentVertex << 16) & 0x00ff0000)
+ }
+ public function get incidentVertex():int{
+ return _incidentVertex;
+ }
+ public var _incidentVertex:int;
+ //
+ public function set flip(value:int) : void{
+ _flip = value;
+ _m_id._key = (_m_id._key & 0x00ffffff) | ((_flip << 24) & 0xff000000)
+ }
+ public function get flip():int{
+ return _flip;
+ }
+ public var _flip:int;
+ public var _m_id:b2ContactID;
+};
+
+
+}
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
+*
+* This software is provided 'as-is', without any express or implied
+* warranty. In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+*/
+
+package Box2D.Collision.Shapes{
+
+
+
+import Box2D.Common.Math.*;
+import Box2D.Collision.Shapes.*;
+
+
+
+public class b2BoxDef extends b2ShapeDef
+{
+ public function b2BoxDef()
+ {
+ type = b2Shape.e_boxShape;
+ extents = new b2Vec2(1.0, 1.0);
+ }
+
+ public var extents:b2Vec2;
+};
+
+}
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
+*
+* This software is provided 'as-is', without any express or implied
+* warranty. In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+*/
+
+package Box2D.Collision.Shapes{
+
+
+
+import Box2D.Common.Math.*;
+import Box2D.Collision.Shapes.*;
+
+
+
+public class b2CircleDef extends b2ShapeDef
+{
+ public function b2CircleDef()
+ {
+ type = b2Shape.e_circleShape;
+ radius = 1.0;
+ }
+
+ public var radius:Number;
+};
+
+}
Oops, something went wrong.

0 comments on commit 7981c6b

Please sign in to comment.