Hey guys,
is there anyone who has created a wrapper for both AngelScript and/or Squirrel to be used in PureBasic?
Binding for AngelScript or Squirrel
Re: Binding for AngelScript or Squirrel
Hm...
4 years ago I gave some hints about squirrel:
https://www.purebasic.fr/english/viewto ... 33#p486633
4 years ago I gave some hints about squirrel:
https://www.purebasic.fr/english/viewto ... 33#p486633
Re: Binding for AngelScript or Squirrel
dofile works, but compile still fails.
Code: Select all
ImportC "squirrel.lib"
sq_open.i(stacksize.l)
sq_pop(*vm, nelementstoppop.l)
sq_close(*vm)
sq_pushroottable(*vm)
sq_pushstring(*vm, f.p-UTF8, len.l)
sq_get(*vm, idx.l)
sq_pushinteger(*vm, ni.l)
sq_pushfloat(*vm, nf.f)
sq_call.i(*vm, param.l, retval.l, raiseerror.l)
sq_compile.i(*vm, *ReadFunc, parameter.i, sourcename.p-UTF8, raiseerror.l)
sq_setcompilererrorhandler(*vm, *ErrorFunc)
sq_setprintfunc(*vm, *PrintFunc, *ErrorFunc)
EndImport
ImportC "sqstdlib.lib"
sqstd_dofile(*vm, filename.p-UTF8, retval.l, printerror.l)
sqstd_loadfile(*vm, filename.p-UTF8, printerror.l)
EndImport
ProcedureC ErrorFunc(*vm, *desc, *source, line.i, column.i)
Debug PeekS(*desc, -1, #PB_UTF8)
Debug PeekS(*source, -1, #PB_UTF8) + " line: " + Str(line) + " col: " + Str(column)
EndProcedure
ProcedureC PrintFunc(*vm, *s, *a)
Debug PeekS(*s, -1, #PB_UTF8)
Debug PeekS(*a, -1, #PB_UTF8)
EndProcedure
ProcedureC.a GetCharFileFunc(hFile.i)
Protected Byte.a
ReadData(hFile, @Byte, 1)
;Debug RSet(Hex(Byte), 2, "0") + " " + Chr(Byte)
ProcedureReturn Byte
EndProcedure
Define hFile.i
*vm = sq_open(10240)
If *vm
sq_setcompilererrorhandler(*vm, @ErrorFunc())
sq_setprintfunc(*vm, @PrintFunc(), #Null)
Debug sq_pushroottable(*vm)
hFile = ReadFile(#PB_Any, "HelloWorld.nut")
If hFile
Debug sq_compile(*vm, @GetCharFileFunc(), hFile, "HelloWorld.nut", #True)
CloseFile(hFile)
;
Debug sqstd_dofile(*vm, "HelloWorld.nut", #False, #True)
;Debug sqstd_dofile(*vm, "compileError.nut", #False, #True)
;
; Debug sq_pushstring(*vm, "foo", -1)
; Debug sq_get(*vm, -2)
; Debug sq_pushinteger(*vm, 1)
; Debug sq_pushfloat(*vm, 2.0)
; Debug sq_pushstring(*vm, "three", -1)
; Debug sq_call(*vm, 4, #False, #True)
Debug sq_pop(*vm, 1)
EndIf
sq_close(*vm)
EndIf
Re: Binding for AngelScript or Squirrel
Nice to see that you have been working on this.
Are you trying to use the static library? Because I had similar problems when I tried to link against the static library of AngelScript. I was able to trace it back to the standard C/C++ string library and had to apply changes to the AngelScript source code in order to make it work. However, I was not happy with that solution as would like to use it as it is.
Are you trying to use the static library? Because I had similar problems when I tried to link against the static library of AngelScript. I was able to trace it back to the standard C/C++ string library and had to apply changes to the AngelScript source code in order to make it work. However, I was not happy with that solution as would like to use it as it is.
Re: Binding for AngelScript or Squirrel
I was able to run your code with with the dynamic lib/dll of Squirrel...infratec wrote:dofile works, but compile still fails.
Output from the debugger:
Code: Select all
4750208
0
%s
Hello World!
1
863838721
Code: Select all
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_MSC_VER=1900'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=0'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:RuntimeLibrary=MD_DynamicRelease'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_MSC_VER=1900'; ignored.
POLINK: warning: Unrecognized option '/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=0'; ignored.
...
POLINK: fatal error: 8 unresolved external(s).
Et cetera is my worst enemy