瀏覽代碼

Merge pull request #63 from blitz-research/develop

Develop up
abakobo 8 年之前
父節點
當前提交
0d267f2bd3

+ 7 - 0
VERSIONS.TXT

@@ -1,4 +1,11 @@
 
+***** Monkey2 v1.1.05c *****
+
+* App no longer renders when minimized/inactive.
+
+* Added 'Internal' decl visibility to mx2cc, which means a decl is only visible to other decls within the same module.
+
+
 ***** Monkey2 v1.1.05b *****
 
 * Fixes a number of fairly critical GC bugs. GC is more aggressive now which has turned up a few 'lurkers'.

+ 1 - 0
bananas/vsynth/audiopipe.h

@@ -1,6 +1,7 @@
 #pragma once
 #include <deque>
 #include <mutex>
+#include <algorithm>
 
 typedef double Sample;
 

+ 17 - 8
modules/mojo/app/app.monkey2

@@ -88,8 +88,10 @@ Class AppInstance
 		If Not config config=New StringMap<String>
 	
 		_config=config
-
+		
 		SDL_Init( SDL_INIT_VIDEO|SDL_INIT_JOYSTICK )
+		
+		SDL_SetHint( "SDL_MOUSE_FOCUS_CLICKTHROUGH","1" )
 
 		'possible fix for linux crashing at exit (can't reproduce myself).
 		'		
@@ -436,12 +438,19 @@ Class AppInstance
 	
 		_requestRender=True
 	End
+	
+	#rem monkeydoc @hidden
+	#end
+	Property Renderable:Bool()
+		
+		Return _activeWindow And Not _activeWindow.Minimized And Not _frozen
+	End
 
 	#rem monkeydoc @hidden
 	#end
 	Method MainLoop()
-	
-		If Not _requestRender
+		
+		If Not _requestRender Or Not Renderable
 
 			SDL_WaitEvent( Null )
 			
@@ -475,9 +484,9 @@ Class AppInstance
 	#rem monkeydoc @hidden
 	#end	
 	Method UpdateWindows()
-	
-		If _frozen Return
-	
+		
+		if Not Renderable Return
+		
 		Local render:=_requestRender
 		_requestRender=False
 		
@@ -747,7 +756,7 @@ Class AppInstance
 			SendKeyEvent( EventType.KeyChar )
 			
 		Case SDL_MOUSEBUTTONDOWN
-		
+			
 			Local mevent:=Cast<SDL_MouseButtonEvent Ptr>( event )
 			
 			_window=Window.WindowForID( mevent->windowID )
@@ -785,7 +794,7 @@ Class AppInstance
 			Endif
 		
 		Case SDL_MOUSEBUTTONUP
-		
+			
 			Local mevent:=Cast<SDL_MouseButtonEvent Ptr>( event )
 			
 			_window=Window.WindowForID( mevent->windowID )

+ 4 - 2
modules/mojo/graphics/glexts/glexts.cpp

@@ -16,6 +16,7 @@ namespace bbGLexts{
 	bool GL_texture_float;
 	bool GL_texture_half_float;
 	bool GL_depth_texture;
+	bool GL_seamless_cube_map;
 	
 	PFNGLDRAWBUFFERSPROC glDrawBuffers;
 	
@@ -60,12 +61,13 @@ namespace bbGLexts{
 			SDL_GL_ExtensionSupported( "GL_WEBGL_depth_texture" ) ||
 			SDL_GL_ExtensionSupported( "GL_OES_depth_texture" );
 		
+		GL_seamless_cube_map=SDL_GL_ExtensionSupported( "GL_ARB_seamless_cube_map" );
+			
 //		bb_printf( "GL_draw_buffers=%i\n",int( GL_draw_buffers ) );
 //		bb_printf( "GL_texture_float=%i\n",int( GL_texture_float ) );
 //		bb_printf( "GL_texture_half_float=%i\n",int( GL_texture_half_float ) );
 //		bb_printf( "GL_depth_texture=%i\n",int( GL_depth_texture ) );
-		
-		fflush( stdout );
+//		fflush( stdout );
 	}
 	
 }

+ 1 - 0
modules/mojo/graphics/glexts/glexts.h

