Bläddra i källkod

Merged branch develop into master

Mark Sibly 8 år sedan
förälder
incheckning
facb6634c9
97 ändrade filer med 3621 tillägg och 392 borttagningar
  1. 3 0
      .gitignore
  2. 3 1
      README.TXT
  3. 0 54
      TODO.TXT
  4. 0 24
      VERSIONS.TXT
  5. 54 0
      bananas/httprequest/httprequest_test.monkey2
  6. 4 1
      bananas/spacechimps/spacechimps.monkey2
  7. 9 9
      bin/env_macos.txt
  8. 3 0
      bin/env_windows.txt
  9. BIN
      bin/mx2cc_linux
  10. BIN
      bin/mx2cc_macos
  11. BIN
      bin/mx2cc_windows.exe
  12. 12 0
      modules/httprequest/httprequest.monkey2
  13. 238 0
      modules/httprequest/httprequest_android.monkey2
  14. 38 0
      modules/httprequest/httprequest_ios.monkey2
  15. 8 0
      modules/httprequest/module.json
  16. 116 0
      modules/httprequest/native/Monkey2HttpRequest.java
  17. 90 0
      modules/httprequest/native/httprequest.cpp
  18. 53 0
      modules/httprequest/native/httprequest.h
  19. 136 0
      modules/httprequest/native/httprequest.mm
  20. 92 0
      modules/jni/jni.monkey2
  21. 8 0
      modules/jni/module.json
  22. 122 0
      modules/jni/native/jni_glue.cpp
  23. 20 0
      modules/jni/native/jni_glue.h
  24. 1 4
      modules/mojo/app/app.monkey2
  25. 2 2
      modules/mojo/app/view.monkey2
  26. 14 5
      modules/mojo/input/keyboard.monkey2
  27. 43 6
      modules/mojo/input/mouse.monkey2
  28. 9 3
      modules/mojo/input/touch.monkey2
  29. 4 4
      modules/mojox/docs/module.md
  30. 12 1
      modules/mojox/filebrowser.monkey2
  31. 80 0
      modules/monkey/docs/language/arrays.md
  32. 3 0
      modules/monkey/docs/language/language.md
  33. 0 49
      modules/monkey/docs/language/reflection.md
  34. 49 0
      modules/monkey/docs/language/strings.md
  35. 2 2
      modules/monkey/docs/language/types.md
  36. 1 1
      modules/monkey/docs/language/variables.md
  37. 47 0
      modules/monkey/docs/language/variants.md
  38. 44 0
      modules/monkey/native/bbgc.cpp
  39. 4 0
      modules/monkey/native/bbgc.h
  40. 4 0
      modules/monkey/native/bbstd.h
  41. 12 0
      modules/monkey/native/bbstring.h
  42. BIN
      modules/openal/openal-soft/jniLibs/arm64-v8a/libopenal.so
  43. BIN
      modules/openal/openal-soft/jniLibs/armeabi/libopenal.so
  44. BIN
      modules/openal/openal-soft/jniLibs/mips/libopenal.so
  45. BIN
      modules/openal/openal-soft/jniLibs/mips64/libopenal.so
  46. BIN
      modules/openal/openal-soft/jniLibs/x86/libopenal.so
  47. BIN
      modules/openal/openal-soft/jniLibs/x86_64/libopenal.so
  48. 24 23
      modules/openal/openal.monkey2
  49. 16 0
      modules/sdl2/sdl2.monkey2
  50. 1 1
      modules/std/audio/load_vorbis.monkey2
  51. 12 2
      modules/std/fiber/fcontext.monkey2
  52. 58 0
      modules/std/fiber/native/asm/android-arm/jump.S
  53. 62 0
      modules/std/fiber/native/asm/android-arm/make.S
  54. 63 0
      modules/std/fiber/native/asm/android-arm/ontop.S
  55. 88 0
      modules/std/fiber/native/asm/android-arm64/jump.S
  56. 71 0
      modules/std/fiber/native/asm/android-arm64/make.S
  57. 87 0
      modules/std/fiber/native/asm/android-arm64/ontop.S
  58. 86 0
      modules/std/fiber/native/asm/android-mips/jump.S
  59. 86 0
      modules/std/fiber/native/asm/android-mips/make.S
  60. 87 0
      modules/std/fiber/native/asm/android-mips/ontop.S
  61. 86 0
      modules/std/fiber/native/asm/android-mips64/jump.S
  62. 86 0
      modules/std/fiber/native/asm/android-mips64/make.S
  63. 87 0
      modules/std/fiber/native/asm/android-mips64/ontop.S
  64. 59 0
      modules/std/fiber/native/asm/android-x86/jump.S
  65. 94 0
      modules/std/fiber/native/asm/android-x86/make.S
  66. 61 0
      modules/std/fiber/native/asm/android-x86/ontop.S
  67. 67 0
      modules/std/fiber/native/asm/android-x86_64/jump.S
  68. 62 0
      modules/std/fiber/native/asm/android-x86_64/make.S
  69. 69 0
      modules/std/fiber/native/asm/android-x86_64/ontop.S
  70. 2 2
      modules/std/socket/native/socket.cpp
  71. 1 1
      modules/theoraplayer/makefile.monkey2
  72. 18 28
      products/android/Monkey2Game/app/src/main/Monkey2Game.java
  73. 37 0
      products/android/Monkey2Game/app/src/main/java/com/monkey2/lib/Monkey2Activity.java
  74. 5 5
      scripts/common.bat
  75. 8 8
      scripts/common.sh
  76. 452 0
      src/c2mx2/cxxtomx2.monkey2
  77. 26 3
      src/c2mx2/test.h
  78. 2 9
      src/c2mx2/test.json
  79. 9 9
      src/mx2cc/builder.monkey2
  80. 85 29
      src/mx2cc/buildproduct.monkey2
  81. 78 39
      src/mx2cc/docs/docsmaker.monkey2
  82. 11 9
      src/mx2cc/docs/markdownbuffer.monkey2
  83. 2 0
      src/mx2cc/geninfo/geninfo.monkey2
  84. 1 1
      src/mx2cc/mx2.monkey2
  85. 3 5
      src/mx2cc/mx2cc.monkey2
  86. 11 1
      src/mx2cc/parser.monkey2
  87. 2 0
      src/mx2cc/test.java
  88. 1 23
      src/mx2cc/test.monkey2
  89. 35 0
      src/mx2cc/tests/deps1.monkey2
  90. 1 1
      src/mx2cc/toker.monkey2
  91. 42 10
      src/mx2cc/translator.monkey2
  92. 29 8
      src/mx2cc/translator_cpp.monkey2
  93. 2 2
      src/mx2cc/util.monkey2
  94. 1 2
      src/ted2/buildproduct.monkey2
  95. 3 3
      src/ted2/modulemanager.monkey2
  96. 1 1
      src/ted2/monkey2document.monkey2
  97. 1 1
      src/ted2go

+ 3 - 0
.gitignore

