Pub.AngelScript

BlitzMax Forums/BlitzMax Module Tweaks/Pub.AngelScript

N(Posted 2005) [#1]
AngelScript module that -should- implement the classes correctly. So far I'm having trouble actually using AngelScript with BlitzMax, so if anyone wants to have a go at using (and making it work right) this, be my guest.

This uses the 2.1.0c version of AngelScript. You will need MinGW for this, obviously.

And I'd recommend downloading the AngelScript SDK, 'cause it has the documentation.

DOWNLOAD


Perturbatio(Posted 2005) [#2]
I get a 96k corrupt zip :\


N(Posted 2005) [#3]
Weird, but my FTP isn't letting me upload it all the way (definitely haven't reached the maximum for my FTP, so dunno). I'll try uploading it again in a bit, in the mean time, just wait 'til I say it's good.


N(Posted 2005) [#4]
Should be up now.


Perturbatio(Posted 2005) [#5]
yup, that's it


N(Posted 2005) [#6]
Quick test...

Strict

Local r:Int				' Result

Local engine:asIScriptEngine = asCreateScriptEngine( ANGELSCRIPT_VERSION )

Local codeString$ = "float global_var=0;void Add(){global_var++;if (global_var > 10)global_var = 0;}void Sub( ){	global_var--;if (global_var < 0)global_var = 10;}"
Local code:Byte Ptr = codeString.ToCString( )
Local size:Int = codeString.Length

r = engine.AddScriptSection( "module".ToCString( ), "section".ToCString( ), code, size, 0, 0 )
Assert r=0, "Failed to add script section"
engine.Build( "module".ToCString( ), Null )

Local s$

Repeat
	s = Input( ">" ).Trim( )
	If s.ToLower( ) = "q" Or s.ToLower( ) = "quit" Or s.ToLower( ) = "exit" Then Exit
	engine.ExecuteString( "module".ToCString( ), s.ToCString( ), Null, Null, 0 )
	Local gvar:Int = engine.GetGlobalVarIDByName( "module".ToCString( ), "global_var".ToCString( ) )
	Local pointer:Int
	engine.GetGlobalVarPtr( gvar, Byte Ptr Ptr(Varptr pointer) )
	Print( ( Float Ptr( pointer ) )[0] )
Forever

r = engine.Release_( )



AntonyWells(Posted 2005) [#7]
Did you ever get this working properly?

I tried the above example , it works, but adding a function always fails.

Import "angelscript.bmx"

Strict

Local r:Int' Result

Local engine:asIScriptEngine = asCreateScriptEngine( ANGELSCRIPT_VERSION )

Local codeString$ = "float global_var=0;void Add(){global_var++;if (global_var > 10)global_var = 0;}void Sub( ){global_var--;if (global_var < 0)global_var = 10;}"
Local code:Byte Ptr = codeString.ToCString( )
Local size:Int = codeString.Length

r = engine.AddScriptSection( "module".ToCString( ), "section".ToCString( ), code, size, 0, 0 )
Assert r=0, "Failed to add script section"
Type test
	Method multi()
	End Method
End Type
Local c:Test = New test

Local func:Byte Ptr = Byte Ptr( Sin )
engine.Build( "module".ToCString( ), Null )
Local gf = engine.registerGlobalFunction("float Sin(float)".tocstring(),func,asCALL_CDECL)
Assert gf=0,"Failed to register func :"+gf



Local s$

Repeat
s = Input( ">" ).Trim( )
If s.ToLower( ) = "q" Or s.ToLower( ) = "quit" Or s.ToLower( ) = "exit" Then Exit
engine.ExecuteString( "module".ToCString( ), s.ToCString( ), Null, Null, 0 )
Local gvar:Int = engine.GetGlobalVarIDByName( "module".ToCString( ), "global_var".ToCString( ) )
Local pointer:Int
engine.GetGlobalVarPtr( gvar, Byte Ptr Ptr(Varptr pointer) )
Print( ( Float Ptr( pointer ) )[0] )
Forever

r = engine.Release_( )


Function mult()

End Function



Your code but adds a global function and asserts it. Fails with -7 everytime here.


N(Posted 2005) [#8]
Don't know what's up with it and don't have the time to figure it out.

The module was never finished due to AngelScript just not being suited for use with BlitzMax.


TommyBear(Posted 2005) [#9]
Not to fear Noel... I'm working on an AngelScript module right now... looks very promising. Until then


AntonyWells(Posted 2006) [#10]
Any progress on your module Tommy?