@@ -14,6 +14,7 @@ namespace bbGLexts{
 	extern bool GL_texture_float;
 	extern bool GL_texture_half_float;
 	extern bool GL_depth_texture;
+	extern bool GL_seamless_cube_map;
 	
 	typedef void (GL_APIENTRY *PFNGLDRAWBUFFERSPROC)( GLsizei n,const GLenum *bufs );
 

+ 13 - 3
modules/mojo/graphics/glexts/glexts.monkey2

@@ -8,6 +8,8 @@ Namespace mojo.graphics.glexts
 
 #Endif
 
+Const GL_TEXTURE_CUBE_MAP_SEAMLESS:=$884f
+
 Const GL_DRAW_BUFFER:=$0c01
 
 Const GL_READ_BUFFER:=$0c01
@@ -35,17 +37,19 @@ Const GL_COLOR_ATTACHMENT13:Int=$8CED
 Const GL_COLOR_ATTACHMENT14:Int=$8CEE
 Const GL_COLOR_ATTACHMENT15:Int=$8CEF
 
+'GLES2 targets
 #If __TARGET__="windows" Or __MOBILE_TARGET__ Or __WEB_TARGET__
 
 Const GL_draw_buffer:Bool=False
 Const GL_read_buffer:Bool=False
+Const GL_seamless_cube_map:bool=False
 
 Extern
 
 Const GL_draw_buffers:Bool="bbGLexts::GL_draw_buffers"
+Const GL_depth_texture:bool="bbGLexts::GL_depth_texture"
 Const GL_texture_float:Bool="bbGLexts::GL_texture_float"
 Const GL_texture_half_float:bool="bbGLexts::GL_texture_half_float"
-Const GL_depth_texture:bool="bbGLexts::GL_depth_texture"
 
 Function glDrawBuffers( n:Int,bufs:GLenum Ptr )="bbGLexts::glDrawBuffers"
 
@@ -62,14 +66,16 @@ Function glReadBuffer( mode:GLenum )
 	RuntimeError( "glReadBuffer unsupported" )
 End
 
+'GL targets
 #Elseif __TARGET__="macos" Or __TARGET__="linux"
 
 Const GL_draw_buffer:Bool=True
 Const GL_read_buffer:Bool=True
 Const GL_draw_buffers:Bool=True
+Const GL_depth_texture:bool=True
 Const GL_texture_float:Bool=True
 Const GL_texture_half_float:bool=True
-Const GL_depth_texture:bool=True
+Const GL_seamless_cube_map:bool=True
 
 Extern
 
@@ -82,12 +88,16 @@ Public
 Function InitGLexts()
 End
 
+'?
 #Else
 
+Const GL_draw_buffer:Bool=False
+Const GL_read_buffer:Bool=False
 Const GL_draw_buffers:Bool=False
+Const GL_depth_texture:bool=False
 Const GL_texture_float:Bool=False
 Const GL_texture_half_float:bool=False
-Const GL_depth_texture:bool=False
+Const GL_seamless_cube_map:Bool=False
 
 Function glDrawBuffers( n:Int,bufs:GLenum Ptr )
 	RuntimeError( "glDrawBuffers unsupported" )

+ 2 - 0
modules/mojo/graphics/graphicsdevice.monkey2

@@ -443,6 +443,8 @@ Class GraphicsDevice
 		If GL_draw_buffer glGetIntegerv( GL_DRAW_BUFFER,Varptr _defaultDrawBuf )
 		If GL_read_buffer glGetIntegerv( GL_READ_BUFFER,Varptr _defaultReadBuf )
 			
+		if GL_seamless_cube_map glEnable( GL_TEXTURE_CUBE_MAP_SEAMLESS )
+			
 		glCheck()
 	End
 	

+ 36 - 11
modules/mojo/graphics/vertex3f.monkey2

@@ -5,12 +5,13 @@ Struct Vertex3f
 
 	Field position:Vec3f	'0
 	Field texCoord0:Vec2f	'12
-	Field normal:Vec3f		'20
-	Field tangent:Vec4f		'32
-	Field weights:Vec4f		'48
-	Field bones:UInt		'64
+	Field texCoord1:Vec2f	'20
+	Field normal:Vec3f		'28
+	Field tangent:Vec4f		'40
+	Field weights:Vec4f		'56
+	Field bones:UInt		'72
 
-	Const Pitch:=68			'68
+	Const Pitch:=76			'76
 	
 	Method New()
 	End
@@ -66,6 +67,30 @@ Struct Vertex3f
 		texCoord0.y=sy
 	End
 	
+	Property Sx0:Float()
+		Return texCoord0.x
+	Setter( sx:Float )
+		texCoord0.x=sx
+	End
+	
+	Property Sy0:Float()
+		Return texCoord0.y
+	Setter( sy:Float )
+		texCoord0.y=sy
+	End
+	
+	Property Sx1:Float()
+		Return texCoord1.x
+	Setter( sx:Float )
+		texCoord1.x=sx
+	End
+	
+	Property Sy1:Float()
+		Return texCoord1.y
+	Setter( sy:Float )
+		texCoord1.y=sy
+	End
+	
 End
 
 Class Vertex3fFormat Extends VertexFormat
@@ -74,17 +99,17 @@ Class Vertex3fFormat Extends VertexFormat
 	
 	Property Pitch:Int() Override
 		
-		Return 68
+		Return Vertex3f.Pitch
 	End
 
 	Method UpdateGLAttribs() Override
-		
 		glEnableVertexAttribArray( A_POSITION ) ; glVertexAttribPointer( A_POSITION,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 0 ) )
 		glEnableVertexAttribArray( A_TEXCOORD0 ) ; glVertexAttribPointer( A_TEXCOORD0,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 12 ) )