@@ -29,6 +29,7 @@ __MANPAGES__/
 /modules/module-manager/downloads/*.zip
 
 /src/Ted2GO
+
 /modules/cmark
 /modules/lua
 /modules/wdw-game2d
@@ -41,6 +42,8 @@ __MANPAGES__/
 /modules/pyro-scenegraph
 /modules/bullet
 /modules/gles30
+/modules/timelinefx
+/modules/admob
 
 /modules/module-manager/backups
 

+ 3 - 1
README.TXT

@@ -1,7 +1,9 @@
 
 ***** Welcome to Monkey2! *****
 
-W A R N I N G ! The master branch is super-volatile, and the develop branch is event worse! Grabbing the most recently tagged version is recommended if you just want to give monkey2 a try.
+The master branch is effectively the 'release candidates' branch, so should be relatively stable. All development work is now done on the develop branch.
+
+Grabbing the most recently tagged version is recommended if you just want to give monkey2 a try.
 
 
 ***** Building monkey2 on Windows *****

+ 0 - 54
TODO.TXT

@@ -1,54 +0,0 @@
-
-Monkey2 TODO list.
-
-This is list of stuff I consider reasonably urgent.
-
-This doesn't include big picture things like new targets, modules etc.
-
-
-* Mx2cc/builder/makedocs
-
-	* Deal with Self.New/Super.New issues.
-
-	* Deal with global/const order-of-initialization issues.
-
-	* Wildcard/filtered asset importing so you can import a dir in one hit.
-
-	* Add support for custom 'manuals' in module docs.
-
-	* System assets folder support.
-
-
-* Modules
-
-	* Add lights/shadows to mojo.graphics.
-
-	* Fix mojo.graphics 'font texture always 512x512' issue.
-
-	* Better audio support - openalsoft?
-
-	* Handle symlinks better in std.filesystem.
-	
-	* Network support - udp/tcp streams/servers and httprequest.
-
- 
-* Ted2
-
-	* Goto Line.
-	
-	* More customization.
-
-	* Restore offline help system.
-
-	* Draggable/closable tabs.
-
-	* Filebrowser context menu.
-	
-	* Hotkeys for scripts.
-
-
-* Misc
-
-	* Add module upload/browser to monkey2.monkey-x.com.
-	
-	* Implement a libclang based 'API convertor' to help with wrapping 3rd party C/C++ libs.

+ 0 - 24
VERSIONS.TXT

@@ -1,24 +0,0 @@
-
-Fixed previous word.
-
-Block tab/untab selects all lines.
-
-Fixed macos drop file.
-
-Added cmd-q causes closewindow event for macos.
-
-Tidied up chipmunk module.
-
-Added List.RemoveIf and Stack.RemoveIf.
-
-Added Edit->Goto line AT LAST!
-
-Fixed TextView.CharRect bug returning bad width.
-
-Restored Stream.ReadCString and Stream.WriteCString.
-
-***** v1.0.91 *****
-
-Made reflection optional. You now need to #Import "<reflection>" to activate it, and the first build of an app will be SLOW. Reflection is still 'all or nothing' for now.
-
-Fixed some race conditions with Process objects going out of scope very quickly.

+ 54 - 0
bananas/httprequest/httprequest_test.monkey2

@@ -0,0 +1,54 @@
+
+Namespace myapp
+
+#Import "<std>"
+#Import "<mojo>"
+#Import "<httprequest>"
+
+Using std..
+Using mojo..
+Using httprequest..
+
+Class MyWindow Extends Window
+	
+	Field req:HttpRequest
+
+	Method New( title:String="HttpRequest demo",width:Int=640,height:Int=480,flags:WindowFlags=Null )
+
+		Super.New( title,width,height,flags )
+		
+		req=New HttpRequest( "GET","http://www.blitzbasic.com",Lambda()
+		
+			Print "Ready state changed to "+Int( req.ReadyState )
+			
+			If req.ReadyState=4 
+				Print "ReponseText="+req.ResponseText
+				Print "Status="+req.Status
+			Endif
+		
+		End )
+		
+		New Fiber( Lambda()
+		
+			req.Send()
+			
+		End )
+	End
+
+	Method OnRender( canvas:Canvas ) Override
+	
+		App.RequestRender()
+	
+		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
+	End
+	
+End
+
+Function Main()
+
+	New AppInstance
+	
+	New MyWindow
+	
+	App.Run()
+End

+ 4 - 1
bananas/spacechimps/spacechimps.monkey2

@@ -75,7 +75,10 @@ Class MyWindow Extends Window
 		Select event.Type
 		Case EventType.KeyDown
 			Select event.Key
-
+			Case Key.Enter
+				If event.Modifiers & Modifier.Alt
+					If Fullscreen EndFullscreen() Else BeginFullscreen()
+				Endif
 			Case Key.S
 			
 				SwapInterval=1-SwapInterval

+ 9 - 9
bin/env_macos.txt

@@ -55,12 +55,12 @@ MX2_LD_OPTS_EMSCRIPTEN_RELEASE=-O3
 'C compiler options
 MX2_CC_OPTS_EMSCRIPTEN=-std=gnu99 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 -s DISABLE_EXCEPTION_CATCHING=1
 MX2_CC_OPTS_EMSCRIPTEN_DEBUG=-O2
-MX2_CC_OPTS_EMSCRIPTEN_RELEASE=-O3
+MX2_CC_OPTS_EMSCRIPTEN_RELEASE=-O3 -DNDEBUG
 
 'C++ compiler options
 MX2_CPP_OPTS_EMSCRIPTEN=-std=c++11 -s USE_SDL=2 -s TOTAL_MEMORY=67108864 -s DISABLE_EXCEPTION_CATCHING=1
 MX2_CPP_OPTS_EMSCRIPTEN_DEBUG=-O2
-MX2_CPP_OPTS_EMSCRIPTEN_RELEASE=-O3
+MX2_CPP_OPTS_EMSCRIPTEN_RELEASE=-O3 -DNDEBUG
 
 
 '***** ANDROID *****
@@ -70,19 +70,19 @@ PATH=${HOME}/Library/Android/sdk/ndk-bundle:${PATH}
 
 '***** IOS *****
 
-MX2_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk
+MX2_SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.2.sdk
 
 'LD options
-MX2_LD_OPTS_IOS=-arch armv7 -isysroot ${MX2_SDKROOT}
-MX2_LD_OPTS_IOS_DEBUG=-O0 -g
-MX2_LD_OPTS_IOS_RELEASE=-O3
+MX2_LD_OPTS_IOS=-arch armv7 -arch arm64 -isysroot ${MX2_SDKROOT}
+MX2_LD_OPTS_IOS_DEBUG=
+MX2_LD_OPTS_IOS_RELEASE=-O3 
 
 'C compiler options
-MX2_CC_OPTS_IOS=-std=gnu99 -arch armv7 -isysroot ${MX2_SDKROOT} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
-MX2_CC_OPTS_IOS_DEBUG=-O0 -g
+MX2_CC_OPTS_IOS=-std=gnu99 -arch armv7 -arch arm64 -isysroot ${MX2_SDKROOT} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+MX2_CC_OPTS_IOS_DEBUG=
 MX2_CC_OPTS_IOS_RELEASE=-O3 -DNDEBUG
 
 'C++ compiler options
-MX2_CPP_OPTS_IOS=-std=c++11 -arch armv7 -isysroot ${MX2_SDKROOT} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
+MX2_CPP_OPTS_IOS=-std=c++11 -arch armv7 -arch arm64 -isysroot ${MX2_SDKROOT} -fobjc-arc -Wno-deprecated-declarations -Wno-tautological-pointer-compare -Wno-undefined-bool-conversion -Wno-int-to-void-pointer-cast -Wno-inconsistent-missing-override -Wno-logical-op-parentheses -Wno-parentheses-equality
 MX2_CPP_OPTS_IOS_DEBUG=-O0 -g
 MX2_CPP_OPTS_IOS_RELEASE=-O3 -DNDEBUG

+ 3 - 0
bin/env_windows.txt

@@ -73,6 +73,9 @@ MX2_CPP_OPTS_EMSCRIPTEN_RELEASE=-O3
 
 'PATH=D:\devtools\Android\sdk\ndk-bundle;${PATH}
 
+'Uncomment below to build for ALL android architectures (slow). Defaults to armeabi-v7a.
+MX2_ANDROID_APP_ABI=armeabi-v7a x86
+'MX2_ANDROID_APP_ABI=all
 
 '***** RASPBIAN *****
 

BIN
bin/mx2cc_linux


BIN
bin/mx2cc_macos


BIN
bin/mx2cc_windows.exe


+ 12 - 0
modules/httprequest/httprequest.monkey2

@@ -0,0 +1,12 @@
+
+Namespace httprequest
+
+#If __TARGET__="android"
+
+#Import "httprequest_android"
+
+#Else If __TARGET__="macos" Or  __TARGET__="ios"
+
+#Import "httprequest_ios"
+
+#Endif

+ 238 - 0
modules/httprequest/httprequest_android.monkey2

@@ -0,0 +1,238 @@
+
+Namespace httprequest
+
+#Import "<jni>"
+#Import "<std>"
+#Import "<mojo>"
+#Import "<sdl2>"
+
+#Import "native/Monkey2HttpRequest.java"
+#Import "native/httprequest.cpp"
+#Import "native/httprequest.h"
+
+Using jni..
+Using std..
+Using mojo..
+Using sdl2..
+
+Extern Private
+
+Global onReadyStateChanged:Void(jobject,Int)="bbHttpRequest::onReadyStateChanged"
+
+Global onResponseReceived:Void(jobject,String,Int,Int)="bbHttpRequest::onResponseReceived"
+
+private
+
+Function OnMainFiber( func:Void() )
+	
+	If Fiber.Current()=Fiber.Main() func() Else App.Idle+=func
+	
+End
+
+Public
+
+Enum ReadyState
+	
+	Unsent=0
+	Opened=1
+	HeadersReceived=2
+	Loading=3
+	Done=4
+	Error=5
+
+End
+
+Class HttpRequest
+	
+	Field ReadyStateChanged:Void()
+	
+	Method New()
+
+		Local env:=Android_JNI_GetEnv()
+		
+		Init( env )
+		
+		Local obj:=env.AllocObject( _class )
+		
+		_obj=env.NewGlobalRef( obj )
+		
+		Insert()
+	End
+	
+	Method New( req:String,url:String,readyStateChanged:Void()=Null )
+		Self.New()
+		
+		ReadyStateChanged=readyStateChanged
+		
+		Open( req,url )
+	End
+	
+	Property ReadyState:ReadyState()
+		
+		Return Cast<ReadyState>( _readyState )
+
+	End
+	
+	Property ResponseText:String()
+		
+		Return _response
+	End
+	
+	Property Status:Int()
+		
+		Return _status
+	End
+	
+	Method Discard()
+		
+		Remove()
+		
+		Local env:=Android_JNI_GetEnv()
+		
+		env.DeleteGlobalRef( _obj )
+		
+	End
+	
+	Method Open( req:String,url:String )
+		
+		OnMainFiber( Lambda()
+		
+			Local env:=Android_JNI_GetEnv()
+		
+			env.CallVoidMethod( _obj,_open,New Variant[]( req,url ) )
+		End )
+	End
+	
+	Method SetHeader( header:String,value:String )
+		
+		OnMainFiber( Lambda()
+
+			Local env:=Android_JNI_GetEnv()
+		
+			env.CallVoidMethod( _obj,_setHeader,New Variant[]( header,value ) )
+		End )
+	End
+	
+	Method Send()
+		
+		Send( "" )
+	End
+	
+	Method Send( text:String )
+		
+		OnMainFiber( Lambda()
+
+			Local env:=Android_JNI_GetEnv()
+		
+			env.CallVoidMethod( _obj,_send,New Variant[]( text ) )
+		
+		End )
+		
+	End
+	
+	Private
+	
+	Global _list:HttpRequest
+	
+	Field _succ:HttpRequest
+	Field _obj:jobject
+	Field _readyState:Int
+	Field _response:String
+	Field _status:int
+	
+	Method New( peer:jobject )
+		_obj=peer
+	End
+	
+	Method Insert()
+		_succ=_list
+		_list=Self
+	End
+	
+	Method Remove()
+		local inst:=_list,pred:HttpRequest=Null
+		While inst
+			If inst=Self
+				If pred
+					pred._succ=_succ
+				Else
+					_list=_succ
+				Endif
+				Return
+			Endif
+			pred=inst
+			inst=inst._succ
+		Wend
+	End
+	
+	Global _class:jclass
+	Global _open:jmethodID
+	Global _setHeader:jmethodID
+	Global _send:jmethodID
+	
+	Function OnReadyStateChanged( obj:jobject,state:Int )
+		
+		Local env:=Android_JNI_GetEnv()
+		
+		Local inst:=_list
+		
+		While inst
+			
+			If env.IsSameObject( obj,inst._obj )
+				
+				inst._readyState=state
+				
+				inst.ReadyStateChanged()
+				
+				Return
+			Endif
+			
+			inst=inst._succ
+		Wend
+		
+	End
+	
+	Function OnResponseReceived( obj:jobject,response:String,status:Int,state:Int )
+
+		Local env:=Android_JNI_GetEnv()
+		
+		Local inst:=_list
+		
+		While inst
+			
+			If env.IsSameObject( obj,inst._obj )
+				
+				inst._response=response
+				
+				inst._status=status
+				
+				inst._readyState=state
+				
+				inst.ReadyStateChanged()
+			
+			Endif
+
+			inst=inst._succ
+		wend
+	End
+	
+	Function Init( env:JNIEnv )
+		If _class Return
+	
+		_class=env.FindClass( "com/monkey2/lib/Monkey2HttpRequest" )
+		If Not _class RuntimeError( "Can't find com.monkey2.lib.Monkey2HttpRequest class" )
+		
+		_open=env.GetMethodID( _class,"open","(Ljava/lang/String;Ljava/lang/String;)V" )
+		
+		_setHeader=env.GetMethodID( _class,"setHeader","(Ljava/lang/String;Ljava/lang/String;)V" )
+	
+		_send=env.GetMethodID( _class,"send","(Ljava/lang/String;)V" )
+		
+		onReadyStateChanged=OnReadyStateChanged
+		
+		onResponseReceived=OnResponseReceived
+	End
+	
+End
+
+		

+ 38 - 0
modules/httprequest/httprequest_ios.monkey2

@@ -0,0 +1,38 @@
+
+Namespace httprequest
+
+#Import "native/httprequest.mm"
+
+#Import "native/httprequest.h"
+
+Extern
+
+Enum ReadyState="bbReadyState"
+	Unsent
+	Done
+	Error
+End
+
+Class HttpRequest="bbHttpRequest"
+	
+	Field ReadyStateChanged:Void()="readyStateChanged"
+	
+	Property ReadyState:ReadyState()="readyState"
+		
+	Property ResponseText:String()="responseText"
+		
+	Property Status:Int()="status"
+
+	Method New()
+		
+	Method New( req:String,url:String,readyStateChanged:Void()=Null )
+		
+	Method Open( req:String,url:String )="open"
+		
+	Method SetHeader( name:String,value:String )="setHeader"
+		
+	Method Send()="send"
+		
+	Method Send( text:String )="send"
+		
+End

+ 8 - 0
modules/httprequest/module.json

@@ -0,0 +1,8 @@
+{
+	"module":"httprequest",
+	"about":"HttpRequest module",
+	"author":"Mark Sibly",
+	"version":"1.0.0",
+	"depends":["jni","std","sdl2","mojo"]
+}
+

+ 116 - 0
modules/httprequest/native/Monkey2HttpRequest.java

@@ -0,0 +1,116 @@
+
+package com.monkey2.lib;
+
+import android.util.Log;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public class Monkey2HttpRequest{
+
+	private static final String TAG = "Monkey2HttpRequest";
+
+	HttpURLConnection connection;
+	
+	int readyState;
+	
+	boolean busy;
+
+    native void onNativeReadyStateChanged( int state );
+    
+    native void onNativeResponseReceived( String response,int status,int state );
+    
+    void setReadyState( int state ){
+    
+    	if( state==readyState ) return;
+    	
+    	onNativeReadyStateChanged( state );
+    	
+    	readyState=state;
+    }
+	
+	void open( String req,String url ){
+	
+		if( readyState!=0 ) return;
+		
+		try{
+		
+			URL turl=new URL( url );
+			connection=(HttpURLConnection)turl.openConnection();
+			connection.setRequestMethod( req );
+			
+			setReadyState( 1 );
+			
+		}catch( IOException ex ){
+		
+			setReadyState( 5 );
+		}		
+	}
+	
+	void setHeader( String name,String value ){
+	
+		if( readyState!=1 || busy ) return;
+	
+		connection.setRequestProperty( name,value );
+	}
+	
+	void send( final String text ){
+	
+		if( readyState!=1 || busy ) return;
+		
+		busy=true;
+		
+		new Thread( new Runnable() {
+
+			public void run() {
+
+				try {
+				
+					if( text!=null && text.length()!=0 ){
+			
+						byte[] bytes=text.getBytes( "UTF-8" );
+
+						connection.setDoOutput( true );
+						connection.setFixedLengthStreamingMode( bytes.length );
+				
+						OutputStream out=connection.getOutputStream();
+						out.write( bytes,0,bytes.length );
+						out.close();
+					}
+					
+					InputStream in=connection.getInputStream();
+					
+					setReadyState( 3 );
+
+					byte[] buf = new byte[4096];
+					ByteArrayOutputStream out=new ByteArrayOutputStream(1024);
+					for (; ; ) {
+						int n = in.read(buf);
+						if (n < 0) break;
+						out.write(buf, 0, n);
+					}
+					in.close();
+
+					String response=new String( out.toByteArray(),"UTF-8" );
+
+					int status=connection.getResponseCode();
+					
+					onNativeResponseReceived( response,status,4 );
+					
+					readyState=4;
+					
+				} catch ( IOException ex) {
+				
+					setReadyState( 5 );
+				}
+				
+				busy=false;
+			}
+			
+		} ).start();
+	}
+}

+ 90 - 0
modules/httprequest/native/httprequest.cpp

@@ -0,0 +1,90 @@
+
+#include "httprequest.h"
+
+#include "../../std/async/native/async.h"
+
+extern "C" JNIEnv *Android_JNI_GetEnv();	//SDL2
+
+namespace bbHttpRequest{
+
+	bbFunction<void( jobject,bbInt )> onReadyStateChanged;
+
+	bbFunction<void( jobject,bbString,bbInt,bbInt )> onResponseReceived;
+}
+
+namespace{
+
+	struct ReadyStateChangedEvent : public bbAsync::Event{
+		
+		jobject obj;
+		int state;
+		
+		ReadyStateChangedEvent( jobject obj,int state ):obj( obj ),state( state ){
+		}
+		
+		void dispatch(){
+		
+			bbHttpRequest::onReadyStateChanged( obj,state );
+			
+			JNIEnv *env=Android_JNI_GetEnv();
+			
+			env->DeleteGlobalRef( obj );
+			
+			delete this;
+		}
+	};
+
+	struct ResponseReceivedEvent : public bbAsync::Event{
+		
+		jobject obj;
+		jstring response;
+		int status;
+		int state;
+		
+		ResponseReceivedEvent( jobject obj,jstring response,int status,int state ):obj( obj ),response( response ),status( status ),state( state ){
+		}
+		
+		void dispatch(){
+		
+			JNIEnv *env=Android_JNI_GetEnv();
+			
+			const char *cstr=env->GetStringUTFChars( response,0 );
+		
+			bbString str=bbString::fromCString( cstr );
+		
+			env->ReleaseStringUTFChars( response,cstr );
+		
+			bbHttpRequest::onResponseReceived( obj,str,status,state );
+			
+			env->DeleteGlobalRef( response );
+			
+			env->DeleteGlobalRef( obj );
+			
+			delete this;
+		}
+	};
+}
+
+extern "C"{
+
+JNIEXPORT void JNICALL Java_com_monkey2_lib_Monkey2HttpRequest_onNativeReadyStateChanged( JNIEnv *env,jobject obj,int state ){
+
+	obj=env->NewGlobalRef( obj );
+
+	ReadyStateChangedEvent *ev=new ReadyStateChangedEvent( obj,state );
+	
+	ev->post();
+}
+
+JNIEXPORT void JNICALL Java_com_monkey2_lib_Monkey2HttpRequest_onNativeResponseReceived( JNIEnv *env,jobject obj,jstring response,int status,int state ){
+
+	obj=env->NewGlobalRef( obj );
+	
+	response=(jstring)env->NewGlobalRef( response );
+	
+	ResponseReceivedEvent *ev=new ResponseReceivedEvent( obj,response,status,state );
+	
+	ev->post();
+}
+
+}

+ 53 - 0
modules/httprequest/native/httprequest.h

@@ -0,0 +1,53 @@
+
+#include <bbmonkey.h>
+
+#if __APPLE__
+
+enum class bbReadyState{
+	Unsent=0,
+	Done=4,
+	Error=5
+};
+
+struct bbHttpRequest : public bbObject{
+
+	struct Rep;	//NS stuff...
+		
+	Rep *_rep;
+	
+	bbString _response;
+	int _readyState=0;
+	int _status=-1;
+	int _recv=-1;
+	
+	bbFunction<void()> readyStateChanged;
+	
+	bbHttpRequest();
+	
+	bbHttpRequest( bbString req,bbString url,bbFunction<void()> readyStateChanged );
+	
+	bbReadyState readyState();
+	bbString responseText();
+	int status();
+	
+	void open( bbString req,bbString url );
+	void setHeader( bbString name,bbString value );
+	void send();
+	void send( bbString text );
+
+	void gcMark();
+};
+	
+#else
+
+#include <jni.h>
+
+namespace bbHttpRequest{
+
+	extern bbFunction<void( jobject,bbInt )> onReadyStateChanged;
+	
+	extern bbFunction<void( jobject,bbString,bbInt,bbInt )> onResponseReceived;
+
+}
+
+#endif

+ 136 - 0
modules/httprequest/native/httprequest.mm

@@ -0,0 +1,136 @@
+
+#include "httprequest.h"
+
+#include "../../std/async/native/async.h"
+
+struct bbHttpRequest::Rep{
+	NSMutableURLRequest *_req;
+	NSString *_response;
+	int _status;	
+};
+
+namespace{
+
+	struct ReadyStateChangedEvent : public bbAsync::Event{
+
+		bbHttpRequest *req;
+		int state;
+
+		ReadyStateChangedEvent( bbHttpRequest *req,int state ):req( req ),state( state ){
+		}
+		
+		void dispatch(){
+		
+			if( state==req->_readyState ){
+		
+				if( req->_readyState==4 ){
+					req->_response=bbString( req->_rep->_response );
+					req->_status=req->_rep->_status;
+				}
+			
+				req->readyStateChanged();
+			}
+			
+			bbGC::release( req );
+			
+			delete this;
+		}
+	};
+
+}
+
+bbHttpRequest::bbHttpRequest(){
+
+	_rep=new Rep;
+}
+
+bbHttpRequest::bbHttpRequest( bbString req,bbString url,bbFunction<void()> readyStateChanged ):bbHttpRequest(){
+
+	this->readyStateChanged=readyStateChanged;
+
+	open( req,url );
+}
+	
+bbReadyState bbHttpRequest::readyState(){
+	
+	return (bbReadyState)_readyState;
+}
+	
+bbString bbHttpRequest::responseText(){
+
+	return _response;
+}
+	
+int bbHttpRequest::status(){
+	
+	return _status;
+}
+	
+void bbHttpRequest::open( bbString req,bbString url ){
+	
+	if( _readyState!=0 ) return;
+	
+	NSMutableURLRequest *nsreq=[[NSMutableURLRequest alloc] init];
+		
+	[nsreq setHTTPMethod:req.ToNSString()];
+	
+	[nsreq setURL:[NSURL URLWithString:url.ToNSString()]];
+	
+	if( [nsreq respondsToSelector:@selector(setAllowsCellularAccess:)] ){
+		[nsreq setAllowsCellularAccess:YES];
+	}
+	
+	_rep->_req=nsreq;
+		
+	_readyState=1;
+}
+	
+void bbHttpRequest::setHeader( bbString name,bbString value ){
+	
+	if( _readyState!=1 ) return;
+		
+	[_rep->_req setValue:value.ToNSString() forHTTPHeaderField:name.ToNSString()];
+}
+	
+void bbHttpRequest::send(){
+	
+	send( "" );
+}
+	
+void bbHttpRequest::send( bbString text ){
+	
+	if( _readyState!=1 ) return;
+		
+	bbGC::retain( this );
+
+	_readyState=3;	//loading
+	
+    std::thread( [=](){
+
+		NSURLResponse *response=0;
+			
+		NSData *data=[NSURLConnection sendSynchronousRequest:_rep->_req returningResponse:&response error:0];
+		
+		if( data && response ){
+			
+		  	_rep->_response=[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+		
+		    _rep->_status=[(NSHTTPURLResponse*)response statusCode];
+			    
+		    //_recv=[data length];
+		}
+		
+		_readyState=4;	//loaded
+		
+		ReadyStateChangedEvent *ev=new ReadyStateChangedEvent( this,_readyState );
+		
+		ev->post();
+			
+	} ).detach();
+}
+
+void bbHttpRequest::gcMark(){
+
+	bbGCMark( readyStateChanged ); 
+}
+

+ 92 - 0
modules/jni/jni.monkey2

@@ -0,0 +1,92 @@
+
+Namespace jni
+
+#If __TARGET__="android"
+
+#Import "native/jni_glue.cpp"
+#Import "native/jni_glue.h"
+
+Extern
+
+Struct _jclass
+End
+
+Alias jclass:_jclass Ptr
+
+Struct _jobject
+End
+
+Alias jobject:_jobject Ptr
+
+Struct _jstring
+End
+
+Alias jstring:_jstring Ptr
+
+Struct _jfieldID
+End
+
+Alias jfieldID:_jfieldID Ptr
+
+Struct _jmethodID
+End
+
+Alias jmethodID:_jmethodID Ptr
+
+Class JNIEnv Extends Void
+
+	'utils
+	'
+	Method JStringToString:String( jstr:jstring ) Extension="bbJNI::JStringToString"
+	
+	Method StringToJString:jstring( str:String ) Extension="bbJNI::StringToJString"
+		
+	'classes
+	'
+	Method FindClass:jclass( name:CString )
+
+	'fields...
+	'
+	Method GetFieldID:jfieldID( clazz:jclass,name:CString,sig:CString )
+	
+	Method GetObjectField:jobject( obj:jobject,fieldID:jfieldID )
+	
+	'static fields...
+	
+	Method GetStaticFieldID:jfieldID( clazz:jclass,name:CString,sig:CString )
+	
+	Method GetStaticObjectField:jobject( clazz:jclass,fieldID:jfieldID )
+	
+	'methods...
+	'
+	Method GetMethodID:jmethodID( clazz:jclass,name:CString,sig:CString )
+
+	Method CallVoidMethod:Void( obj:jobject,methodID:jmethodID,args:Variant[] ) Extension="bbJNI::CallVoidMethod"
+	
+	Method CallBooleanMethod:Bool( obj:jobject,methodID:jmethodID,args:Variant[] ) Extension="bbJNI::CallBooleanMethod"
+	
+	'static methods...
+	'
+	Method GetStaticMethodID:jmethodID( clazz:jclass,name:CString,sig:CString )
+	
+	Method CallStaticVoidMethod:Void( clazz:jclass,methodID:jmethodID,args:Variant[] ) Extension="bbJNI::CallStaticVoidMethod"
+	
+	Method CallStaticBooleanMethod:Bool( clazz:jclass,methodID:jmethodID,args:Variant[] ) Extension="bbJNI::CallStaticBooleanMethod"
+
+	'ctors...
+	'
+	Method AllocObject:jobject( clazz:jclass )
+		
+	Method NewObject:jobject( clazz:jclass,methodID:jmethodID )
+		
+	'refs...
+	'
+	Method NewGlobalRef:jobject( obj:jobject )
+		
+	Method DeleteGlobalRef( obj:jobject )
+		
+	Method IsSameObject:Bool( obj1:jobject,obj2:jobject )
+		
+End
+
+#End

+ 8 - 0
modules/jni/module.json

@@ -0,0 +1,8 @@
+{
+	"module":"jni",
+	"about":"Java JNI wrapper",
+	"author":"Mark Sibly",
+	"version":"1.0.0",
+	"support":"http://monkey2.monkey-x.com",
+	"depends":["mojo"]
+}

+ 122 - 0
modules/jni/native/jni_glue.cpp

@@ -0,0 +1,122 @@
+
+#include "jni_glue.h"
+
+namespace bbJNI{
+
+	bbString JStringToString( JNIEnv *env,jstring jstr ){
+	
+		const char *cstr=env->GetStringUTFChars( jstr,0 );
+		
+		bbString str=bbString::fromCString( cstr );
+		
+		env->ReleaseStringUTFChars( jstr,cstr );
+		
+		return str;
+	}
+	
+	jstring StringToJString( JNIEnv *env,bbString str ){
+	
+		int n=str.utf8Length()+1;
+		
+		char *buf=new char[n];
+		
+		str.toCString( buf,n );
+		
+		jstring jstr=env->NewStringUTF( buf );
+		
+		return jstr;
+	}
+
+	jvalue *makeArgs( JNIEnv *env,bbArray<bbVariant> args ){
+	
+		jvalue *jargs=new jvalue[args.length()];
+		
+		memset( jargs,0,sizeof( jvalue ) * args.length() );
+		
+		jvalue *jarg=jargs;
+		
+		for( int i=0;i<args.length();++i ){
+		
+			bbVariant arg=args[i];
+			
+			bbTypeInfo *type=arg.getType();
+			
+			if( type==bbGetType<bbBool>() ){
+			
+				bbBool val=arg.get<bbBool>();
+				
+				jarg->z=val;
+				
+			}else if( type==bbGetType<bbInt>() ){
+			
+				bbInt val=arg.get<bbInt>();
+				
+				jarg->i=val;
+			
+			}else if( type==bbGetType<bbString>() ){
+			
+				bbString str=arg.get<bbString>();
+				
+				int n=str.utf8Length()+1;
+				
+				char *buf=new char[n];
+				
+				str.toCString( buf,n );
+				
+				jstring jstr=env->NewStringUTF( buf );
+				
+				jarg->l=jstr;
+			
+			}else{
+			
+				bbRuntimeError( "Can't evaluate JNI method param of typ:"+type->toString() );
+			}
+			
+			++jarg;
+		}
+		
+		return jargs;
+	}
+	
+	void CallVoidMethod( JNIEnv *env,jobject obj,jmethodID methodID,bbArray<bbVariant> args ){
+		
+		jvalue *jargs=makeArgs( env,args );
+		
+		env->CallVoidMethodA( obj,methodID,jargs );
+		
+		delete[] jargs;
+	}
+
+	bbBool CallBooleanMethod( JNIEnv *env,jobject obj,jmethodID methodID,bbArray<bbVariant> args ){
+		
+		jvalue *jargs=makeArgs( env,args );
+		
+		bbBool r=env->CallBooleanMethodA( obj,methodID,jargs );
+		
+		delete[] jargs;
+		
+		return r;
+	}
+
+	void CallStaticVoidMethod( JNIEnv *env,jclass clazz,jmethodID methodID,bbArray<bbVariant> args ){
+		
+		jvalue *jargs=makeArgs( env,args );
+		
+		env->CallStaticVoidMethodA( clazz,methodID,jargs );
+		
+		delete[] jargs;
+	}
+
+	bbBool CallStaticBooleanMethod( JNIEnv *env,jclass clazz,jmethodID methodID,bbArray<bbVariant> args ){
+		
+		jvalue *jargs=makeArgs( env,args );
+		
+		bbBool r=env->CallStaticBooleanMethodA( clazz,methodID,jargs );
+		
+		delete[] jargs;
+		
+		return r;
+	}
+
+}
+

+ 20 - 0
modules/jni/native/jni_glue.h

@@ -0,0 +1,20 @@
+
+#include <jni.h>
+
+#include <bbmonkey.h>
+
+namespace bbJNI{
+
+	void CallVoidMethod( JNIEnv *env,jobject obj,jmethodID methodID,bbArray<bbVariant> args );
+	
+	bbBool CallBooleanMethod( JNIEnv *env,jobject obj,jmethodID methodID,bbArray<bbVariant> args );
+
+	void CallStaticVoidMethod( JNIEnv *env,jclass clazz,jmethodID methodID,bbArray<bbVariant> args );
+	
+	bbBool CallStaticBooleanMethod( JNIEnv *env,jclass clazz,jmethodID methodID,bbArray<bbVariant> args );
+	
+	bbString JStringToString( JNIEnv *env,jstring jstr );
+	
+	jstring StringToJString( JNIEnv *env,bbString str );
+
+}

+ 1 - 4
modules/mojo/app/app.monkey2

@@ -310,9 +310,6 @@ Class AppInstance
 	End
 	
 	#rem monkeydoc Mouse location relative to the active window.
-	
-	@see [[ActiveWindow]], [[MouseX]], [[MouseY]]
-	
 	#end	
 	Property MouseLocation:Vec2i()
 
@@ -692,7 +689,7 @@ Class AppInstance
 	
 		Keyboard.SendEvent( event )
 		
-'		Mouse.SendEvent( event )
+		Mouse.SendEvent( event )
 		
 		Touch.SendEvent( event )
 	

+ 2 - 2
modules/mojo/app/view.monkey2

@@ -5,11 +5,11 @@ Namespace mojo.app
 #end
 Class View
 
-	#rem monkeydoc Invoked when a view becomes visble and active.
+	#rem monkeydoc Invoked when a view becomes visible and active.
 	#end
 	Field Activated:Void()
 
-	#rem monkeydoc Invoked when a view is no longer visble or active.
+	#rem monkeydoc Invoked when a view is no longer visible or active.
 	#end
 	Field Deactivated:Void()
 

+ 14 - 5
modules/mojo/input/keyboard.monkey2

@@ -102,10 +102,12 @@ Class KeyboardDevice Extends InputDevice
 	@param key Key to check.
 	
 	#end
-	Method KeyPressed:Bool( key:Key )
+	Method KeyPressed:Bool( key:Key,repeating:Bool=False )
 	
 		Local scode:=ScanCode( key )
 		
+		If repeating Return _keys[scode].rpressed=_frame
+		
 		Return _keys[scode].pressed=_frame
 	End
 
@@ -127,9 +129,9 @@ Class KeyboardDevice Extends InputDevice
 	
 	#rem monkeydoc @hidden
 	#end
-	Method KeyHit:Bool( key:Key )
+	Method KeyHit:Bool( key:Key,repeating:Bool=False )
 
-		Return KeyPressed( key )
+		Return KeyPressed( key,repeating )
 	End
 	
 	#rem monkeydoc Peeks at the next character in the character queue.
@@ -225,7 +227,13 @@ Class KeyboardDevice Extends InputDevice
 			Local scode:=kevent->keysym.scancode
 			
 			_keys[scode].down=True
-			_keys[scode].pressed=_frame
+			If kevent->repeat_
+				_keys[scode].rpressed=_frame
+			Else
+				_keys[scode].pressed=_frame
+				_keys[scode].rpressed=_frame
+			Endif
+			
 			_modifiers=Cast<Modifier>( kevent->keysym.mod_ )
 			
 			Local char:=KeyToChar( _scan2key[scode] )
@@ -255,7 +263,8 @@ Class KeyboardDevice Extends InputDevice
 	
 	Struct KeyState
 		Field down:Bool
-		Field pressed:Int
+		Field pressed:Int	'frame of last keydown received
+		Field rpressed:Int	'frame of last keydown+repeat received
 		Field released:Int
 	End
 

+ 43 - 6
modules/mojo/input/mouse.monkey2

@@ -60,6 +60,24 @@ Class MouseDevice Extends InputDevice
 		Return _location
 	End
 	
+	#rem monkeydoc The mouse wheel delta x value since the last app update.
+	#end
+	Property WheelX:Int()
+		Return Wheel.x
+	End
+	
+	#rem monkeydoc The mouse wheel delta y value since the last app update.
+	#end
+	Property WheelY:Int()
+		Return Wheel.y
+	End
+	
+	#rem monkeydoc The mouse wheel delta value since the last app update.
+	#end
+	Property Wheel:Vec2i()
+		Return _wheel
+	End
+	
 	#rem monkeydoc Checks the current up/down state of a mouse button.
 	
 	Returns true if `button` is currently held down.
@@ -118,22 +136,33 @@ Class MouseDevice Extends InputDevice
 		UpdateButton( MouseButton.Left,mask & 1 )
 		UpdateButton( MouseButton.Middle,mask & 2 )
 		UpdateButton( MouseButton.Right,mask & 4)
+		
+		_wheel=Null
 	End
 	
 	#rem monkeydoc @hidden
 	#end
-	Method UpdateButton( button:MouseButton,down:Bool )
-		_pressed[button]=False
-		_released[button]=False
-		If down=_down[button] Return
-		If down _pressed[button]=True Else _released[button]=True
-		_down[button]=down
+	Method SendEvent( event:SDL_Event Ptr )
+	
+		Select event->type
+		
+		Case SDL_MOUSEWHEEL
+		
+			Local mevent:=Cast<SDL_MouseWheelEvent Ptr>( event )
+			
+			Local window:=Window.WindowForID( mevent->windowID )
+			If Not window Return
+			
+			_wheel+=New Vec2i( mevent->x,mevent->y )
+		
+		End
 	End
 	
 	Private
 
 	Field _init:Bool	
 	Field _location:Vec2i
+	Field _wheel:Vec2i
 	Field _down:=New Bool[4]
 	Field _pressed:=New Bool[4]
 	Field _released:=New Bool[4]
@@ -141,4 +170,12 @@ Class MouseDevice Extends InputDevice
 	Method New()
 	End
 	
+	Method UpdateButton( button:MouseButton,down:Bool )
+		_pressed[button]=False
+		_released[button]=False
+		If down=_down[button] Return
+		If down _pressed[button]=True Else _released[button]=True
+		_down[button]=down
+	End
+	
 End

+ 9 - 3
modules/mojo/input/touch.monkey2

@@ -85,6 +85,8 @@ Class TouchDevice Extends InputDevice
 		
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
+			Print "SDL_FINGERDOWN, id="+tevent->fingerId
+		
 			Local id:=-1
 			For Local i:=0 Until 10
 				If _fingers[i].down Continue
@@ -100,9 +102,11 @@ Class TouchDevice Extends InputDevice
 			_fingers[id].location=EventLocation( tevent )
 		
 		Case SDL_FINGERUP
-		
+
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
+			Print "SDL_FINGERUP, id="+tevent->fingerId
+		
 			Local id:=-1
 			For Local i:=0 Until 10
 				If Not _fingers[i].down Or _fingers[i].id<>tevent->fingerId Continue
@@ -117,9 +121,11 @@ Class TouchDevice Extends InputDevice
 			_fingers[id].location=EventLocation( tevent )
 			
 		Case SDL_FINGERMOTION
-		
+
 			Local tevent:=Cast<SDL_TouchFingerEvent Ptr>( event )
 			
+			Print "SDL_FINGERMOTION, id="+tevent->fingerId
+			
 			Local id:=-1
 			For Local i:=0 Until 10
 				If Not _fingers[i].down Or _fingers[i].id<>tevent->fingerId Continue
@@ -138,7 +144,7 @@ Class TouchDevice Extends InputDevice
 	Private
 	
 	Struct FingerState
-		Field id:Int
+		Field id:Long
 		Field down:Bool
 		Field pressed:Int
 		Field released:Int

+ 4 - 4
modules/mojox/docs/module.md

@@ -3,8 +3,8 @@
 
 The mojox module provides a simple but highly customizable gui system, built on top of mojo. Mojox also uses 'auto-layout' as much as possible, so you don't generally have to provide location/size of widgets, and can easily change fonts, skins etc without having to manually 're-layout' your gui.
 
-Much of the core functionality of mojox is actually implemented in the mojo module by the [[mojo.app.AppInstance]] 
-and [[mojo.app.View]] classes. The View class is the base class of all 'widgets' in mojo/mojox (including the mojo Window class), and mojox really just provides a set of useful view subclasses provide buttons, text views, dialogs etc.
+Much of the core functionality of mojox is actually implemented in the mojo module by the [[mojo.app.AppInstance|AppInstance]] 
+and [[mojo.app.View|View]] classes. The View class is the base class of all 'widgets' in mojo/mojox (including the mojo Window class), and mojox really just provides a set of useful view subclasses that provide buttons, text views, dialogs etc.
 
 Views are stored in a simple 'tree' structure, where each view has an optional parent, and 0 or more children.
 
@@ -35,6 +35,6 @@ Here is a relatively crappy diagram that may or may not help!
 
 Gui layout is a 2 step process:
 
-* First, all views are measured by calling their [[View.OnMeasure]] method. This step occurs in 'bottom up' order so any view's whose size is dependant on a child view's size can be sure the child has been measured first. A view's OnMeasure method should return it's preferred size - that is, the size it would like to be. Once a view has been measured, you can use the [[View.LayoutSize]] property to retrieve a view's preferred layout size. Note that this is not the value returned by the view's OnMeasure method, but an adjusted size that takes the view's style into account.
+* First, all views are measured by calling their [[mojo.app.View.OnMeasure|OnMeasure]] method. This step occurs in 'bottom up' order so any view's whose size is dependant on a child view's size can be sure the child has been measured first. A view's OnMeasure method should return it's preferred size - that is, the size it would like to be. Once a view has been measured, you can use the [[mojo.app.View.LayoutSize|LayoutSize]] property to retrieve a view's preferred layout size. Note that this is not the value returned by the view's OnMeasure method, but an adjusted size that takes the view's style into account.
 
-* Once measuring is complete, layout is then performed by calling the [[View.OnLayout]] method for all views in 'top down' order. View's that are responsible for handling the layout of child views should set the [[View.Frame]] property of any child views they 'own' during OnLayout. A view may by further positioned and size within it's frame depending on its [[View.Layout]] property. For example, if a view's layout is "fill", the view is resized to completely fill its frame; if layout is "float", the view retains its measured size but is positioned within its frame according to its [[View.Gravity]].
+* Once measuring is complete, layout is then performed by calling the [[mojo.app.View.OnLayout|OnLayout]] method for all views in 'top down' order. View's that are responsible for handling the layout of child views should set the [[mojo.app.View.Frame|Frame]] property of any child views they 'own' during OnLayout. A view may by further positioned and size within it's frame depending on its [[mojo.app.View.Layout]] property. For example, if a view's layout is "fill", the view is resized to completely fill its frame; if layout is "float", the view retains its measured size but is positioned within its frame according to its [[mojo.app.View.Gravity|Gravity]] property.

+ 12 - 1
modules/mojox/filebrowser.monkey2

@@ -178,7 +178,7 @@ Class FileBrowser Extends TreeView
 			child.Text=f
 			child._path=fpath
 			
-			Local icon:=_fileTypeIcons[ExtractExt( f ).ToLower()]
+			Local icon:=GetFileTypeIcon( fpath )
 			
 			If i<dirs.Length
 				If Not icon icon=_dirIcon
@@ -231,6 +231,17 @@ Class FileBrowser Extends TreeView
 		Return _fileTypeIcons
 	End
 	
+	Protected
+	
+	Method GetFileTypeIcon:Image( path:String ) Virtual
+	
+		Local ext:=ExtractExt( path )
+		If Not ext Return Null
+		
+		Return GetFileTypeIcons()[ ext.ToLower() ]
+	End
+	
+	
 	Private
 	
 	Global _fileTypeIcons:StringMap<Image>

+ 80 - 0
modules/monkey/docs/language/arrays.md

@@ -0,0 +1,80 @@
+
+### Arrays
+
+An array is a linear sequence of values that can be addressed using one or more integer indices.
+
+Each array has an associated element type. That is, the type of the values actually stored in the array. An array's element type is a purely static property. It is only known at compile time so arrays cannot be 'downcast' at runtime.
+
+The syntax used for declaring values and variables of array type is: 
+
+_ElementType_ `[` [`,`...] `]`
+
+An array can also be multidimensional, in which case the '[]' will contain 1 or more commas.
+
+Here are some example of declaring array variables:
+
+```
+Local ints:Int[]			'One dimensional int array.
+Local map[,]				'Two dimension int array.
+Local funcs:Int()[]			'One dimensional array of functions of type Int().
+Local stacks:Stack<Int>[]	'One dimensional array of stacks of type Int.
+```
+
+#### Creating arrays
+
+Declaring an array does not actually create an array. To do that you must use `New`.
+
+`New` can be used to create either an unintialized or preinitialized array. The syntax for creating an uninitialized array is:
+
+`New` _ElementType_ `[` _DimensionSizes_ `]`
+
+(Note: the elements of an 'uninitialized' array are actually initialized to 'Null'!)
+
+The syntax for creating an initialized array is:
+
+`New` _ElementType_[]( _Element0_`,`_Element1_`,`...etc )
+
+Here are some examples:
+
+```
+Local ints:Int[]=New Int[10]				'Creates a ten element integer array.
+Local flts:=New Float[]( 1.0,3,5.1,7,9.2 )	'Creates a 5 element float array initialized to 1.0,3,5.1,7,9.2 
+```
+
+#### Iterating through arrays
+
+You can iterate through the elements of an array using `Eachin`, eg:
+
+```
+Local arr:=New Int[]( 1,3,5,7,9 )
+For Local i:=Eachin arr
+	Print i
+Next
+```
+
+#### Slicing arrays
+
+One dimensional arrays can be sliced using the `Slice` method, eg:
+
+```
+Local ints:=New Int[]( 1,3,5,7,9 )
+ints=ints.Slice( 1,4 )	'ints now contains 3,5,7
+```
+
+For more information, see the [[types.Array.Slice|Array.Slice]] API documentation.
+
+
+#### Resizing arrays
+
+One dimensional arrays can be resized using the `Resize` method, eg:
+
+```
+Local ints:=New Int[]( 1,2,3 )
+ints=ints.Resize( 5 )	'ints now contains 1,2,3,0,0
+```
+
+(Note that resize does not actually resize the array! It actually returns a resized *copy* of the array.)
+
+Note that mutidimensional arrays cannot currently be sliced or resized, and you cannot create an initialized multidimensional arrays. These features are planned for the future though.
+
+For more information, see the [[types.Array.Resize|Array.Resize]] API documentation.

+ 3 - 0
modules/monkey/docs/language/language.md

@@ -10,6 +10,9 @@ Note: This documentation is currently WIP.
 @import modules.md
 @import namespaces.md
 @import types.md
+@import arrays.md
+@import strings.md
+@import variants.md
 @import variables.md
 @import functions.md
 @import expressions.md

+ 0 - 49
modules/monkey/docs/language/reflection.md

@@ -1,55 +1,6 @@
 
 ### Reflection
 
-#### Variants
-
-The Variant type is a primitive type that can be used to 'box' values of any type.
-
-The easiest way to create a variant is to cast a value to Variant (much like casting an Int to String etc), eg:
-
-`Local v:=Variant( 10 )`
-
-An uninitialized variant will contain a 'null' value (of type Void) until you assign something to it:
-
-```
-Local v:Variant
-v=10				'variant now contains an int 10.
-v="hello"			'variant now contains a string "hello".
-```
-
-A variant is 'true' if it contains any value with a non-void type (including a bool false value!) and 'false' if it is uninitialized and has no (void) type.
-
-Any type of value can be implicitly converted to a variant, so you can easily pass anything to a function with variant parameters:
-
-```
-Function Test( v:Variant )
-End
-
-Function Main()
-	Test( 1 )
-	Test( "Hello" )
-	Test( New Int[] )
-	Test( Main )
-End
-```
-
-To retrieve the value contained in a variant, you must explicitly cast the variant to the desired type:
-
-```
-Local v:=Variant( 100 )
-Print Cast<Int>( v )
-```
-
-Note that the cast must specify the exact type of the value already contained in the variant, or a runtime error will occur:
-
-```
-Local v:=Variant( 10 )
-Print Cast<String>( v )	'Runtime error! Variant contains an Int not a String!
-```
-
-The one exception to this is if the Variant contains a class object, in which case you can cast the variant to any valid base class of the object.
-
-
 #### Typeof and TypeInfo
 
 The Typeof operator return a TypeInfo object, that contains various properties and methods for inspecting types at runtime. There are 2 ways to use Typeof:

+ 49 - 0
modules/monkey/docs/language/strings.md

@@ -0,0 +1,49 @@
+
+### Strings
+
+Values of type String are used to represent sequences of characters, such as text. The exact size of each character in a string value is target dependent, but is at least 8 bits.
+
+String variables are declared using the type name `String`, for example:
+
+```
+Local test:String="Hello World"
+```
+
+String literals are sequences of characters enclosed in "" (quotation marks). String literals may also include escape sequences, special sequences of characters used to represent unprintable characters.
+
+You can use the following escape sequences in string literals:
+
+| Escape sequence	| Character code
+|:------------------|:--------------
+|~q					| 34 (quotation mark ")
+|~n					| 10 (newline)
+|~r					| 13 (return)
+|~t					| 9 (tab)
+|~z					| 0 (null)
+|~~	 				| 126 (tilde ~)
+
+For example, to include literal quotation marks in a string...
+
+```
+Local test:="~qHello World~q" 
+```
+
+You can index a string using the `[]' operator, eg:
+```
+Local str:="Hello World"
+For Local i:=0 Until str.Length
+	Print str[i]
+Next
+```
+
+Indexing a string will return the character code at a given string index as an int.
+
+You can iterate through the characters in a string using `Eachin`, eg:
+
+```
+For Local chr:=Eachin "Hello World"
+	Print chr
+Next
+```
+
+For more information on strings, please see the [[types.String|String]] API reference.

+ 2 - 2
modules/monkey/docs/language/types.md

@@ -28,9 +28,9 @@ The following compound types are supported by monkey2:
 
 | Type						| Description
 |:--------------------------|:-----------
-| _Type_ `[]`				| Array type
+| _Type_ `[` [,...] `]`				| Array type
 | _Type_ `Ptr`				| Pointer type
-| _Type_ `(` _Types_ `)`		| Function type
+| _Type_ `(` _Types_ `)`	| Function type
 
 
 #### Implicit type conversions

+ 1 - 1
modules/monkey/docs/language/variables.md

@@ -1,5 +1,5 @@
 
-### Variables and Consts
+### Variables
 
 #### Local variables
 

+ 47 - 0
modules/monkey/docs/language/variants.md

@@ -0,0 +1,47 @@
+### Variants
+
+The Variant type is a primitive type that can be used to 'box' values of any type.
+
+The easiest way to create a variant is to cast a value to Variant (much like casting an Int to String etc), eg:
+
+`Local v:=Variant( 10 )`
+
+An uninitialized variant will contain a 'null' value (of type Void) until you assign something to it:
+
+```
+Local v:Variant
+v=10				'variant now contains an int 10.
+v="hello"			'variant now contains a string "hello".
+```
+
+A variant is 'true' if it contains any value with a non-void type (including a bool false value!) and 'false' if it is uninitialized and has no (void) type.
+
+Any type of value can be implicitly converted to a variant, so you can easily pass anything to a function with variant parameters:
+
+```
+Function Test( v:Variant )
+End
+
+Function Main()
+	Test( 1 )
+	Test( "Hello" )
+	Test( New Int[] )
+	Test( Main )
+End
+```
+
+To retrieve the value contained in a variant, you must explicitly cast the variant to the desired type:
+
+```
+Local v:=Variant( 100 )
+Print Cast<Int>( v )
+```
+
+Note that the cast must specify the exact type of the value already contained in the variant, or a runtime error will occur:
+
+```
+Local v:=Variant( 10 )
+Print Cast<String>( v )	'Runtime error! Variant contains an Int not a String!
+```
+
+The one exception to this is if the Variant contains a class object, in which case you can cast the variant to any valid base class of the object.

+ 44 - 0
modules/monkey/native/bbgc.cpp

@@ -42,6 +42,11 @@
 	
 #endif
 
+struct bbGCRetained{
+	bbGCRetained *succ;
+	bbGCNode *node;
+};
+
 namespace bbGC{
 
 	int markedBit;
@@ -65,6 +70,9 @@ namespace bbGC{
 	size_t unmarkedBytes;
 	size_t allocedBytes;
 	
+	bbGCRetained *retained;
+	bbGCRetained *retained_free;
+	
 	void init(){
 		static bool done;
 		if( done ) return;
@@ -137,6 +145,14 @@ namespace bbGC{
 		}
 	}
 	
+	void markRetained(){
+	
+		for( bbGCRetained *r=retained;r;r=r->succ ){
+			if( r->node ) r->node->gcMark();
+				r=r->succ;
+		}
+	}
+	
 	void markFibers(){
 	
 		bbGCFiber *fiber=fibers;
@@ -186,6 +202,8 @@ namespace bbGC{
 	
 //		puts( "bbGC::sweep()" );fflush( stdout );
 	
+		markRetained();
+		
 		markFibers();
 	
 		markQueued();
@@ -263,4 +281,30 @@ namespace bbGC{
 		
 //		printf( "GCCollect: in use=%i\n",(int)unmarkedBytes );fflush( stdout );
 	}
+	
+	void retain( bbGCNode *node ){
+		bbGCRetained *r=retained_free;
+		if( !r ){
+			//should alloc buf-worth...
+			r=new bbGCRetained;
+		}
+		r->node=node;
+		r->succ=retained;
+		retained=r;
+	}
+	
+	void release( bbGCNode *node ){
+		bbGCRetained **p=&retained;
+		while( bbGCRetained *r=*p ){
+			if( r->node==node ){
+				*p=r->succ;
+				r->succ=retained_free;
+				retained_free=r;
+				return;
+			}
+			p=&r->succ;
+			r=r->succ;
+		}
+		printf( "Wanting! bbGC::release() node not found!\n" );
+	}
 }

+ 4 - 0
modules/monkey/native/bbgc.h

@@ -143,6 +143,10 @@ struct bbGCTmp{
 };
 
 namespace bbGC{
+
+	void retain( bbGCNode *p );
+	
+	void release( bbGCNode *p );
 	
 	inline void insert( bbGCNode *p,bbGCNode *succ ){
 		p->succ=succ;

+ 4 - 0
modules/monkey/native/bbstd.h

@@ -2,6 +2,10 @@
 #ifndef BB_STD_H
 #define BB_STD_H
 
+#if __OBJC__
+#import <Foundation/Foundation.h>
+#endif
+
 #include <new>
 #include <initializer_list>
 

+ 12 - 0
modules/monkey/native/bbstring.h

@@ -86,6 +86,11 @@ class bbString{
 	
 	bbString( const wchar_t *data,int length ):_rep( Rep::create( data,length ) ){
 	}
+	
+#if __OBJC__
+	bbString( NSString *str ):_rep( Rep::create( str.UTF8String ) ){
+	}
+#endif
 
 	explicit bbString( int n ){
 		char data[64];
@@ -464,6 +469,12 @@ class bbString{
 
 	void toWString( void *buf,int size )const;
 	
+#if __OBJC__	
+	NSString *ToNSString()const{
+		return [NSString stringWithUTF8String:c_str()];
+	}
+#endif
+	
 	static bbString fromChar( int chr );
 	
 	static bbString fromChars( bbArray<int> chrs );
@@ -534,3 +545,4 @@ inline bbString BB_T( const char *p ){
 }
 
 #endif
+

BIN
modules/openal/openal-soft/jniLibs/arm64-v8a/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/armeabi/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/mips/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/mips64/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/x86/libopenal.so


BIN
modules/openal/openal-soft/jniLibs/x86_64/libopenal.so


+ 24 - 23
modules/openal/openal.monkey2

@@ -1,45 +1,46 @@
 
-#import "<libc>"
+#Import "<libc>"
 
 #if __TARGET__="windows"
 
-	#import "openal-soft/bin/OpenAL32.dll"
-	#import "openal-soft/lib/OpenAL32.lib"
+	#Import "openal-soft/bin/OpenAL32.dll"
+	#Import "openal-soft/lib/OpenAL32.lib"
 		
-	#import "openal-soft/include/*.h"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "openal-soft/include/*.h"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 	
 #else if __TARGET__="macos"
 	
-	#import "<OpenAL.framework>"
+	#Import "<OpenAL.framework>"
 		
-	#import "<OpenAL/al.h>"
-	#import "<OpenAL/alc.h>"
+	#Import "<OpenAL/al.h>"
+	#Import "<OpenAL/alc.h>"
 		
 #else if __TARGET__="linux" or __TARGET__="raspbian"
 	
-	#import "<libopenal.a>"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "<libopenal.a>"
 	
-#else if __TARGET__="emscripten"
-
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
+	
+#Else if __TARGET__="emscripten"
 
-#else if __TARGET__="android"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 
-	#Import "openal-soft/jniLibs/armeabi-v7a/libopenal.so"
+#Else if __TARGET__="android"
+	
+	#Import "openal-soft/jniLibs/$(TARGET_ARCH_ABI)/libopenal.so"
 
-	#import "openal-soft/include/*.h"
-	#import "<AL/al.h>"
-	#import "<AL/alc.h>"
+	#Import "openal-soft/include/*.h"
+	#Import "<AL/al.h>"
+	#Import "<AL/alc.h>"
 	
 #else if __TARGET__="ios"
 
-	#import "<OpenAL/al.h>"
-	#import "<OpenAL/alc.h>"
+	#Import "<OpenAL/al.h>"
+	#Import "<OpenAL/alc.h>"
 
 #endif
 		

+ 16 - 0
modules/sdl2/sdl2.monkey2

@@ -1,10 +1,18 @@
 
 Namespace sdl2
 
+#Import "<jni>"
 #Import "<libc>"
 #Import "<gles20>"
 
 #Import "SDL/include/*.h"
+
+#If __TARGET__="android"
+
+#Import "SDL/src/core/android/SDL_android.h"
+
+#Endif
+
 #Import "<SDL.h>"
 
 #Import "makefile.monkey2"
@@ -13,6 +21,14 @@ Using libc
 
 Extern
 
+#If __TARGET__="android"
+
+Function Android_JNI_GetEnv:jni.JNIEnv()
+Function Android_JNI_GetActivityClass:jni.jclass()
+Function Android_JNI_SetActivityTitle( title:CString )
+
+#Endif
+
 Struct SDL_Surface
 End
 

+ 1 - 1
modules/std/audio/load_vorbis.monkey2

@@ -19,7 +19,7 @@ Function LoadAudioData_OGG:AudioData( path:String )
 	Case 1 
 		format=AudioFormat.Mono16
 	Case 2 
-		format=AudioFormat.Mono16
+		format=AudioFormat.Stereo16
 	Default
 		libc.free( samples )
 		Return Null

+ 12 - 2
modules/std/fiber/fcontext.monkey2

@@ -26,18 +26,28 @@ Namespace std.fiber
 	#import "native/asm/jump_x86_64_sysv_elf_gas.S"
 	#import "native/asm/ontop_x86_64_sysv_elf_gas.S"
 	
-#Else If __TARGET__="android" or __TARGET__="raspbian"
+#Else If __TARGET__="android"
+ 
+	#Import "native/asm/android-$(TARGET_ARCH)/make.S"
+	#Import "native/asm/android-$(TARGET_ARCH)/jump.S"
+	#Import "native/asm/android-$(TARGET_ARCH)/ontop.S"
+
+#Else If __TARGET__="raspbian"
 
 	#import "native/asm/make_arm_aapcs_elf_gas.S"
 	#import "native/asm/jump_arm_aapcs_elf_gas.S"
 	#import "native/asm/ontop_arm_aapcs_elf_gas.S"
-
+	
 #Else If __TARGET__="ios"
 
 	#import "native/asm/make_arm_aapcs_macho_gas.S"
 	#import "native/asm/jump_arm_aapcs_macho_gas.S"
 	#import "native/asm/ontop_arm_aapcs_macho_gas.S"
 
+	#import "native/asm/make_arm64_aapcs_macho_gas.S"
+	#import "native/asm/jump_arm64_aapcs_macho_gas.S"
+	#import "native/asm/ontop_arm64_aapcs_macho_gas.S"
+
 #Endif
 
 Extern Private

+ 58 - 0
modules/std/fiber/native/asm/android-arm/jump.S

@@ -0,0 +1,58 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,%function
+jump_fcontext:
+    @ save LR as PC
+    push {lr}
+    @ save hidden,V1-V8,LR
+    push {a1,v1-v8,lr}
+
+    @ store RSP (pointing to context-data) in A1
+    mov  a1, sp
+
+    @ restore RSP (pointing to context-data) from A2
+    mov  sp, a2
+
+    @ restore hidden,V1-V8,LR
+    pop {a4,v1-v8,lr}
+
+    @ return transfer_t from jump
+    str  a1, [a4, #0]
+    str  a3, [a4, #4]
+    @ pass transfer_t as first arg in context function
+    @ A1 == FCTX, A2 == DATA
+    mov  a2, a3
+
+    @ restore PC
+    pop {pc}
+.size jump_fcontext,.-jump_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 62 - 0
modules/std/fiber/native/asm/android-arm/make.S

@@ -0,0 +1,62 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,%function
+make_fcontext:
+    @ shift address in A1 to lower 16 byte boundary
+    bic  a1, a1, #15
+
+    @ reserve space for context-data on context-stack
+    sub  a1, a1, #60
+
+    @ third arg of make_fcontext() == address of context-function
+    str  a3, [a1, #40]
+
+    @ compute address of returned transfer_t
+    add  a2, a1, #44
+    mov  a3, a2
+    str  a3, [a1, #0]
+
+    @ compute abs address of label finish
+    adr  a2, finish
+    @ save address of finish as return-address for context-function
+    @ will be entered after context-function returns
+    str  a2, [a1, #36]
+
+    bx  lr @ return pointer to context-data
+
+finish:
+    @ exit code is zero
+    mov  a1, #0
+    @ exit application
+    bl  _exit@PLT
+.size make_fcontext,.-make_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 63 - 0
modules/std/fiber/native/asm/android-arm/ontop.S

@@ -0,0 +1,63 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |hiddn|  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |  v8 |  lr |  pc | FCTX| DATA|                 |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,%function
+ontop_fcontext:
+    @ save LR as PC
+    push {lr}
+    @ save hidden,V1-V8,LR
+    push {a1,v1-v8,lr}
+
+    @ store RSP (pointing to context-data) in A1
+    mov  a1, sp
+
+    @ restore RSP (pointing to context-data) from A2
+    mov  sp, a2
+
+    @ store parent context in A2
+    mov  a2, a1
+
+    @ restore hidden,V1-V8,LR
+    pop {a1,v1-v8,lr}
+
+    @ return transfer_t from jump
+    str  a2, [a1, #0]
+    str  a3, [a1, #4]
+    @ pass transfer_t as first arg in context function
+    @ A1 == hidden, A2 == FCTX, A3 == DATA
+
+    @ skip PC
+    add  sp, sp, #4
+
+    @ jump to ontop-function
+    bx  a4
+.size ontop_fcontext,.-ontop_fcontext
+
+@ Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 88 - 0
modules/std/fiber/native/asm/android-arm64/jump.S

@@ -0,0 +1,88 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global jump_fcontext
+.type   jump_fcontext, %function
+jump_fcontext:
+    # prepare stack for GP + FPU
+    sub  sp, sp, #0x70
+
+    # save x19-x30
+    stp  x19, x20, [sp, #0x00]
+    stp  x21, x22, [sp, #0x10]
+    stp  x23, x24, [sp, #0x20]
+    stp  x25, x26, [sp, #0x30]
+    stp  x27, x28, [sp, #0x40]
+    stp  x29, x30, [sp, #0x50]
+
+    # save LR as PC
+    str  x30, [sp, #0x60]
+
+    # store RSP (pointing to context-data) in X0
+    mov  x4, sp
+
+    # restore RSP (pointing to context-data) from X1
+    mov  sp, x0
+
+    # load x19-x30
+    ldp  x19, x20, [sp, #0x00]
+    ldp  x21, x22, [sp, #0x10]
+    ldp  x23, x24, [sp, #0x20]
+    ldp  x25, x26, [sp, #0x30]
+    ldp  x27, x28, [sp, #0x40]
+    ldp  x29, x30, [sp, #0x50]
+
+    # return transfer_t from jump
+    # pass transfer_t as first arg in context function
+    # X0 == FCTX, X1 == DATA
+    mov x0, x4
+
+    # load pc
+    ldr  x4, [sp, #0x60]
+
+    # restore stack from GP + FPU
+    add  sp, sp, #0x70
+
+    ret x4
+.size   jump_fcontext,.-jump_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 71 - 0
modules/std/fiber/native/asm/android-arm64/make.S

@@ -0,0 +1,71 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global make_fcontext
+.type   make_fcontext, %function
+make_fcontext:
+    # shift address in x0 (allocated stack) to lower 16 byte boundary
+    and x0, x0, ~0xF
+
+    # reserve space for context-data on context-stack
+    sub  x0, x0, #0x70
+
+    # third arg of make_fcontext() == address of context-function
+    # store address as a PC to jump in
+    str  x2, [x0, #0x60]
+
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns (LR register)
+    adr  x1, finish
+    str  x1, [x0, #0x58]
+
+    ret  x30 // return pointer to context-data (x0)
+
+finish:
+    # exit code is zero
+    mov  x0, #0
+    # exit application
+    bl  _exit
+
+.size   make_fcontext,.-make_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-arm64/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Edward Nevill + Oliver Kowalke 2015
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c|  *
+ *  -------------------------------------------------  *
+ *  |    x19    |    x20    |    x21    |    x22    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c|  *
+ *  -------------------------------------------------  *
+ *  |    x23    |    x24    |    x25    |    x26    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
+ *  -------------------------------------------------  *
+ *  | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c|  *
+ *  -------------------------------------------------  *
+ *  |    x27    |    x28    |    FP     |     LR    |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  24 |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  *
+ *  -------------------------------------------------  *
+ *  | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c|  *
+ *  -------------------------------------------------  *
+ *  |     PC    |   align   |           |           |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ *******************************************************/
+
+# .cpu    generic+fp+simd
+.text
+.align  2
+.global ontop_fcontext
+.type   ontop_fcontext, %function
+ontop_fcontext:
+    # prepare stack for GP + FPU
+    sub  sp, sp, #0x70
+
+    # save x19-x30
+    stp  x19, x20, [sp, #0x00]
+    stp  x21, x22, [sp, #0x10]
+    stp  x23, x24, [sp, #0x20]
+    stp  x25, x26, [sp, #0x30]
+    stp  x27, x28, [sp, #0x40]
+    stp  x29, x30, [sp, #0x50]
+
+    # save LR as PC
+    str  x30, [sp, #0x60]
+
+    # store RSP (pointing to context-data) in X5
+    mov  x4, sp
+
+    # restore RSP (pointing to context-data) from X1
+    mov  sp, x0
+
+    # load x19-x30
+    ldp  x19, x20, [sp, #0x00]
+    ldp  x21, x22, [sp, #0x10]
+    ldp  x23, x24, [sp, #0x20]
+    ldp  x25, x26, [sp, #0x30]
+    ldp  x27, x28, [sp, #0x40]
+    ldp  x29, x30, [sp, #0x50]
+
+    # return transfer_t from jump
+    # pass transfer_t as first arg in context function
+    # X0 == FCTX, X1 == DATA
+    mov x0, x4
+
+    # skip pc
+    # restore stack from GP + FPU
+    add  sp, sp, #0x70
+
+    # jump to ontop-function
+    ret x2
+.size   ontop_fcontext,.-ontop_fcontext
+# Mark that we don't need executable stack.
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips/jump.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+.ent jump_fcontext
+jump_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a1, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == fctx, A1 == data
+    move  $a1, $a2 
+
+    # jump to context
+    jr  $t9
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips/make.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set    noreorder
+.cpload $t9
+.set    reorder
+#endif
+    # first arg of make_fcontext() == top address of context-stack
+    move $v0, $a0
+
+    # shift address in A0 to lower 16 byte boundary
+    move $v1, $v0
+    li $v0, -16 # 0xfffffffffffffff0
+    and $v0, $v1, $v0
+
+    # reserve space for context-data on context-stack
+    # including 48 byte of shadow space (sp % 16 == 0)
+    addiu $v0, $v0, -112
+
+    # third arg of make_fcontext() == address of context-function
+    sw  $a2, 44($v0)
+    # save global pointer in context-data
+    sw  $gp, 48($v0)
+
+    # compute address of returned transfer_t
+    addiu $t0, $v0, 52
+    sw  $t0, 36($v0)
+
+    # compute abs address of label finish
+    la  $t9, finish
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns
+    sw  $t9, 40($v0)
+
+    jr  $ra # return pointer to context-data
+
+finish:
+    lw $gp, 0($sp)
+    # allocate stack space (contains shadow space for subroutines)
+    addiu  $sp, $sp, -32
+    # save return address
+    sw  $ra, 28($sp)
+
+    # restore GP (global pointer)
+#    move  $gp, $s1
+    # exit code is zero
+    move  $a0, $zero
+    # address of exit
+    lw  $t9, %call16(_exit)($gp)
+    # exit application
+    jalr  $t9
+.end make_fcontext
+.size make_fcontext, .-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-mips/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+.ent ontop_fcontext
+ontop_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a2, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == hidden, A1 == fctx, A2 == data
+    move  $a1, $a0 
+    move  $a0, $t0 
+
+    # jump to context
+    jr  $a3
+.end ontop_fcontext
+.size ontop_fcontext, .-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips64/jump.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+.ent jump_fcontext
+jump_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a1, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == fctx, A1 == data
+    move  $a1, $a2 
+
+    # jump to context
+    jr  $t9
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 86 - 0
modules/std/fiber/native/asm/android-mips64/make.S

@@ -0,0 +1,86 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set    noreorder
+.cpload $t9
+.set    reorder
+#endif
+    # first arg of make_fcontext() == top address of context-stack
+    move $v0, $a0
+
+    # shift address in A0 to lower 16 byte boundary
+    move $v1, $v0
+    li $v0, -16 # 0xfffffffffffffff0
+    and $v0, $v1, $v0
+
+    # reserve space for context-data on context-stack
+    # including 48 byte of shadow space (sp % 16 == 0)
+    addiu $v0, $v0, -112
+
+    # third arg of make_fcontext() == address of context-function
+    sw  $a2, 44($v0)
+    # save global pointer in context-data
+    sw  $gp, 48($v0)
+
+    # compute address of returned transfer_t
+    addiu $t0, $v0, 52
+    sw  $t0, 36($v0)
+
+    # compute abs address of label finish
+    la  $t9, finish
+    # save address of finish as return-address for context-function
+    # will be entered after context-function returns
+    sw  $t9, 40($v0)
+
+    jr  $ra # return pointer to context-data
+
+finish:
+    lw $gp, 0($sp)
+    # allocate stack space (contains shadow space for subroutines)
+    addiu  $sp, $sp, -32
+    # save return address
+    sw  $ra, 28($sp)
+
+    # restore GP (global pointer)
+#    move  $gp, $s1
+    # exit code is zero
+    move  $a0, $zero
+    # address of exit
+    lw  $t9, %call16(_exit)($gp)
+    # exit application
+    jalr  $t9
+.end make_fcontext
+.size make_fcontext, .-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 87 - 0
modules/std/fiber/native/asm/android-mips64/ontop.S

@@ -0,0 +1,87 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*******************************************************
+ *                                                     *
+ *  -------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
+ *  -------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  *
+ *  -------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  *
+ *  -------------------------------------------------  *
+ *  -------------------------------------------------  *
+ *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
+ *  -------------------------------------------------  *
+ *  |  32 |  36 |  40 |  44 |  48 |  52 |  56 |  60 |  *
+ *  -------------------------------------------------  *
+ *  |  FP |hiddn|  RA |  PC |  GP | FCTX| DATA|     |  *
+ *  -------------------------------------------------  *
+ *                                                     *
+ * *****************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+.ent ontop_fcontext
+ontop_fcontext:
+    # reserve space on stack
+    addiu $sp, $sp, -112
+
+    sw  $s0, ($sp)  # save S0
+    sw  $s1, 4($sp)  # save S1
+    sw  $s2, 8($sp)  # save S2
+    sw  $s3, 12($sp)  # save S3
+    sw  $s4, 16($sp)  # save S4
+    sw  $s5, 20($sp)  # save S5
+    sw  $s6, 24($sp)  # save S6
+    sw  $s7, 28($sp)  # save S7
+    sw  $fp, 32($sp)  # save FP
+    sw  $a0, 36($sp)  # save hidden, address of returned transfer_t
+    sw  $ra, 40($sp)  # save RA
+    sw  $ra, 44($sp)  # save RA as PC
+
+    # store SP (pointing to context-data) in A0
+    move  $a0, $sp
+
+    # restore SP (pointing to context-data) from A1
+    move  $sp, $a1
+
+    lw  $s0, ($sp)  # restore S0
+    lw  $s1, 4($sp)  # restore S1
+    lw  $s2, 8($sp)  # restore S2
+    lw  $s3, 12($sp)  # restore S3
+    lw  $s4, 16($sp)  # restore S4
+    lw  $s5, 20($sp)  # restore S5
+    lw  $s6, 24($sp)  # restore S6
+    lw  $s7, 28($sp)  # restore S7
+    lw  $fp, 32($sp)  # restore FP
+    lw  $t0, 36($sp)  # restore hidden, address of returned transfer_t
+    lw  $ra, 40($sp)  # restore RA
+
+    # load PC
+    lw  $t9, 44($sp)
+
+    # adjust stack
+    addiu $sp, $sp, 112
+    
+    # return transfer_t from jump
+    sw  $a0, ($t0)  # fctx of transfer_t
+    sw  $a2, 4($t0) # data of transfer_t
+    # pass transfer_t as first arg in context function
+    # A0 == hidden, A1 == fctx, A2 == data
+    move  $a1, $a0 
+    move  $a0, $t0 
+
+    # jump to context
+    jr  $a3
+.end ontop_fcontext
+.size ontop_fcontext, .-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 59 - 0
modules/std/fiber/native/asm/android-x86/jump.S

@@ -0,0 +1,59 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+jump_fcontext:
+    pushl  %ebp  /* save EBP */
+    pushl  %ebx  /* save EBX */
+    pushl  %esi  /* save ESI */
+    pushl  %edi  /* save EDI */
+
+    /* store fcontext_t in ECX */
+    movl  %esp, %ecx
+
+    /* first arg of jump_fcontext() == fcontext to jump to */
+    movl  0x18(%esp), %eax
+
+    /* second arg of jump_fcontext() == data to be transferred */
+    movl  0x1c(%esp), %edx
+
+    /* restore ESP (pointing to context-data) from EAX */
+    movl  %eax, %esp
+
+    /* address of returned transport_t */
+    movl 0x14(%esp), %eax
+    /* return parent fcontext_t */
+    movl  %ecx, (%eax)
+    /* return data */
+    movl %edx, 0x4(%eax)
+
+    popl  %edi  /* restore EDI */
+    popl  %esi  /* restore ESI */
+    popl  %ebx  /* restore EBX */
+    popl  %ebp  /* restore EBP */
+
+    /* jump to context */
+    ret $4
+.size jump_fcontext,.-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 94 - 0
modules/std/fiber/native/asm/android-x86/make.S

@@ -0,0 +1,94 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+    /* first arg of make_fcontext() == top of context-stack */
+    movl  0x4(%esp), %eax
+
+    /* reserve space for first argument of context-function
+       rax might already point to a 16byte border */
+    leal  -0x8(%eax), %eax
+
+    /* shift address in EAX to lower 16 byte boundary */
+    andl  $-16, %eax
+
+    /* reserve space for context-data on context-stack */
+    leal  -0x28(%eax), %eax
+
+    /* third arg of make_fcontext() == address of context-function */
+    /* stored in EBX */
+    movl  0xc(%esp), %ecx
+    movl  %ecx, 0x8(%eax)
+
+    /* return transport_t */
+    /* FCTX == EDI, DATA == ESI */
+    leal  (%eax), %ecx
+    movl  %ecx, 0x14(%eax)
+
+    /* compute abs address of label trampoline */
+    call  1f
+    /* address of trampoline 1 */
+1:  popl  %ecx
+    /* compute abs address of label trampoline */
+    addl  $trampoline-1b, %ecx
+    /* save address of trampoline as return address */
+    /* will be entered after calling jump_fcontext() first time */
+    movl  %ecx, 0x10(%eax)
+
+    /* compute abs address of label finish */
+    call  2f
+    /* address of label 2 */
+2:  popl  %ecx
+    /* compute abs address of label finish */
+    addl  $finish-2b, %ecx
+    /* save address of finish as return-address for context-function */
+    /* will be entered after context-function returns */
+    movl  %ecx, 0xc(%eax) 
+
+    ret /* return pointer to context-data */
+
+trampoline:
+    /* move transport_t for entering context-function */
+    movl  %edi, (%esp)
+    movl  %esi, 0x4(%esp)
+    pushl %ebp
+    /* jump to context-function */
+    jmp *%ebx
+
+finish:
+    call  3f
+    /* address of label 3 */
+3:  popl  %ebx
+    /* compute address of GOT and store it in EBX */
+    addl  $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx
+
+    /* exit code is zero */
+    xorl  %eax, %eax
+    movl  %eax, (%esp)
+    /* exit application */
+    call  _exit@PLT
+    hlt
+.size make_fcontext,.-make_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 61 - 0
modules/std/fiber/native/asm/android-x86/ontop.S

@@ -0,0 +1,61 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+          http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/*****************************************************************************************
+ *                                                                                       *
+ *  -----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6     |    7    |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18   |   0x1c  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   EIP    |  hidden |    to    |   data  |  *
+ *  -----------------------------------------------------------------------------------  *
+ *                                                                                       *
+ *****************************************************************************************/
+
+.text
+.globl ontop_fcontext
+.align 2
+.type ontop_fcontext,@function
+ontop_fcontext:
+    pushl  %ebp  /* save EBP */
+    pushl  %ebx  /* save EBX */
+    pushl  %esi  /* save ESI */
+    pushl  %edi  /* save EDI */
+
+    /* store fcontext_t in ECX */
+    movl  %esp, %ecx
+
+    /* first arg of ontop_fcontext() == fcontext to jump to */
+    movl  0x18(%esp), %eax
+
+    /* pass parent fcontext_t */
+    movl  %ecx, 0x18(%eax)
+
+    /* second arg of ontop_fcontext() == data to be transferred */
+    movl  0x1c(%esp), %ecx
+
+    /* pass data */
+    movl %ecx, 0x1c(%eax)
+
+    /* third arg of ontop_fcontext() == ontop-function */
+    movl  0x20(%esp), %ecx
+
+    /* restore ESP (pointing to context-data) from EDX */
+    movl  %eax, %esp
+
+    popl  %edi  /* restore EDI */
+    popl  %esi  /* restore ESI */
+    popl  %ebx  /* restore EBX */
+    popl  %ebp  /* restore EBP */
+
+    /* jump to context */
+    jmp *%ecx
+.size ontop_fcontext,.-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 67 - 0
modules/std/fiber/native/asm/android-x86_64/jump.S

@@ -0,0 +1,67 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl jump_fcontext
+.type jump_fcontext,@function
+.align 16
+jump_fcontext:
+    pushq  %rbp  /* save RBP */
+    pushq  %rbx  /* save RBX */
+    pushq  %r15  /* save R15 */
+    pushq  %r14  /* save R14 */
+    pushq  %r13  /* save R13 */
+    pushq  %r12  /* save R12 */
+
+    /* store RSP (pointing to context-data) in RAX */
+    movq  %rsp, %rax
+
+    /* restore RSP (pointing to context-data) from RDI */
+    movq  %rdi, %rsp
+
+    popq  %r12  /* restrore R12 */
+    popq  %r13  /* restrore R13 */
+    popq  %r14  /* restrore R14 */
+    popq  %r15  /* restrore R15 */
+    popq  %rbx  /* restrore RBX */
+    popq  %rbp  /* restrore RBP */
+
+    /* restore return-address */
+    popq  %r8
+
+    /* return transfer_t from jump */
+    /* RAX == fctx, RDX == data */
+    movq  %rsi, %rdx
+    /* pass transfer_t as first arg in context function */
+    /* RDI == fctx, RSI == data */
+    movq  %rax, %rdi
+
+    /* indirect jump to context */
+    jmp  *%r8
+.size jump_fcontext,.-jump_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 62 - 0
modules/std/fiber/native/asm/android-x86_64/make.S

@@ -0,0 +1,62 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl make_fcontext
+.type make_fcontext,@function
+.align 16
+make_fcontext:
+    /* first arg of make_fcontext() == top of context-stack */
+    movq  %rdi, %rax
+
+    /* shift address in RAX to lower 16 byte boundary */
+    andq  $-16, %rax
+
+    /* reserve space for context-data on context-stack */
+    /* on context-function entry: (RSP -0x8) % 16 == 0 */
+    leaq  -0x40(%rax), %rax
+
+    /* third arg of make_fcontext() == address of context-function */
+    movq  %rdx, 0x30(%rax)
+
+    /* compute abs address of label finish */
+    leaq  finish(%rip), %rcx
+    /* save address of finish as return-address for context-function */
+    /* will be entered after context-function returns */
+    movq  %rcx, 0x38(%rax)
+
+    ret /* return pointer to context-data */
+
+finish:
+    /* exit code is zero */
+    xorq  %rdi, %rdi
+    /* exit application */
+    call  _exit@PLT
+    hlt
+.size make_fcontext,.-make_fcontext
+
+/* Mark that we don't need executable stack. */
+.section .note.GNU-stack,"",%progbits

+ 69 - 0
modules/std/fiber/native/asm/android-x86_64/ontop.S

@@ -0,0 +1,69 @@
+/*
+            Copyright Oliver Kowalke 2009.
+   Distributed under the Boost Software License, Version 1.0.
+      (See accompanying file LICENSE_1_0.txt or copy at
+            http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R12        |         R13       |         R14        |        R15        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |         RBP       |         RIP        |       EXIT        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ ****************************************************************************************/
+
+.text
+.globl ontop_fcontext
+.type ontop_fcontext,@function
+.align 16
+ontop_fcontext:
+    pushq  %rbp  /* save RBP */
+    pushq  %rbx  /* save RBX */
+    pushq  %r15  /* save R15 */
+    pushq  %r14  /* save R14 */
+    pushq  %r13  /* save R13 */
+    pushq  %r12  /* save R12 */
+
+    /* store RSP (pointing to context-data) in RAX */
+    movq  %rsp, %rax
+
+    /* restore RSP (pointing to context-data) from RDI */
+    movq  %rdi, %rsp
+
+    popq  %r12  /* restrore R12 */
+    popq  %r13  /* restrore R13 */
+    popq  %r14  /* restrore R14 */
+    popq  %r15  /* restrore R15 */
+    popq  %rbx  /* restrore RBX */
+    popq  %rbp  /* restrore RBP */
+
+    /* preserve ontop-function in R8 */
+    movq  %rdx, %r8
+
+    /* return transfer_t from jump */
+    /* RAX == fctx, RDX == data */
+    movq  %rsi, %rdx
+    /* pass transfer_t as first arg in context function */
+    /* RDI == fctx, RSI == data */
+    movq  %rax, %rdi
+
+    /* keep return-address on stack */
+
+    /* indirect jump to context */
+    jmp  *%r8
+.size ontop_fcontext,.-ontop_fcontext
+
+/* Mark that we don't need executable stack.  */
+.section .note.GNU-stack,"",%progbits

+ 2 - 2
modules/std/socket/native/socket.cpp

@@ -430,7 +430,7 @@ namespace bbSocket{
 		
 		if( name=="TCP_NODELAY" ){
 			setsockopt( socket,IPPROTO_TCP,TCP_NODELAY,ip,sz );
-		}else if( name="SO_REUSEADDR" ){
+		}else if( name=="SO_REUSEADDR" ){
 			setsockopt( socket,SOL_SOCKET,SO_REUSEADDR,ip,sz );
 		}else if( name=="SO_SNDTIMEO" ){
 			setsockopt( socket,SOL_SOCKET,SO_SNDTIMEO,ip,sz );
@@ -448,7 +448,7 @@ namespace bbSocket{
 		
 		if( name=="TCP_NODELAY" ){
 			getsockopt( socket,IPPROTO_TCP,TCP_NODELAY,ip,(socklen_t*)&sz );
-		}else if( name="SO_REUSEADDR" ){
+		}else if( name=="SO_REUSEADDR" ){
 			getsockopt( socket,SOL_SOCKET,SO_REUSEADDR,ip,(socklen_t*)&sz );
 		}else if( name=="SO_SNDTIMEO" ){
 			getsockopt( socket,SOL_SOCKET,SO_SNDTIMEO,ip,(socklen_t*)&sz );

+ 1 - 1
modules/theoraplayer/makefile.monkey2

@@ -140,7 +140,7 @@ Namespace theoraplayer
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale.cc"
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale_any.cc"
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale_argb.cc"
-#Import "native/theoraplayer/src/YUV/libyuv/src/scale_argb_neon.cc"
+'#Import "native/theoraplayer/src/YUV/libyuv/src/scale_argb_neon.cc"	'problem on ios arm64...
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale_common.cc"
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale_gcc.cc"
 #Import "native/theoraplayer/src/YUV/libyuv/src/scale_mips.cc"

+ 18 - 28
products/android/Monkey2Game/app/src/main/Monkey2Game.java

@@ -1,29 +1,19 @@
-
-package ${PACKAGE_NAME};
-
-import org.libsdl.app.SDLActivity;
-
-import android.os.*;
-import android.util.*;
-import android.content.res.Configuration;
-
-import java.io.*;
-import java.nio.*;
-import java.net.*;
-import java.util.*;
-import java.text.*;
-import java.lang.reflect.*;
-
-/*
- * A sample wrapper class that just calls SDLActivity
- */
-public class ${ACTIVITY_NAME} extends SDLActivity {
-
-    protected void onCreate(Bundle savedInstanceState){
-        super.onCreate( savedInstanceState );
-    }
-
-    protected void onDestroy(){
-        super.onDestroy();
-    }
+
+package ${PACKAGE_NAME};
+
+import android.os.Bundle;
+
+import com.monkey2.lib.Monkey2Activity;
+
+public class ${ACTIVITY_NAME} extends Monkey2Activity{
+
+    protected void onCreate(Bundle savedInstanceState){
+
+        super.onCreate( savedInstanceState );
+    }
+
+    protected void onDestroy(){
+
+        super.onDestroy();
+    }
 }

+ 37 - 0
products/android/Monkey2Game/app/src/main/java/com/monkey2/lib/Monkey2Activity.java

@@ -0,0 +1,37 @@
+package com.monkey2.lib;
+
+import android.os.Bundle;
+import android.os.Looper;
+import android.util.Log;
+import android.view.ViewGroup;
+
+import org.libsdl.app.SDLActivity;
+
+public class Monkey2Activity extends SDLActivity {
+    private static final String TAG = "Monkey2Activity";
+
+    public static Monkey2Activity mSingleton;
+
+    protected void onCreate(Bundle savedInstanceState) {
+
+        super.onCreate(savedInstanceState);
+
+        mSingleton = this;
+    }
+
+    protected void onDestroy() {
+
+        super.onDestroy();
+    }
+
+    static public Monkey2Activity instance(){
+
+        return mSingleton;
+    }
+
+    static public ViewGroup layout() {
+
+        return mSingleton.mLayout;
+    }
+
+}

+ 5 - 5
scripts/common.bat

@@ -1,11 +1,11 @@
 
 set mx2cc=..\bin\mx2cc_windows.exe
-set mx2cc_new=..\src\mx2cc\mx2cc.buildv1.1.02\windows_release\mx2cc.exe
-set mx2cc_raspbian_new=..\src\mx2cc\mx2cc.buildv1.1.02\raspbian_release\mx2cc
+set mx2cc_new=..\src\mx2cc\mx2cc.buildv1.1.03\windows_release\mx2cc.exe
+set mx2cc_raspbian_new=..\src\mx2cc\mx2cc.buildv1.1.03\raspbian_release\mx2cc
 
 set ted2=..\bin\ted2_windows
-set ted2_new=..\src\ted2\ted2.buildv1.1.02\windows_release
-set ted2go_new=..\src\ted2go\ted2.buildv1.1.02\windows_release
+set ted2_new=..\src\ted2\ted2.buildv1.1.03\windows_release
+set ted2go_new=..\src\ted2go\ted2.buildv1.1.03\windows_release
 
 set launcher="..\Monkey2 (Windows).exe"
-set launcher_new=..\src\launcher\launcher.buildv1.1.02\windows_release\launcher.exe
+set launcher_new=..\src\launcher\launcher.buildv1.1.03\windows_release\launcher.exe

+ 8 - 8
scripts/common.sh

@@ -9,14 +9,14 @@ launcher_new=""
 if [ "$OSTYPE" = "linux-gnu" ]
 then
 	mx2cc="../bin/mx2cc_linux"
-	mx2cc_new="../src/mx2cc/mx2cc.buildv1.1.02/linux_release/mx2cc"
+	mx2cc_new="../src/mx2cc/mx2cc.buildv1.1.03/linux_release/mx2cc"
 	
 	ted2="../bin/ted2_linux"
-	ted2_new="../src/ted2/ted2.buildv1.1.02/linux_release"
-	ted2go_new="../src/ted2go/ted2.buildv1.1.02/linux_release"
+	ted2_new="../src/ted2/ted2.buildv1.1.03/linux_release"
+	ted2go_new="../src/ted2go/ted2.buildv1.1.03/linux_release"
 	
 	launcher="../Monkey2 (Linux)"
-	launcher_new="../src/launcher/launcher.buildv1.1.02/linux_release/launcher"
+	launcher_new="../src/launcher/launcher.buildv1.1.03/linux_release/launcher"
 	
 elif [ "$OSTYPE" = "linux-gnueabihf" ]
 then
@@ -31,12 +31,12 @@ then
 	launcher_new="../src/launcher/launcher.buildv1.1.02/raspbian_release/launcher"
 else
 	mx2cc="../bin/mx2cc_macos"
-	mx2cc_new="../src/mx2cc/mx2cc.buildv1.1.02/macos_release/mx2cc"
+	mx2cc_new="../src/mx2cc/mx2cc.buildv1.1.03/macos_release/mx2cc"
 	
 	ted2="../bin/ted2_macos.app"
-	ted2_new="../src/ted2/ted2.buildv1.1.02/macos_release/ted2.app"
-	ted2go_new="../src/ted2go/ted2.buildv1.1.02/macos_release/ted2.app"
+	ted2_new="../src/ted2/ted2.buildv1.1.03/macos_release/ted2.app"
+	ted2go_new="../src/ted2go/ted2.buildv1.1.03/macos_release/ted2.app"
 	
 	launcher="../Monkey2 (Macos).app"
-	launcher_new="../src/launcher/launcher.buildv1.1.02/macos_release/launcher.app"
+	launcher_new="../src/launcher/launcher.buildv1.1.03/macos_release/launcher.app"
 fi

+ 452 - 0
src/c2mx2/cxxtomx2.monkey2

@@ -0,0 +1,452 @@
+
+#Import "<libc>"
+#Import "<std>"
+
+#Import "libclang_extern.monkey2"
+
+Using libc..
+Using std..
+
+Using libclang..
+
+Global tab:String
+Global buf:=New StringStack
+
+Global enumType:=""
+Global superType:=""
+Global paramDecls:=New Stack<CXCursor>
+
+Global LongType:="Long"
+Global ULongType:="ULong"
+Global LongLongType:="Long"
+Global ULongLongType:="ULong"
+
+Struct CXString Extension
+	Method To:String()
+		Return ToString( Self )
+	End
+End
+
+Function ToString:String( str:CXString )
+	Local cstr:=clang_getCString( str )
+	clang_disposeString( str )
+	Return cstr
+End
+
+Function ToCString:const_char_t Ptr( str:String )
+	Local n:=str.Length+1
+	Local buf:=Cast<Byte Ptr>( malloc( n ) )
+	str.ToCString( buf,n )
+	Return Cast<const_char_t Ptr>( buf )
+End
+
+Function Emit( str:String )
+	If str.StartsWith( "}" ) tab=tab.Slice( 0,-1 ) ; str=str.Slice( 1 )
+	If str.EndsWith( "{" )
+		buf.Push( tab+str.Slice( 0,-1 ) )
+		tab+="~t"
+	Else
+		buf.Push( tab+str )
+	Endif
+End
+
+Function Err( cursor:CXCursor )
+
+	Local srcloc:=clang_getCursorLocation( cursor )
+	
+	Local err:="Error translating '"+String( clang_getCursorDisplayName( cursor ) )+"' : cursor.kind="+Int(cursor.kind)
+	
+	Emit( "'"+err )
+End
+
+Function TransType:String( type:CXType )
+
+	If clang_isConstQualifiedType( type ) Return ""
+	
+	Select type.kind
+	
+	Case CXType_Void Return "Void"
+	
+	Case CXType_SChar Return "Byte"
+	
+	Case CXType_UChar Return "UByte"
+	
+	Case CXType_Bool Return "Bool"
+	
+	Case CXType_Short Return "Short"
+	
+	Case CXType_UShort Return "UShort"
+	
+	Case CXType_Int Return "Int"
+	
+	Case CXType_UInt Return "UInt"
+	
+	Case CXType_Float Return "Float"
+	
+	Case CXType_Double Return "Double"
+	
+	Case CXType_Long Return LongType
+	
+	Case CXType_ULong Return ULongType
+	
+	Case CXType_LongLong Return LongLongType
+	
+	Case CXType_ULongLong Return ULongLongType
+	
+	Case CXType_Pointer 
+	
+		Local ptype:=TransType( clang_getPointeeType( type ) )
+		If ptype Return ptype+" Ptr"
+		
+	Case CXType_ConstantArray
+	
+		Local ptype:=TransType( clang_getElementType( type ) )
+		If ptype Return ptype+" Ptr"
+	
+	Case CXType_IncompleteArray 
+
+		Local ptype:=TransType( clang_getElementType( type ) )
+		If ptype Return ptype+" Ptr"
+	
+	Case CXType_Record
+	
+		Return clang_getTypeSpelling( type )
+		
+	Case CXType_Elaborated
+	
+		Return TransType( clang_Type_getNamedType( type ) )
+
+	Case CXType_Typedef
+	
+		Return clang_getTypeSpelling( type )
+		
+	End
+	
+	Return "Bad("+Int(type.kind)+")"
+End
+
+Function TransType:String( cursor:CXCursor )
+
+	Return TransType( clang_getCursorType( cursor ) )
+End
+
+Function TransIdent:String( cursor:CXCursor )
+
+	Local id:=String( clang_getCursorSpelling( cursor ) )
+	
+	Return id
+
+End
+
+Function EmitTypedefDecl:Bool( cursor:CXCursor )
+
+	If cursor.kind<>CXCursor_TypedefDecl Return False
+	
+	Local id:=TransIdent( cursor )
+	If Not id Return False
+	
+	Local type:=TransType( clang_getTypedefDeclUnderlyingType( cursor ) )
+	If Not type Return False
+	
+	If id=type Return True
+	
+	Emit( "Alias "+id+":"+type )
+	
+	Return True
+End
+
+Function EmitEnumDecl:Bool( cursor:CXCursor )
+
+	If cursor.kind<>CXCursor_EnumDecl Return False
+	
+	Local id:=TransIdent( cursor )
+	If Not id Return False
+	
+	Emit( "Enum "+id )
+	Emit( "End" )
+	
+	enumType=id
+	clang_visitChildren( cursor,VisitEnumDecl,Null )
+
+	Return True	
+End
+
+Function EmitTypeDecl:Bool( cursor:CXCursor )
+
+	Local kind:=""
+	Select cursor.kind
+	Case CXCursor_ClassDecl
+		kind="Class"
+	Case CXCursor_StructDecl,CXCursor_UnionDecl
+		kind="Struct"
+	Default
+		Return False
+	End
+
+	Local id:=TransIdent( cursor )
+	If Not id Return False
+	
+	If Not clang_isCursorDefinition( cursor ) Return True
+
+	Local pos:=buf.Length
+	Emit( kind+" "+id+"{" )
+	
+	superType=""
+	clang_visitChildren( cursor,VisitTypeDecl,Null )
+	
+	If kind="Class"
+		If superType
+			buf[pos]+=" Extends "+superType
+		Else
+			buf[pos]+=" Extends Void"
+		End
+	Endif
+	
+	Emit( "}End" )
+	
+	Return True
+End
+
+Function EmitFuncDecl:Bool( cursor:CXCursor )
+
+	Local kind:="",id:=""
+	Select cursor.kind
+	Case CXCursor_FunctionDecl
+		kind="Function"
+	Case CXCursor_CXXMethod
+		kind="Method"
+	Case CXCursor_Constructor
+		kind="Method"
+		id="New"
+	Default
+		Return False
+	End
+
+	If Not id 
+		id=TransIdent( cursor )
+		If Not id Return False
+	Endif
+	
+	Local ftype:=clang_getCursorType( cursor )
+	
+	Local retType:=TransType( clang_getResultType( ftype ) )
+	If Not retType Return False
+	
+	paramDecls.Clear()
+	clang_visitChildren( cursor,VisitFuncDecl,Null )
+	
+	Local argTypes:=New Stack<String>
+	
+	For Local param:=Eachin paramDecls
+	
+		Local id:=TransIdent( param )
+		If Not id Return False
+	
+		Local type:=TransType( param )
+		If Not type Return False
+		
+		argTypes.Push( id+":"+type )
+	Next
+	
+	local mods:=""
+	If kind="Method" And clang_CXXMethod_isVirtual( cursor ) mods=" Virtual"
+	
+	Emit( kind+" "+id+":"+retType+"("+argTypes.Join( "," )+")"+mods )
+	
+	Return True
+End
+
+Function EmitVarDecl:Bool( cursor:CXCursor )
+
+	Local kind:=""
+	Select cursor.kind
+	Case CXCursor_VarDecl
+		kind=clang_isConstQualifiedType( clang_getCursorType( cursor ) ) ? "Const" Else "Global"
+	Case CXCursor_FieldDecl
+		kind="Field"
+	Default
+		Return False
+	End
+
+	Local id:=TransIdent( cursor )
+	If Not id Return False
+		
+	Local type:=TransType( cursor )
+	If Not type Return False
+	
+	Emit( kind+" "+id+":"+type )
+	
+	Return True
+End
+
+Function VisitEnumDecl:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+
+	Select cursor.kind
+	
+	Case CXCursor_EnumConstantDecl
+	
+		Emit( "Const "+TransIdent( cursor )+":"+enumType )
+	
+	Default
+	
+		Err( cursor )
+	End
+	
+	Return CXChildVisit_Continue
+End
+
+Function VisitTypeDecl:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+	
+	If clang_getCXXAccessSpecifier( cursor )=CX_CXXPrivate Return CXChildVisit_Continue
+
+	Select cursor.kind
+	
+	Case CXCursor_CXXBaseSpecifier
+	
+		superType=TransType( cursor )
+	
+	Case CXCursor_FieldDecl
+	
+		If Not EmitVarDecl( cursor ) Err( cursor )
+		
+	Case CXCursor_CXXMethod,CXCursor_Constructor
+	
+		If Not EmitFuncDecl( cursor ) Err( cursor )
+		
+	Case CXCursor_CXXAccessSpecifier
+	
+	Default
+	
+		Err( cursor )
+	End
+	
+	Return CXChildVisit_Continue
+End
+
+Function VisitFuncDecl:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+
+	Select cursor.kind
+
+	Case CXCursor_ParmDecl
+	
+		paramDecls.Push( cursor )
+	
+	Default
+	
+		Err( cursor )
+	End
+	
+	Return CXChildVisit_Continue
+End
+
+Function VisitTransUnit:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+
+	Local srcloc:=clang_getCursorLocation( cursor )
+	If clang_Location_isInSystemHeader( srcloc ) Return CXChildVisit_Continue
+
+	Select cursor.kind
+	
+	Case CXCursor_TypedefDecl
+	
+		If Not EmitTypedefDecl( cursor ) Err( cursor )
+		
+	Case CXCursor_EnumDecl
+	
+		If Not EmitEnumDecl( cursor ) Err( cursor )
+	
+	Case CXCursor_StructDecl,CXCursor_ClassDecl
+	
+		If Not EmitTypeDecl( cursor ) Err( cursor )
+		
+	Case CXCursor_FunctionDecl
+	
+		If Not EmitFuncDecl( cursor ) Err( cursor )
+
+	Case CXCursor_VarDecl
+	
+		If Not EmitVarDecl( cursor ) Err( cursor )
+		
+	Default
+	
+		Err( cursor )
+	
+	End
+	
+	Return CXChildVisit_Continue
+
+End
+
+Function VisitDebug:CXChildVisitResult( cursor:CXCursor,parent:CXCursor,client_data:CXClientData )
+
+	Local ctype:=clang_getCursorType( cursor )
+
+	Print tab+clang_getCursorSpelling( cursor )+":"+clang_getTypeSpelling( ctype )+", cursor kind="+Int( cursor.kind )+", type kind="+Int( ctype.kind )
+	
+	tab+="~t"
+	clang_visitChildren( cursor,VisitDebug,Null )
+	tab=tab.Slice( 0,-1 )
+
+	Return CXChildVisit_Continue
+End
+
+Function Main()
+
+	Local path:=RequestFile( "Select c2mx2.json file...","Json files:json" )
+	If Not path Return
+	
+	Local config:=JsonObject.Load( path )
+	If Not config
+		Print "C2mx2: Failed to load JSON object from "+path
+		Return
+	Endif
+
+	If Not config.Contains( "clangArgs" )
+		Print "C2mx2: No clangArgs specified"
+		Return
+	Endif
+	
+	If Not config.Contains( "inputFile" )
+		Print "C2mx2: No inputFile specified"
+		Return
+	Endif
+	
+	If Not config.Contains( "outputFile" )
+		Print "C2mx2: No outputFile specified"
+		Return
+	Endif
+
+	'change to working dir
+	ChangeDir( ExtractDir( path ) )
+	
+	If config.Contains( "workingDir" ) 
+		ChangeDir( config.GetString( "workingDir" ) )
+	Endif
+	
+	'clang args
+	Local cargs:=config.GetArray( "clangArgs" )
+	Local args:=New const_char_t Ptr[cargs.Length]
+	For Local i:=0 Until args.Length
+		args[i]=ToCString( cargs[i].ToString() )
+	Next
+	
+	'input file
+	Local inputFile:=config.GetString( "inputFile" )
+	
+	'outfile file
+	Local outputFile:=config.GetString( "outputFile" )
+
+	'start clang	
+	Local clangIndex:=clang_createIndex( 1,1 )
+	
+	'create trans unit
+	Local transUnit:=clang_createTranslationUnitFromSourceFile( clangIndex,inputFile,args.Length,args.Data,0,Null )
+	Assert( transUnit,"Failed to create translation unit from source file" )
+	
+	Local cursor:=clang_getTranslationUnitCursor( transUnit )
+	
+	clang_visitChildren( cursor,VisitTransUnit,Null )
+'	clang_visitChildren( cursor,VisitDebug,Null )
+	
+	Print buf.Join( "~n" )
+
+End

+ 26 - 3
src/c2mx2/test.h

@@ -1,10 +1,21 @@
 
+class C;
+
 struct S{
+	int x,y,z;
 };
 
 typedef S MS;
 
-void update( S &s );
+typedef int Myint;
+
+enum E{
+	x,y,z;
+};
+
+void Update( float f );
+
+void Update( float *p );
 
 void update2( const S *s );
 
@@ -13,11 +24,23 @@ void update3( const MS *s );
 class C{
 	public:
 	
+	C();
+	
+	C( int x );
+	
 	int x,y,z;
 	
-	void update( S &s );
+	virtual void update( float t );
+
+	void render();
+};
+
+class D : public C{
+	public:
+	
+	int d,e,f;
 	
-	const S &render();
+	virtual void update( float t );
 };
 
 float A,B,C;

+ 2 - 9
src/c2mx2/test.json

@@ -7,13 +7,6 @@
 	
 	"inputFile":"test.h",
 	
-	"outputDir":"test_api",
-	
-	"outputFile":"test",
-	
-	"header":[
-		"",
-		"Extern",
-		""
-	]
+	"outputFile":"test_extern"
+
 }

+ 9 - 9
src/mx2cc/builder.monkey2

@@ -17,10 +17,6 @@ Class BuildOpts
 	
 	Field product:String
 
-	Field assets:String
-
-	Field dlls:String
-
 	Field appType:String
 	
 	Field verbose:Int
@@ -529,7 +525,7 @@ Class BuilderInstance
 		Type.StringType=New PrimType( TCast<ClassType>( types.nodes["@string"] ) )
 		Type.VariantType=New PrimType( TCast<ClassType>( types.nodes["@variant"] ) )
 		
-		Type.ArrayClass=TCast<ClassType>( types.nodes["@Array"] )
+		Type.ArrayClass=TCast<ClassType>( types.nodes["@array"] )
 		Type.ObjectClass=TCast<ClassType>( types.nodes["@object"] )
 		Type.ThrowableClass=TCast<ClassType>( types.nodes["@throwable"] )
 
@@ -690,7 +686,7 @@ Class BuilderInstance
 		Endif
 		
 		Local qpath:="~q"+path+"~q"
-
+		
 		Select ext
 		Case ".framework"
 			
@@ -700,7 +696,6 @@ Class BuilderInstance
 			Endif
 			
 		Default
-		
 			Select GetFileType( path )
 			Case FileType.Directory
 			
@@ -709,8 +704,8 @@ Class BuilderInstance
 				
 			Case FileType.None
 			
-				New BuildEx( "File "+qpath+" not found" )
-				Return
+'				New BuildEx( "File "+qpath+" not found" )
+'				Return
 				
 			End
 		End
@@ -731,6 +726,11 @@ Class BuilderInstance
 '			If modules.Length=1
 '				SRC_FILES.Push( path )
 '			Endif
+
+		Case ".java"
+		
+'			If parsingModule=mainModule product.JAVA_FILES.Push( path )
+			product.JAVA_FILES.Push( path )
 			
 		Case ".o"
 		

+ 85 - 29
src/mx2cc/buildproduct.monkey2

@@ -17,6 +17,7 @@ Class BuildProduct
 	Field OBJ_FILES:=New StringStack
 	Field LD_SYSLIBS:=New StringStack
 	Field ASSET_FILES:=New StringStack
+	Field JAVA_FILES:=New StringStack
 	Field DLL_FILES:=New StringStack
 	
 	Method New( module:Module,opts:BuildOpts )
@@ -304,7 +305,6 @@ Class GccBuildProduct Extends BuildProduct
 			CXX_CMD="g++"+suffix
 			LD_CMD= "g++"+suffix
 			AS_CMD= "as"
-			If opts.target="ios" AS_CMD+=" -arch armv7"
 		End
 		
 	End
@@ -334,6 +334,14 @@ Class GccBuildProduct Extends BuildProduct
 		
 			cmd=AS_CMD+AS_OPTS
 			
+			If opts.target="ios"
+				If src.Contains( "_arm64_" )
+					cmd+=" -arch arm64"
+				Else
+					cmd+=" -arch armv7"
+				Endif
+			Endif
+			
 			isasm=True
 		End
 			
@@ -355,7 +363,21 @@ Class GccBuildProduct Extends BuildProduct
 					
 				If opts.verbose>0 Print "Scanning "+src
 				
-				Exec( cmd+" -MM ~q"+src+"~q >~q"+deps+"~q" ) 
+				Local tmp:=cmd
+				
+				'A bit dodgy - rip out -arch's from ios
+				If opts.target="ios"
+					Repeat
+						Local i0:=tmp.Find( " -arch "  )
+						If i0=-1 Exit
+						Local i1:=tmp.Find( " ",i0+7 )
+						If i1=-1 Exit
+						tmp=tmp.Slice( 0,i0+1 )+tmp.Slice( i1+1 )
+					Forever
+					tmp+=" -arch armv7"
+				Endif					
+				
+				Exec( tmp+" -MM ~q"+src+"~q >~q"+deps+"~q" ) 
 			Endif
 					
 			Local srcs:=LoadString( deps ).Split( " \" )
@@ -423,21 +445,38 @@ Class GccBuildProduct Extends BuildProduct
 		
 		DeleteFile( output )
 		
-		Local args:=""
-
-		For Local i:=0 Until objs.Length
-			
-			args+=" ~q"+objs.Get( i )+"~q"
+		If opts.target="ios"
+		
+			Local args:=""
+	
+			For Local i:=0 Until objs.Length
+				args+=" ~q"+objs.Get( i )+"~q"
+			Next
 			
-			If args.Length<1000 And i<objs.Length-1 Continue
-
-			Local cmd:=AR_CMD+" q ~q"+output+"~q"+args
+			Local cmd:="libtool -o ~q"+output+"~q"+args
 
 			Exec( cmd )
+		
+		Else
+		
+			Local args:=""
+	
+			For Local i:=0 Until objs.Length
+				
+				args+=" ~q"+objs.Get( i )+"~q"
 			
-			args=""
+				If args.Length<1000 And i<objs.Length-1 Continue
+				
+				Local cmd:=AR_CMD+" q ~q"+output+"~q"+args
+
+				Exec( cmd )
+				
+				args=""
 			
-		Next
+			Next
+		
+		Endif
+		
 	End
 	
 	Method BuildApp( objs:StringStack ) Virtual
@@ -661,13 +700,8 @@ Class AndroidBuildProduct Extends BuildProduct
 		
 		buf.Push( "APP_OPTIM := "+opts.config )
 		
-		buf.Push( "APP_ABI := armeabi-v7a" )
-'		buf.Push( "APP_ABI := armeabi armeabi-v7a x86" )
-'		buf.Push( "APP_ABI := armeabi-v7a x86" )
-'		buf.Push( "APP_ABI := all" )
-
-		buf.Push( "APP_PLATFORM := 10" )
-		
+		buf.Push( "APP_ABI := "+GetEnv( "MX2_ANDROID_APP_ABI","armeabi-v7a" ) )
+		buf.Push( "APP_PLATFORM := "+GetEnv( "MX2_ANDROID_APP_PLATFORM","10" ) )
 		buf.Push( "APP_CFLAGS += -std=gnu99" )
 		buf.Push( "APP_CPPFLAGS += -std=c++11" )
 		buf.Push( "APP_CPPFLAGS += -frtti" )
@@ -730,13 +764,19 @@ Class AndroidBuildProduct Extends BuildProduct
 		If opts.productType="app"
 		
 			buf.Push( "LOCAL_STATIC_LIBRARIES := \" )
-			For Local imp:=Eachin imports	'Builder.modules.Backwards()
+			For Local imp:=Eachin imports
 				If imp=module Continue
 				
+				If imp.name="sdl2" Or imp.name="admob" Continue
+				
 				buf.Push( "mx2_"+imp.name+" \" )
 			Next
 			buf.Push( "" )
 			
+			'This keeps the JNI functions in sdl2 and admob alive: ugly, ugly stuff but that's the joys of modern coding for ya...
+			'
+			buf.Push( "LOCAL_WHOLE_STATIC_LIBRARIES := mx2_sdl2 mx2_admob" )
+
 			buf.Push( "LOCAL_SHARED_LIBRARIES := \" )
 			For Local dll:=Eachin DLL_FILES
 				buf.Push( StripDir( dll )+" \" )
@@ -751,11 +791,6 @@ Class AndroidBuildProduct Extends BuildProduct
 			
 			buf.Push( "LOCAL_LDLIBS += -llog -landroid" )
 
-			'This keeps the JNI functions in sdl2 alive, or it gets optimized out of the build as its unused...alas, probably keeps
-			'entire static lib alive...
-			'
-			buf.Push( "LOCAL_WHOLE_STATIC_LIBRARIES := mx2_sdl2" )
-
 			buf.Push( "include $(BUILD_SHARED_LIBRARY)" )
 		Else
 
@@ -773,11 +808,32 @@ Class AndroidBuildProduct Extends BuildProduct
 		
 		ChangeDir( cd )
 		
-		If opts.productType="app" And opts.assets And opts.dlls
+		If opts.productType="app" And opts.product
 		
-			CopyDir( module.outputDir+"libs",opts.dlls )
-
-			CopyAssets( opts.assets )
+			For Local jfile:=Eachin JAVA_FILES
+			
+				Local src:=LoadString( jfile )
+				If Not src Continue
+				
+				Local i0:=src.Find( "package " )
+				If i0=-1 Continue
+				
+				Local i1:=src.Find( ";",i0+8 )
+				If i1=-1 Continue
+				
+				Local pkg:=src.Slice( i0+8,i1 ).Trim()
+				If Not pkg Continue
+				
+				Local dstDir:=opts.product+"app/src/main/java/"+pkg.Replace( ".","/" )
+				
+				CreateDir( dstDir,True )
+				
+				CopyFile( jfile,dstDir+"/"+StripDir( jfile ) )
+			Next
+		
+			CopyAssets( opts.product+"app/src/main/assets/" )
+		
+			CopyDir( module.outputDir+"libs",opts.product+"app/src/main/jniLibs" )
 		
 		Endif
 		

+ 78 - 39
src/mx2cc/docs/docsmaker.monkey2

@@ -11,8 +11,10 @@ Class DocsMaker
 	
 		_nav=New JsonBuffer
 	
-		_md=New MarkdownBuffer( "",Lambda:String( link:String )
-			Return ResolveLink( link,_linkScope )
+		_md=New MarkdownBuffer( "",Lambda:String( link:String,name:String )
+		
+			Return ResolveLink( link,name,_linkScope )
+			
 		End )
 	End
 	
@@ -24,19 +26,19 @@ Class DocsMaker
 		DeleteDir( module.baseDir+"docs/__MANPAGES__",True )
 		CreateDir( module.baseDir+"docs/__MANPAGES__" )
 		
-		Local pages:=ManPage.MakeManPages( path,module,Lambda:String( link:String )
-			Return ResolveLink( link,_linkScope )
-		End )
+		Local pages:=ManPage.MakeManPages( path,module,Lambda:String( link:String,name:String )
 		
-'		Local pages:=ManPage.MakeManPages( path,module.baseDir,Lambda:String( link:String )
-'			Return ResolveLink( link,_linkScope )
-'		End )
+			Return ResolveLink( link,name,_linkScope )
+			
+		End )
 		
 		For Local it:=Eachin pages
 		
 			Local path:=it.Key		'source path
 			Local page:=it.Value	'ManPage
 			
+			Print "Making manual page:"+path
+			
 			Local dir:=ExtractDir( path ),cd:=".."
 			While dir<>module.baseDir+"docs/" And Not IsRootDir( dir )
 				dir=ExtractDir( dir )
@@ -70,6 +72,8 @@ Class DocsMaker
 		Local md:=stringio.LoadString( mdocs )
 		If Not md Return ""
 		
+		Print "Making module docs:"+mdocs
+		
 		_md.Emit( md )
 		
 		Local docs:=_md.Flush()
@@ -99,7 +103,7 @@ Class DocsMaker
 		Local nmspaceDocs:=New StringMap<String>
 		
 		For Local fscope:=Eachin _module.fileScopes
-		
+			
 			Local nmspace:=Cast<NamespaceScope>( fscope.outer )
 			If Not nmspace Continue
 			
@@ -116,6 +120,9 @@ Class DocsMaker
 		BeginNode( _module.name,page )
 		
 		For Local nmspace:=Eachin nmspaces.Values
+
+			Print "Making namespace docs:"+nmspace.Name
+		
 			EmitNamespace( nmspace,nmspaceDocs[nmspace.Name] )
 		Next
 		
@@ -202,55 +209,68 @@ Class DocsMaker
 		Return "<a href=~qjavascript:void('"+slug+"')~q onclick=~qopenDocsPage('"+slug+"')~q>"+text+"</a>"
 	End
 
-	Method ResolveLink:String( path:String,scope:Scope )
+	Method FixKeyword:String( ident:String )
 	
-		Local i0:=0
+		If KeyWords.Contains( ident.ToLower() ) Return "@"+ident.ToLower()
 		
+		Return ident
+	End
+	
+	Method ResolveLink:String( path:String,name:String,scope:Scope )
+		
+		If Not name name=path
+		
+		If path.StartsWith( "http:" ) Or path.StartsWith( "https:" ) Return "<a href='"+path+"'>"+name+"</a>"
+	
+'		Print "ResolveLink( path="+path+", name="+name+" )"
+	
+		Local i0:=0
 		Local tpath:=""
 		
 		Repeat
 		
 			Local i1:=path.Find( ".",i0 )
+			
 			If i1=-1
 			
-				If Not scope Return ""
+				If Not scope Return name
 
 				Local id:=path.Slice( i0 )
 				
-				Local node:=scope.FindNode( id )
-				If Not node
-					Return path
-				Endif
+				Local node:=scope.FindNode( FixKeyword( id ) )
+				If Not node Return name
 				
 				tpath+=id
 				
+				If Not name name=tpath
+				
 				Local vvar:=Cast<VarValue>( node )
-				If vvar Return MakeLink( tpath,vvar.vdecl,vvar.scope )
+				If vvar Return MakeLink( name,vvar.vdecl,vvar.scope )
 				
 				Local flist:=Cast<FuncList>( node )
-				If flist Return MakeLink( tpath,flist.funcs[0].fdecl,flist.funcs[0].scope )
+				If flist Return MakeLink( name,flist.funcs[0].fdecl,flist.funcs[0].scope )
 				
 				Local etype:=TCast<EnumType>( node )
-				If etype Return MakeLink( tpath,etype.edecl,etype.scope.outer )
+				If etype Return MakeLink( name,etype.edecl,etype.scope.outer )
 				
 				Local ntype:=TCast<NamespaceType>( node )
-				If ntype Return MakeLink( tpath,ntype.scope )
+				If ntype Return MakeLink( name,ntype.scope )
 				
 				Local ctype:=TCast<ClassType>( node )
-				If ctype Return MakeLink( tpath,ctype.cdecl,ctype.scope.outer )
+				If ctype Return MakeLink( name,ctype.cdecl,ctype.scope.outer )
 				
-				Return ""
+				Print "Can't resolve link:"+path+", id="+id
+				Return name
 			Endif
 			
 			Local id:=path.Slice( i0,i1 )
 			i0=i1+1
-			
+
 			Local type:Type
 			If scope
 				Try
-					type=scope.FindType( id )
+					type=scope.FindType( FixKeyword( id ) )
 				Catch ex:SemantEx
-					Print "Exception!"
 				End
 			Else If Not tpath
 				For Local fscope:=Eachin _module.fileScopes
@@ -258,14 +278,31 @@ Class DocsMaker
 					type=fscope.nmspace.ntype
 					Exit
 				Next
+				If Not type type=Builder.monkeyNamespace.FindType( FixKeyword( id ) )
 			Endif
 
+			tpath+=id+"."
+			
 			If Not type 
-				Return path
+				If scope
+					Try
+						Local node:=scope.FindNode( FixKeyword( id ) )
+						
+						Local vvar:=Cast<VarValue>( node )
+						If vvar
+							Local ctype:=TCast<ClassType>( vvar.type )
+							If ctype
+								scope=ctype.scope
+								Continue
+							Endif
+						Endif
+					Catch ex:SemantEx
+					End
+				Endif
+				Print "Can't resolve link:"+path+", id="+id
+				Return name
 			Endif
 			
-			tpath+=id+"."
-			
 			Local ntype:=TCast<NamespaceType>( type )
 			If ntype
 				scope=ntype.scope
@@ -281,14 +318,15 @@ Class DocsMaker
 			Local etype:=TCast<EnumType>( type )
 			If etype
 				'stop at Enum!
-				Return MakeLink( tpath+"."+path.Slice( i0 ),etype.edecl,etype.scope.outer )
+				If Not name name=tpath+"."+path.Slice( i0 )
+				Return MakeLink( name,etype.edecl,etype.scope.outer )
 			Endif
 			
-			Return ""
+			Return name
 			
 		Forever
-			
-		Return ""
+		
+		Return name
 	End
 	
 	Method DeclIdent:String( decl:Decl,gen:Bool=False )
@@ -498,7 +536,9 @@ Class DocsMaker
 	End
 	
 	Method DocsHidden:Bool( decl:Decl,access:Int )
+		
 		If access And (decl.flags & access) Return DocsHidden( decl )
+		
 		Return True
 	End
 	
@@ -778,7 +818,7 @@ Class DocsMaker
 			If Not vvar Or vvar.transFile.module<>_module Continue
 			
 			Local decl:=vvar.vdecl
-			If decl.kind<>kind Or DocsHidden( decl,DECL_PUBLIC ) Continue
+			If decl.kind<>kind Or DocsHidden( decl ) Continue
 		
 			_linkScope=vvar.scope
 
@@ -807,7 +847,7 @@ Class DocsMaker
 			If Not atype Continue
 			
 			Local decl:=atype.adecl
-			If decl.kind<>kind Or DocsHidden( decl,DECL_PUBLIC ) Continue
+			If decl.kind<>kind Or DocsHidden( decl ) Continue
 		
 			_linkScope=atype.scope
 		
@@ -836,7 +876,7 @@ Class DocsMaker
 			If Not etype Continue
 			
 			Local decl:=etype.edecl
-			If decl.kind<>kind Or DocsHidden( decl,DECL_PUBLIC ) Continue
+			If decl.kind<>kind Or DocsHidden( decl ) Continue
 			
 			_linkScope=etype.scope.outer
 
@@ -865,7 +905,7 @@ Class DocsMaker
 			If Not ctype Or ctype.transFile.module<>_module Continue
 			
 			Local decl:=ctype.cdecl
-			If decl.kind<>kind Or DocsHidden( decl,DECL_PUBLIC ) Continue
+			If decl.kind<>kind Or DocsHidden( decl ) Continue
 			
 			_linkScope=ctype.scope	'.outer
 			
@@ -947,7 +987,7 @@ Class DocsMaker
 			If Not plist Continue
 			
 			Local decl:=plist.pdecl
-			If decl.kind<>kind Or DocsHidden( decl,DECL_PUBLIC ) Continue
+			If decl.kind<>kind Or DocsHidden( decl ) Continue
 
 			Local func:=plist.getFunc
 			If Not func 
@@ -989,8 +1029,7 @@ Class DocsMaker
 				If (func.IsMethod Or func.IsCtor) And func.scope<>scope Continue
 				
 				Local decl:=func.fdecl
-				
-				If DocsHidden( decl,DECL_PUBLIC ) Continue
+				If DocsHidden( decl ) Continue
 				
 				If kind="constructor"
 					If decl.ident<>"new" Continue

+ 11 - 9
src/mx2cc/docs/markdownbuffer.monkey2

@@ -38,7 +38,7 @@ End
 
 Class MarkdownBuffer
 
-	Alias LinkResolver:String( link:String )
+	Alias LinkResolver:String( link:String,name:String )
 
 	Alias TagHandler:Bool( tag:String,arg:String )
 	
@@ -257,15 +257,17 @@ Class MarkdownBuffer
 			Local i1:=line.Find( "]]",i0+2 )
 			If i1=-1 Return line
 			
-			Local path:=line.Slice( i0+2,i1 )
-			Local link:=path
+			Local link:=line.Slice( i0+2,i1 ),name:=""
+			Local i:=link.Find( "|" )
+			If i<>-1
+				name=link.Slice( i+1 )
+				link=link.Slice( 0,i )
+			Endif
 			
-			If _linkResolver<>Null
-				link=_linkResolver( path )
-				If Not link
-					Print "Makedocs error: Can't resolve link '"+path+"'"
-					link=path
-				Endif
+			If _linkResolver<>Null 
+				link=_linkResolver( link,name )
+			Else If name
+				link=name
 			Endif
 			
 			line=line.Slice( 0,i0 )+link+line.Slice( i1+2 )

+ 2 - 0
src/mx2cc/geninfo/geninfo.monkey2

@@ -73,6 +73,8 @@ Class ParseInfoGenerator
 	
 		local node:=MakeNode( decl )
 		
+		node.SetString( "namespace",decl.nmspace )
+		
 		If decl.imports node.SetValue( "imports",GenNode( decl.imports ) )
 		
 		Return node

+ 1 - 1
src/mx2cc/mx2.monkey2

@@ -50,4 +50,4 @@ Using libc
 ' 3) edit .sh and .bat files to use new version (common.sh, common.bat)
 ' 4) ./rebuildall
 '
-Const MX2CC_VERSION:="1.1.02"
+Const MX2CC_VERSION:="1.1.03"

+ 3 - 5
src/mx2cc/mx2cc.monkey2

@@ -23,7 +23,9 @@ Global StartDir:String
 
 Const TestArgs:="mx2cc makedocs"
 
-'Const TestArgs:="mx2cc makeapp -apptype=console src/mx2cc/test.monkey2"
+'Const TestArgs:="mx2cc makemods -target=ios std"' std"
+ 
+'Const TestArgs:="mx2cc makeapp -target=desktop src/mx2cc/test.monkey2"
 
 'To build with old mx2cc...
 '
@@ -367,10 +369,6 @@ Function ParseOpts:String[]( opts:BuildOpts,args:String[] )
 		Select opt
 		Case "-product"
 			opts.product=path
-		Case "-assets"
-			opts.assets=path
-		Case "-dlls"
-			opts.dlls=path
 		Case "-apptype"
 			Select val
 			Case "gui","console"

+ 11 - 1
src/mx2cc/parser.monkey2

@@ -498,6 +498,12 @@ Class Parser
 			Else
 				type=ParseFuncType( New IdentExpr( "void",SrcPos,SrcPos ) )
 			Endif
+
+			If kind="lambda"
+				For Local p:=Eachin type.params
+					If p.init Error( "Lambda function parameters cannot have default values" )
+				Next
+			Endif
 			
 			If Not (flags & DECL_EXTERN)
 				For Local param:=Eachin type.params
@@ -598,7 +604,11 @@ Class Parser
 				If Not (flags & DECL_SETTER) Error( "Getter must appear after setter" )
 			Default
 				Parse( "end" )
-				CParse( kind )
+				If flags & (DECL_GETTER|DECL_SETTER)
+					CParse( "property" )
+				Else
+					CParse( kind )
+				Endif
 				If kind<>"lambda" ParseEol()
 			End
 			

+ 2 - 0
src/mx2cc/test.java

@@ -0,0 +1,2 @@
+
+package com.monkey2.Monkey2Admob;

+ 1 - 23
src/mx2cc/test.monkey2

@@ -1,27 +1,5 @@
 
-Namespace test
-
-#Import "<std>"
-
-Using std..
-
-Struct Test<T>
-
-	Const A:=New Test( 10 )
-	Const B:=New Test[ 100 ]
-	
-	Field t:T
-	
-	Method New( t:T )
-		Self.t=t
-	End
-End
-
+#Import "test.java"
 
 Function Main()
-
-	Print Test<Int>.A.t
-	Print Test<Int>.B.Length
-	
-
 End

+ 35 - 0
src/mx2cc/tests/deps1.monkey2

@@ -0,0 +1,35 @@
+
+#Import "<std>"
+#Import "<mojo>"
+
+Using std..
+Using mojo..
+ 
+Function Main()
+	Local testStack := New TestStack
+	
+	For Local n := 1 To 20
+		Local newItem := New TestItem
+		testStack.Add( newItem, Rnd( 0, 100 ) )
+	Next
+		
+	For Local n := Eachin testStack.items
+		Print( n.depth )
+	Next
+End
+ 
+ 
+Class TestStack
+	Field items := New Stack< TestItem >
+	Method Add( item:TestItem, depth:Float ) 
+		item.depth = depth
+		items.Push( item )
+	End
+End
+ 
+ 
+Struct TestItem				'Change this to a Class and it will compile!
+	Field depth:Int
+	Field img: Image		'Comment out this line and it will compile!
+	Field color: Color
+End

+ 1 - 1
src/mx2cc/toker.monkey2

@@ -25,7 +25,7 @@ Function InitToker:Void()
 	
 	Local keyWords:="Namespace;Using;Import;Extern;"
 	keyWords+="Public;Private;Protected;Internal;Friend;"
-	keyWords+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;Object;Continue;Exit;"
+	keyWords+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;Array;Object;Continue;Exit;"
 	keyWords+="New;Self;Super;Eachin;True;False;Null;Where;"
 	keyWords+="Alias;Const;Local;Global;Field;Method;Function;Property;Getter;Setter;Operator;Lambda;"
 	keyWords+="Enum;Class;Interface;Struct;Extends;Implements;Virtual;Override;Abstract;Final;Inline;"

+ 42 - 10
src/mx2cc/translator.monkey2

@@ -302,14 +302,33 @@ Class Translator
 	Method EndDeps( baseDir:String )
 	
 		BeginInsert( _deps.depsPos )
-	
-		EmitBr()
+
+		'sort usesfiles		
+		Local usesFiles:=New Stack<FileDecl>
 		For Local fdecl:=Eachin _deps.usesFiles.Keys
+			usesFiles.Push( fdecl )
+		Next
+		usesFiles.Sort( Lambda:Int( x:FileDecl,y:FileDecl )
+			Return x.hfile<=>y.hfile
+		End )
+		
+		'Emit includes	
+		EmitBr()
+		For Local fdecl:=Eachin usesFiles
 			EmitInclude( fdecl,baseDir )
 		Next
+		_deps.usesFiles.Clear()
+		
+		'sort refsTypes
+		Local refsTypes:=New Stack<Type>( _deps.refsTypes )
+		refsTypes.Sort( Lambda:Int( x:Type,y:Type )
+			Return x.Name<=>y.Name
+		End )
+		_deps.refsTypes.Clear()
 		
+		'Emit refsTypes
 		EmitBr()
-		For Local type:=Eachin _deps.refsTypes
+		For Local type:=Eachin refsTypes
 		
 			Local ctype:=TCast<ClassType>( type )
 			If ctype
@@ -317,7 +336,7 @@ Class Translator
 				If Included( ctype.transFile ) Continue
 				
 				Local cname:=ClassName( ctype )
-				Emit( "struct "+ClassName( ctype )+";" )
+				Emit( "struct "+cname+";" )
 				
 				If GenTypeInfo( ctype ) 
 					Emit( "#ifdef BB_REFLECTION" )
@@ -346,19 +365,32 @@ Class Translator
 			Endif
 
 		Next
-		_deps.refsTypes.Clear()
+
+		'sort refsVars		
+		Local refsVars:=New Stack<VarValue>( _deps.refsVars )
+		refsVars.Sort( Lambda:Int( x:VarValue,y:VarValue )
+			Return x.Name<=>y.Name
+		End )
+		_deps.refsVars.Clear()
 		
+		'emit refsVars
 		EmitBr()	
-		For Local vvar:=Eachin _deps.refsVars
+		For Local vvar:=Eachin refsVars
 			If Not Included( vvar.transFile ) Emit( "extern "+VarProto( vvar )+";" )
 		Next
-		_deps.refsVars.Clear()
-	
+		
+		'sort refsFuncs
+		Local refsFuncs:=New Stack<FuncValue>( _deps.refsFuncs )
+		refsFuncs.Sort( Lambda:Int( x:FuncValue,y:FuncValue )
+			Return x.Name<=>y.Name
+		End )
+		_deps.refsFuncs.Clear()
+		
+		'emit refsFuncs
 		EmitBr()
-		For Local func:=Eachin _deps.refsFuncs
+		For Local func:=Eachin refsFuncs
 			If Not Included( func.transFile ) Emit( "extern "+FuncProto( func )+";" )
 		Next
-		_deps.refsFuncs.Clear()
 		
 		EndInsert()
 		

+ 29 - 8
src/mx2cc/translator_cpp.monkey2

@@ -331,17 +331,21 @@ Class Translator_CPP Extends Translator
 		
 		EmitClassProto( ctype )
 		
-		Local uses:=_deps.uses
+		Local uses:=New Stack<ClassType>
+		For Local node:=Eachin _deps.uses.Keys
+			Local ctype:=Cast<ClassType>( node )
+			uses.Push( ctype )
+		Next
+		uses.Sort( Lambda:Int( x:ClassType,y:ClassType )
+			Return x.Name<=>y.Name
+		End )
 		
 		EndDeps( ExtractDir( fdecl.hfile ) )
 		
 		
 		emitted[ClassName( ctype )]=True
-		
 	
-		For Local node:=Eachin uses.Keys
-		
-			Local ctype2:=TCast<ClassType>( node )
+		For Local ctype2:=Eachin uses
 		
 			If ctype2.cdecl.IsExtern Or ctype2.transFile<>fdecl Or emitted[ClassName( ctype2 )] Continue
 			
@@ -649,6 +653,8 @@ Class Translator_CPP Extends Translator
 				Emit( ClassName( ctype.superType )+"::dbEmit();" )
 			End
 			
+			Emit( "puts( ~q["+ctype.Name+"]~q);" )
+			
 			For Local vvar:=Eachin ctype.fields
 				Emit( "bbDBEmit(~q"+vvar.vdecl.ident+"~q,&"+VarName( vvar )+");" )
 			Next
@@ -1296,6 +1302,19 @@ Class Translator_CPP Extends Translator
 
 	End
 	
+	Method AssignsTo( type:Type )
+		
+		Uses( type )
+
+		Local ctype:=TCast<ClassType>( type )
+		If ctype And ctype.IsStruct
+			For Local vvar:=Eachin ctype.fields
+				AssignsTo( vvar.type )
+			Next
+		Endif
+		
+	End
+	
 	Method EmitStmt( stmt:AssignStmt )
 	
 		Local op:=stmt.op
@@ -1309,11 +1328,11 @@ Class Translator_CPP Extends Translator
 			If vvar And vvar.vdecl.kind="param" FindGCTmp( vvar )
 		End
 		
+		AssignsTo( stmt.lhs.type )
+		
 		Local lhs:=Trans( stmt.lhs )
 		Local rhs:=Trans( stmt.rhs )
 		
-		Uses( stmt.lhs.type )
-
 		Emit( lhs+op+rhs+";" )
 	End
 
@@ -1671,7 +1690,7 @@ Class Translator_CPP Extends Translator
 	Method TransInvokeMember:String( instance:Value,member:FuncValue,args:Value[] )
 
 		Uses( instance.type )
-	
+		
 		If member.IsExtension
 			
 			Local tinst:=Trans( instance )
@@ -1692,6 +1711,8 @@ Class Translator_CPP Extends Translator
 	
 	Method Trans:String( value:InvokeValue )
 	
+		Decls( value.type )
+		
 		Local mfunc:=Cast<MemberFuncValue>( value.value )
 		
 		If mfunc Return TransInvokeMember( mfunc.instance,mfunc.member,value.args )

+ 2 - 2
src/mx2cc/util.monkey2

@@ -79,10 +79,10 @@ Function MungPath:String( path:String )
 	Return id
 End
 
-Function GetEnv:String( name:String )
+Function GetEnv:String( name:String,defaultValue:String="" )
 	Local p:=getenv( name )
 	If p Return String.FromCString( p )
-	Return ""
+	Return defaultValue
 End
 
 Function SetEnv( name:String,value:String )

+ 1 - 2
src/ted2/buildproduct.monkey2

@@ -540,8 +540,7 @@ Class AndroidProduct Extends BuildProduct
 	Method OnGetMx2ccOpts:String() Override
 
 		Local opts:=""
-		opts+=" ~q-assets="+ProductDir+"app/src/main/assets/~q"
-		opts+=" ~q-dlls="+ProductDir+"app/src/main/jniLibs/~q"
+		opts+=" ~q-product="+ProductDir+"~q"
 		
 		Return opts
 	End

+ 3 - 3
src/ted2/modulemanager.monkey2

@@ -202,10 +202,10 @@ Class ModuleManager Extends Dialog
 			Local dst:=downloadDir+zip
 
 #if __HOSTOS__="macos"
-			Local cmd:="curl -o ~q"+dst+"~q ~q"+src+"~q"
-#else
+			Local cmd:="curl -o ~q"+dst+"~q -data-binary ~q"+src+"~q"
+#Else
 			Local cmd:="wget -O ~q"+dst+"~q ~q"+src+"~q"
-#endif
+#Endif
 			_progress.Text="Downloading "+zip+"..."
 			
 			If Not _console.Run( cmd ) Return False

+ 1 - 1
src/ted2/monkey2document.monkey2

@@ -19,7 +19,7 @@ Function InitKeywords()
 	Local kws:=""
 	kws+="Namespace;Using;Import;Extern;"
 	kws+="Public;Private;Protected;Friend;"
-	kws+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;CString;Variant;TypeInfo;DeclInfo;Object;Continue;Exit;"
+	kws+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;Array;CString;Variant;TypeInfo;DeclInfo;Object;Continue;Exit;"
 	kws+="New;Self;Super;Eachin;True;False;Null;Where;"
 	kws+="Alias;Const;Local;Global;Field;Method;Function;Property;Getter;Setter;Operator;Lambda;"
 	kws+="Enum;Class;Interface;Struct;Extends;Implements;Virtual;Override;Abstract;Final;Inline;"

+ 1 - 1
src/ted2go

@@ -1 +1 @@
-Subproject commit ef4c80f62312888851071b0141a3b4b6a429175b
+Subproject commit 063f945f752274e0d883ce76cd4b3590c0977f40