-		glEnableVertexAttribArray( A_NORMAL ) ; glVertexAttribPointer( A_NORMAL,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 20 ) )
-		glEnableVertexAttribArray( A_TANGENT ) ; glVertexAttribPointer( A_TANGENT,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 32 ) )
-		glEnableVertexAttribArray( A_WEIGHTS ) ; glVertexAttribPointer( A_WEIGHTS,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 48 ) )
-		glEnableVertexAttribArray( A_BONES ) ; glVertexAttribPointer( A_BONES,4,GL_UNSIGNED_BYTE,False,Pitch,Cast<Void Ptr>( 64 ) )
+		glEnableVertexAttribArray( A_TEXCOORD1 ) ; glVertexAttribPointer( A_TEXCOORD1,2,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 20 ) )
+		glEnableVertexAttribArray( A_NORMAL ) ; glVertexAttribPointer( A_NORMAL,3,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 28 ) )
+		glEnableVertexAttribArray( A_TANGENT ) ; glVertexAttribPointer( A_TANGENT,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 40 ) )
+		glEnableVertexAttribArray( A_WEIGHTS ) ; glVertexAttribPointer( A_WEIGHTS,4,GL_FLOAT,False,Pitch,Cast<Void Ptr>( 56 ) )
+		glEnableVertexAttribArray( A_BONES ) ; glVertexAttribPointer( A_BONES,4,GL_UNSIGNED_BYTE,False,Pitch,Cast<Void Ptr>( 72 ) )
 	End
 	
 End

+ 45 - 31
modules/mojo3d/graphics/deferredrenderer.monkey2

@@ -1,45 +1,16 @@
 
 Namespace mojo3d.graphics
 
-Private
-
-Const WIDTH:=1920
-Const HEIGHT:=1080
-Const MRT_COLOR_FORMAT:=PixelFormat.RGBA8'RGBA32F
-
-Public
-
 #rem monkeydoc @hidden The DeferredRenderer class.
 #end
 Class DeferredRenderer Extends Renderer
 	
-	Method New()
-	
-		Local size:=New Vec2i( WIDTH,HEIGHT )
-	
-		_copyShader=Shader.Open( "copy" )
-		_plightShader=Shader.Open( "point-light" )
-		_dlightShader=Shader.Open( "directional-light" )
-		
-		_hdrTexture=New Texture( size.x,size.y,MRT_COLOR_FORMAT,TextureFlags.Filter|TextureFlags.Dynamic )			'output hdr image
-		_colorTexture=New Texture( size.x,size.y,MRT_COLOR_FORMAT,TextureFlags.Filter|TextureFlags.Dynamic )		'metalness in 'a'
-		_normalTexture=New Texture( size.x,size.y,MRT_COLOR_FORMAT,TextureFlags.Filter|TextureFlags.Dynamic )		'roughness in 'a'
-		_depthTexture=New Texture( size.x,size.y,PixelFormat.Depth32F,TextureFlags.Dynamic )
-		
-		_rpass0Target=New RenderTarget( New Texture[]( _hdrTexture,_colorTexture,_normalTexture ),_depthTexture )
-		_rpass2Target=New RenderTarget( New Texture[]( _hdrTexture ),Null )
-		
-		'_uniforms.SetTexture( "HdrTexture",_hdrTexture )
-		
-		_uniforms.SetTexture( "ColorBuffer",_colorTexture )
-		_uniforms.SetTexture( "NormalBuffer",_normalTexture )
-		_uniforms.SetTexture( "DepthBuffer",_depthTexture )
-	End
-
 	Protected
 	
 	Method OnRender() Override
 		
+		Init()
+		
 		_device.RenderTarget=_rpass0Target
 		_device.Viewport=New Recti( 0,0,_renderViewport.Size )
 		_device.Scissor=_device.Viewport
@@ -162,4 +133,47 @@ Class DeferredRenderer Extends Renderer
 	Field _rpass0Target:RenderTarget
 	Field _rpass2Target:RenderTarget
 	
+	Method Init()
+		
+		Global _inited:=False
+		
+		If Not _inited
+			_copyShader=Shader.Open( "copy" )
+			_plightShader=Shader.Open( "point-light" )
+			_dlightShader=Shader.Open( "directional-light" )
+		Endif
+		
+		Local size:=_renderViewport.Size
+		size.x=Max( size.x,1920 )
+		size.y=Max( size.y,1080 )
+		
+		If Not _inited Or size.x>_hdrTexture.Size.x Or size.y>_hdrTexture.Size.y
+		
+			SafeDiscard( _hdrTexture )
+			SafeDiscard( _colorTexture )
+			SafeDiscard( _normalTexture )
+			SafeDiscard( _depthTexture )
+			SafeDiscard( _rpass0Target )
+			SafeDiscard( _rpass2Target )
+	
+			Const format:=PixelFormat.RGBA32F		'32 bit float
+			
+			_hdrTexture=New Texture( size.x,size.y,format,TextureFlags.Filter|TextureFlags.Dynamic )			'output hdr image
+			_colorTexture=New Texture( size.x,size.y,format,TextureFlags.Filter|TextureFlags.Dynamic )		'metalness in 'a'
+			_normalTexture=New Texture( size.x,size.y,format,TextureFlags.Filter|TextureFlags.Dynamic )		'roughness in 'a'
+			_depthTexture=New Texture( size.x,size.y,PixelFormat.Depth32F,TextureFlags.Dynamic )
+			
+			_rpass0Target=New RenderTarget( New Texture[]( _hdrTexture,_colorTexture,_normalTexture ),_depthTexture )
+			_rpass2Target=New RenderTarget( New Texture[]( _hdrTexture ),Null )
+			
+			_uniforms.SetTexture( "ColorBuffer",_colorTexture )
+			_uniforms.SetTexture( "NormalBuffer",_normalTexture )
+			_uniforms.SetTexture( "DepthBuffer",_depthTexture )
+		
+		Endif
+		
+		_inited=true
+		
+	End
+	
 End

+ 3 - 19
modules/mojo3d/graphics/scene.monkey2

@@ -98,59 +98,43 @@ Class Scene
 		Return _current
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
+	Internal
+
 	Function SetCurrent( scene:Scene )
 		
 		_current=scene
 	End
-
-	'***** INTERNAL *****
-
-	#rem monkeydoc @hidden
-	#end		
+	
 	Property PostEffects:Stack<PostEffect>()
 		
 		Return _postEffects
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property RootEntities:Stack<Entity>()
 		
 		Return _rootEntities
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Cameras:Stack<Camera>()
 		
 		Return _cameras
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Lights:Stack<Light>()
 		
 		Return _lights
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Models:Stack<Model>()
 		
 		Return _models
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Terrains:Stack<Terrain>()
 		
 		Return _terrains
 	End
 	
-	#rem monkeydoc @hidden
-	#end	
 	Property Sprites:Stack<Sprite>()
 		
 		Return _sprites

+ 2 - 2
modules/mojo3d/graphics/shaders/bloom.glsl

@@ -3,7 +3,7 @@
 
 uniform sampler2D m_SourceTexture;
 uniform vec2 m_SourceTextureSize;
-uniform vec2 m_SourceCoordScale;
+uniform vec2 m_SourceTextureScale;
 
 varying vec2 v_TexCoord0;
 
@@ -13,7 +13,7 @@ attribute vec2 a_Position;	//0...1 (1=viewport size)
 
 void main(){
 
-	v_TexCoord0=a_Position * m_SourceCoordScale;
+	v_TexCoord0=a_Position * m_SourceTextureScale;
 
 	gl_Position=vec4( a_Position * 2.0 - 1.0,-1.0,1.0 );
 }

+ 99 - 0
modules/mojo3d/tests/cubetest.monkey2

@@ -0,0 +1,99 @@
+Namespace myapp
+
+#Import "<std>"
+#Import "<mojo>"
+#Import "<mojo3d>"
+
+#Import "assets/"
+
+#Import "util"
+
+Using std..
+Using mojo..
+Using mojo3d..
+
+Class MyWindow Extends Window
+	
+	Field _scene:Scene
+	
+	Field _camera:Camera
+	
+	Field _light:Light
+	
+	Field _donut:Model
+	
+	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable )
+
+		Super.New( title,width,height,flags )
+		
+		'little mini cubemap
+		Local pixmap:=New Pixmap( 4,3 )
+		pixmap.Clear( Color.Black )
+		pixmap.SetPixelARGB( 1,0,$ffff0000 )
+		pixmap.SetPixelARGB( 1,1,$ff00ff00 )
+		pixmap.SetPixelARGB( 1,2,$ff0000ff )
+		pixmap.SetPixelARGB( 0,1,$ffffff00 )
+		pixmap.SetPixelARGB( 2,1,$ffff00ff )
+		pixmap.SetPixelARGB( 3,1,$ff00ffff )
+		Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap|TextureFlags.FilterMipmap )		'seamless
+'		Local cubemap:=New Texture( pixmap,TextureFlags.Cubemap )								'seamed
+		
+		_scene=Scene.GetCurrent()
+		
+		_scene.EnvTexture=cubemap
+'		_scene.SkyTexture=cubemap
+		
+		_scene.AmbientLight=Color.Black
+		
+		_scene.ClearColor=Color.Black
+		
+		Local bloom:=New BloomEffect
+		bloom.Passes=4
+		
+		'create camera
+		'
+		_camera=New Camera
+		_camera.Near=.1
+		_camera.Far=100
+		_camera.Move( 0,10,-10 )
+		
+		'create light
+		'
+		'_light=New Light
+		'_light.RotateX( Pi/2 )	'aim directional light 'down' - Pi/2=90 degrees.
+		
+		'create donut - metallic silver...
+		'		
+'		Local material:=New PbrMaterial( Color.White,1,0 )	'shiny metallic white
+		Local material:=New PbrMaterial( Color.White,0,1 )	'rough non-metallic white
+		
+		_donut=Model.CreateTorus( 2,.5,48,24,material )
+		
+		_donut.Move( 0,10,0 )
+	End
+	
+	Method OnRender( canvas:Canvas ) Override
+	
+		RequestRender()
+		
+		If Keyboard.KeyHit( Key.Space ) _donut.Visible=Not _donut.Visible
+		
+		_donut.Rotate( .01,.02,.03 )
+		
+		util.Fly( _camera,Self )
+		
+		_scene.Render( canvas,_camera )
+		
+		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
+	End
+	
+End
+
+Function Main()
+
+	New AppInstance
+	
+	New MyWindow
+	
+	App.Run()
+End

+ 85 - 0
modules/mojo3d/tests/makequad.monkey2

@@ -0,0 +1,85 @@
+
+#Import "<std>"
+#Import "<mojo>"
+#Import "<mojo3d>"
+
+Using std..
+Using mojo..
+Using mojo3d..
+
+Class MyWindow Extends Window
+	
+	Field _scene:Scene
+	
+	Field _camera:Camera
+	
+	Field _light:Light
+	
+	Field _model:Model
+	
+	Method New()
+		
+		'get scene
+		'
+		_scene=Scene.GetCurrent()
+
+		'create camera
+		'
+		_camera=New Camera
+		_camera.Near=.1
+		_camera.Far=100
+		_camera.Move( 0,0,-5 )
+		
+		'create light
+		'
+		_light=New Light
+		_light.RotateX( Pi/2 )	'aim directional light downwards - Pi/2=90 degrees.
+		
+		'create quad mesh
+		'
+		Local vertices:=New Vertex3f[4]
+		vertices[0].position=New Vec3f( -1, 1,0 )
+		vertices[1].position=New Vec3f(  1, 1,0 )
+		vertices[2].position=New Vec3f(  1,-1,0 )
+		vertices[3].position=New Vec3f( -1,-1,0 )
+
+		Local indices:=New UInt[6]
+		indices[0]=0
+		indices[1]=1
+		indices[2]=2
+		indices[3]=0
+		indices[4]=2
+		indices[5]=3
+		
+		Local mesh:=New Mesh( vertices,indices )
+		
+		'create model for the mesh
+		'
+		_model=New Model
+		_model.Mesh=mesh
+		_model.Material=New PbrMaterial( Color.Red )
+		_model.Material.CullMode=CullMode.None
+
+	End
+	
+	Method OnRender( canvas:Canvas ) Override
+
+		RequestRender()
+		
+		_model.RotateY( .1 )
+		
+		_scene.Render( canvas,_camera )
+
+		canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
+	End
+	
+End
+
+Function Main()
+	
+	New AppInstance
+	New MyWindow
+	App.Run()
+End
+
+	

+ 4 - 1
src/mx2cc/docs/docsmaker.monkey2

@@ -532,7 +532,10 @@ Class DocsMaker
 	End
 	
 	Method DocsHidden:Bool( decl:Decl )
-		Return (Not decl.IsPublic And Not decl.docs) Or decl.docs.StartsWith( "@hidden" )
+		
+		If decl.docs Return decl.docs.StartsWith( "@hidden" )
+		
+		Return decl.IsPrivate Or decl.IsInternal
 	End
 	
 	Method DocsHidden:Bool( decl:Decl,access:Int )

+ 1 - 1
src/mx2cc/errors.monkey2

@@ -25,7 +25,7 @@ Class ParseEx Extends ErrorEx
 		Self.srcfile=srcfile
 		Self.srcpos=srcpos
 		
-		Print ToString()
+		If srcfile Print ToString()
 	End
 	
 	Method ToString:String() Override

+ 1 - 1
src/mx2cc/mx2cc.monkey2

@@ -25,7 +25,7 @@ Const FORCE_MSVC:=False
 
 Global StartDir:String
 
-'Const TestArgs:="mx2cc makemods -clean"
+'Const TestArgs:="mx2cc makemods"
 
 'Const TestArgs:="mx2cc makemods -clean monkey"
 

+ 25 - 110
src/mx2cc/parser.monkey2

@@ -149,17 +149,21 @@ Class Parser
 					flags=(flags & ~DECL_ACCESSMASK) | DECL_EXTERN
 					If CParse( "private" )
 						flags|=DECL_PRIVATE
+					Else If CParse( "internal" )
+						flags|=DECL_INTERNAL|DECL_PUBLIC
 					Else
 						CParse( "public" )
 						flags|=DECL_PUBLIC
 					Endif
 					ParseEol()
 					Continue
-				Case "public","private"
+				Case "public","private","internal"
 					flags&=~DECL_ACCESSMASK
 					If fileScope flags&=~DECL_EXTERN
 					If CParse( "private" )
 						flags|=DECL_PRIVATE
+					Else If CParse( "internal" )
+						flags|=DECL_INTERNAL|DECL_PUBLIC
 					Else
 						Parse( "public" )
 						flags|=DECL_PUBLIC
@@ -223,18 +227,20 @@ Class Parser
 		Return decls.ToArray()
 	End
 	
+	#rem
 	Method CParseAccess:Int( flags:Int )
 	
 		Select Toke
 		Case "public" flags=flags & ~(DECL_ACCESSMASK) | DECL_PUBLIC
 		Case "private" flags=flags & ~(DECL_ACCESSMASK) | DECL_PRIVATE
-		Case "protected" flags=flags & ~(DECL_ACCESSMASK) | DECL_PROTECTED
 		Case "internal" flags=flags & ~(DECL_ACCESSMASK) | DECL_INTERNAL
+		Case "protected" flags=flags & ~(DECL_ACCESSMASK) | DECL_PROTECTED
 		Default Return flags
 		End
 		Bump()
 		Return flags
 	End
+	#end
 	
 	Method ParseAliases( decls:Stack<Decl>,flags:Int )
 	
@@ -2073,13 +2079,6 @@ Class Parser
 	
 	'***** Messy Preprocessor - FIXME! *****
 	
-	Class EvalEx Extends Throwable
-		Field msg:String
-		Method new( msg:String )
-			Self.msg=msg
-		End
-	End
-	
 	Field _ppsyms:StringMap<String>
 	
 	Field _cc:=New Stack<Int>
@@ -2097,12 +2096,7 @@ Class Parser
 		If v="false" Or v="~q~q" Return "false"
 		Return "true"
 	End
-	
-	Method EvalError( msg:String )
-		Throw New EvalEx( msg )
-'		Error( "Failed to evaluate preprocessor expression: "+msg )' toke='"+Toke+"'" )
-	End
-		
+
 	Method EvalPrimary:String()
 	
 		If CParse( "(" )
@@ -2115,13 +2109,14 @@ Class Parser
 		Case TOKE_IDENT
 			Local id:=Parse()
 			Local t:=_ppsyms[id]
-			If Not t EvalError( "symbol '"+id+"' not found" )
+			If Not t Error( "symbol '"+id+"' not found" )
 			Return t
 		Case TOKE_STRINGLIT
 			Return Parse()
 		End
 
-		EvalError( "unexpected token '"+Toke+"'" )
+		Error( "unexpected token '"+Toke+"'" )
+		
 		Return Null
 	End
 	
@@ -2142,9 +2137,11 @@ Class Parser
 				lhs=ToBool( lhs )
 				rhs=ToBool( rhs )
 			Endif
+			
 			If (lhs="~q"+HostOS+"~q" And rhs="~qdesktop~q") Or (lhs="~qdesktop~q" And rhs="~q"+HostOS+"~q" ) 
-				EvalError( "__TARGET__=~qdesktop~q no longer supported! Use boolean __DESKTOP_TARGET__ instead!" )
+				Error( "__TARGET__=~qdesktop~q no longer supported! Use boolean __DESKTOP_TARGET__ instead!" )
 			Endif
+			
 			Select op
 			Case "=" If lhs=rhs lhs="true" Else lhs="false"
 			Case "<>" If lhs<>rhs lhs="true" Else lhs="false"
@@ -2224,7 +2221,7 @@ Class Parser
 				
 			Case "end","endif"
 			
-				If _cc.Length=1 EvalError( "#end without matching #if or #rem" )
+				If _cc.Length=1 p.Error( "#end without matching #if or #rem" )
 			
 				If p.CParse( "end" )
 					p.CParse( "if" )
@@ -2254,8 +2251,11 @@ Class Parser
 				If _cc.Top=1
 
 					p.Bump()
+					
 					Local path:=p.ParseString()
 					
+					p.ParseEol()
+					
 					If path.StartsWith( "<" ) And path.EndsWith( ">" )
 					
 						If Not ExtractExt( path ) path=path.Slice( 0,-1 )+".monkey2>"
@@ -2277,101 +2277,16 @@ Class Parser
 					Print p.Eval()
 				Endif
 				
-			End
-		
-			#rem
-			Select p.Toke.ToLower()
-			Case "if"
-				
-				If _ccnest=_ifnest
-				
-					p.Bump()
-					If p.EvalBool() _ccnest+=1
-					
-				Endif
-			
-				_ifnest+=1
-				
-			Case "else","elseif"
-			
-				If _ccnest=_ifnest
-				
-					_ccnest|=$10000
-					
-				Else If _ccnest=_ifnest-1
-			
-					Local t:=True
-
-					If p.CParse( "else" )
-						If p.CParse( "if" ) t=p.EvalBool()
-					Else 
-						p.Bump()
-						t=p.EvalBool()
-					Endif
-					
-					If t _ccnest+=1
-					
-				Endif
-			
-			Case "end","endif"
-			
-				If p.CParse( "end" )
-					p.CParse( "if" )
-				Else
-					p.Bump()
-				End
-				
-				_doccing=False
-				
-				_ccnest&=~$10000
-
-				If _ccnest=_ifnest _ccnest-=1
-				
-				_ifnest-=1
-			
-			Case "rem"
-			
-				If p.Bump()="monkeydoc" And _ccnest=_ifnest
-					Local qhelp:=p._toker.Text.Slice( p._toker.TokePos+9 ).Trim()
-					_ccnest|=$10000
-					_doccing=True
-					_docs.Clear()
-					_docs.Push( qhelp )
-				Endif
-				
-				_ifnest+=1
-			
-			Case "import"
-			
-				If _ccnest=_ifnest 
-					p.Bump()
-					Local path:=p.ParseString()
-					
-					If path.StartsWith( "<" ) And path.EndsWith( ">" )
-					
-						If Not ExtractExt( path ) path=path.Slice( 0,-1 )+".monkey2>"
-						
-					Else If Not path.Contains( "@/" ) And Not path.EndsWith( "/" )
-					
-						If Not ExtractExt( path ) path+=".monkey2"
-						
-					Endif
-					_imports.Push( path )
-				Endif
+			Default
 				
-			Case "print"
-			
-				If _ccnest=_ifnest
-					p.Bump()				
-					Print p.Eval()
+				If _cc.Top=1
+					p.Error( "Unrecognized preprocessor directive '"+p.Toke+"'" )
 				Endif
-				
 			End
-			#end
 			
-		Catch ex:EvalEx
-		
-			Error( "Preprocessor error - "+ex.msg )
+		Catch ex:ParseEx
+			
+			ErrorNx( ex.msg )
 		End
 		
 	End

+ 1 - 0
src/mx2cc/stmtexpr.monkey2

@@ -84,6 +84,7 @@ Class AssignStmtExpr Extends StmtExpr
 			If etype
 				lhs=lhs.RemoveSideEffects( block )
 				Local t:=New BinaryopExpr( op.Slice( 0,-1 ),New ValueExpr( lhs,srcpos,endpos ),Self.rhs,srcpos,endpos )
+				t.srcfile=srcfile
 				rhs=t.Semant( block )
 				op="="
 			Endif

+ 4 - 32
src/mx2cc/test.monkey2

@@ -1,36 +1,8 @@
-Namespace myapp
 
-#Import "<std>"
-#Import "<mojo>"
-
-Using std..
-Using mojo..
-
-Class MyWindow Extends Window
-
-	Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )
-
-		Super.New( title,width,height,flags )
-		
-		New Fiber( Lambda()
-			Print "HERE"
-		End )
-	End
-
-	Method OnRender( canvas:Canvas ) Override
-	
-		App.RequestRender()
-	
-		canvas.DrawText( "Hello World!",Width/2,Height/2,.5,.5 )
-	End
-	
-End
+#Import "test2
 
 Function Main()
-
-	New AppInstance
 	
-	New MyWindow
-	
-	App.Run()
-End
+	Test()
+
+End

+ 2 - 7
src/mx2cc/test2.monkey2

@@ -1,9 +1,4 @@
 
-Global c:C
-
-Class C
-End
-
-Function F( c:C )
-	Print "F()!"
+Function Test()
+	InternalTest()
 End

+ 5 - 1
src/mx2cc/translator_cpp.monkey2

@@ -1871,7 +1871,11 @@ Class Translator_CPP Extends Translator
 
 		If etype t="int("+t+")"
 		
-		t=op+t
+		If (op="+" Or op="-") And t.StartsWith( op )	'deal with -- and ++
+			t=op+"("+t+")"
+		Else
+			t=op+t
+		Endif
 		
 		If etype t=EnumName( etype )+"("+t+")"
 		

+ 11 - 10
src/mx2cc/value.monkey2

@@ -76,19 +76,19 @@ Class Value Extends SNode
 	
 	Function CheckAccess( decl:Decl,scope:Scope,tscope:Scope )
 	
+		If decl.IsInternal
+			If scope.FindFile().fdecl.module=tscope.FindFile().fdecl.module Return
+
+			Throw New SemantEx( "Internal declaration '"+decl.ident+"' cannot be accessed from here." )
+		Endif
+			
 		If decl.IsPublic Return
-		
+
 		Local cscope:=Cast<ClassScope>( scope )
 		If cscope
-		
+			
 			If scope.FindFile()=tscope.FindFile() Return
 
-			If decl.IsInternal
-				If scope.FindFile().fdecl.module=tscope.FindFile().fdecl.module Return
-
-				Throw New SemantEx( "Internal member '"+decl.ident+"' cannot be accessed from different module" )
-			Endif
-
 			Local ctype:=cscope.ctype
 			Local ctype2:=tscope.FindClass()
 			
@@ -96,7 +96,7 @@ Class Value Extends SNode
 			
 				If ctype=ctype2 Return
 				
-				Throw New SemantEx( "Private member '"+decl.ident+"' cannot be accessed from here" )
+				Throw New SemantEx( "Private member '"+decl.ident+"' cannot be accessed from here." )
 				
 			Else If decl.IsProtected
 			
@@ -105,7 +105,8 @@ Class Value Extends SNode
 					ctype2=ctype2.superType
 				Wend
 				
-				Throw New SemantEx( "Protected member '"+decl.ident+"' cannot be accessed from here" )
+				Throw New SemantEx( "Protected member '"+decl.ident+"' cannot be accessed from here." )
+
 			Endif
 
 		Endif

+ 1 - 1
src/ted2go/document/Monkey2Document.monkey2

@@ -18,7 +18,7 @@ Function InitKeywords()
 
 	Local kws:=""
 	kws+="Namespace;Using;Import;Extern;"
-	kws+="Public;Private;Protected;Friend;"
+	kws+="Public;Private;Protected;Internal;Friend;"
 	kws+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;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;"

+ 1 - 1
src/ted2go/syntax/Monkey2Keywords.monkey2

@@ -21,7 +21,7 @@ Class Monkey2Keywords Extends KeywordsPlugin
 	Method GetInternal:String() Override
 		Local s:=""
 		s+="Namespace;Using;Import;Extern;"
-		s+="Public;Private;Protected;Friend;"
+		s+="Public;Private;Protected;Internal;Friend;"
 		s+="Void;Bool;Byte;UByte;Short;UShort;Int;UInt;Long;ULong;Float;Double;String;CString;Variant;TypeInfo;DeclInfo;Object;Continue;Exit;"
 		s+="New;Self;Super;Eachin;True;False;Null;Where;"
 		s+="Alias;Const;Local;Global;Field;Method;Function;Property;Getter;Setter;Operator;Lambda;"

+ 0 - 0
src/ted2go/utils/jsonutils.monkey2 → src/ted2go/utils/JsonUtils.monkey2