1. Wrapper Help
- Posted by Icy_Viking May 19, 2017
- 1313 views
I am working on my Irrlicht wrapper. So far, it is coming along well. However I am having an issue when trying to call string related functions.
In C you would do this.
C Code
irrIrrlichtDeviceSetWindowsCaption(L"01.HelloWorld");
Eu Wrapper Code
public constant xirrIrrlichtDeviceSetWindowCaption = define_c_proc(irr,"irrIrrlichtDeviceSetWindowCaption",{C_POINTER}) public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) atom str = allocate_string(strw,1) c_proc(xirrIrrlichtDeviceSetWindowCaption,{str}) end procedure
Test
include std/machine.e include EuIrr.ew constant TRUE = 1, FALSE = 0 atom dims = irrDimension2duNew(800,600) atom campos = irrVector3dfNew(0,30,-40) atom camat = irrVector3dfNew(0,5,0) atom driver,scene,gui atom col = irrSColorNew(100,0,100,0) irrCreateDevice(dims,FALSE,TRUE,FALSE) driver = irrIrrlichtDeviceGetVideoDriver() scene = irrIrrlichtDeviceGetSceneManager() gui = irrIrrlichtDeviceGetGUIEnviroment() irrIrrlichtDeviceSetWindowsCaption("Hello World")
The error that comes up is type_check failure, strw is {72,101,108,108,111,32,87,111,114,108,100} Perhaps I need to make a machine call of some sort? Any help is appericated.
2. Re: Wrapper Help
- Posted by ne1uno May 19, 2017
- 1292 views
guessing change public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) to public procedure irrIrrlichtDeviceSetWindowCaption(object strw)
3. Re: Wrapper Help
- Posted by Icy_Viking May 19, 2017
- 1299 views
guessing change public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) to public procedure irrIrrlichtDeviceSetWindowCaption(object strw)
OK I got it to work. The C wrapper has a lot of weird typos and whatnot. I had to do this.
public constant xirrIrrlichtDeviceSetWindowsCaption = define_c_proc(irr,"irrIrrlichtDeviceSetWindowsCaption",{C_POINTER}) public procedure irrIrrlichtDeviceSetWindowsCaption(sequence strw) atom str = allocate_string(strw,1) c_proc(xirrIrrlichtDeviceSetWindowsCaption,{str}) end procedure
there is an 's' after Window. However when running the program I get ?????dltFont in the title bar. Not sure if it is handling the string correctly.
4. Re: Wrapper Help
- Posted by ne1uno May 19, 2017
- 1308 views
guessing change public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) to public procedure irrIrrlichtDeviceSetWindowCaption(object strw)
OK I got it to work. The C wrapper has a lot of weird typos and whatnot. I had to do this.
public constant xirrIrrlichtDeviceSetWindowsCaption = define_c_proc(irr,"irrIrrlichtDeviceSetWindowsCaption",{C_POINTER}) public procedure irrIrrlichtDeviceSetWindowsCaption(sequence strw) atom str = allocate_string(strw,1) c_proc(xirrIrrlichtDeviceSetWindowsCaption,{str}) end procedure
there is an 's' after Window. However when running the program I get ?????dltFont in the title bar. Not sure if it is handling the string correctly.
this one? http://irrlicht.sourceforge.net/?page_id=45
is it c or c++? usually what you have to do with c++ is create a c shim that talks to the lib and you wrap the c shim from euphoria. you might be dealing with some unicode and codepage issues too. like wrapping isn't hard enough, there ought to be a law
- edit, looked it up in your other post, this one is the c shim https://github.com/diaes256/clirrlicht
5. Re: Wrapper Help
- Posted by Icy_Viking May 19, 2017
- 1304 views
guessing change public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) to public procedure irrIrrlichtDeviceSetWindowCaption(object strw)
OK I got it to work. The C wrapper has a lot of weird typos and whatnot. I had to do this.
public constant xirrIrrlichtDeviceSetWindowsCaption = define_c_proc(irr,"irrIrrlichtDeviceSetWindowsCaption",{C_POINTER}) public procedure irrIrrlichtDeviceSetWindowsCaption(sequence strw) atom str = allocate_string(strw,1) c_proc(xirrIrrlichtDeviceSetWindowsCaption,{str}) end procedure
there is an 's' after Window. However when running the program I get ?????dltFont in the title bar. Not sure if it is handling the string correctly.
this one? http://irrlicht.sourceforge.net/?page_id=45
is it c or c++? usually what you have to do with c++ is create a c shim that talks to the lib and you wrap the c shim from euphoria. you might be dealing with some unicode and codepage issues too. like wrapping isn't hard enough, there ought to be a law
- edit, looked it up in your other post, this one is the c shim https://github.com/diaes256/clirrlicht
Yes I am using that C wrapper as the basis for the Euphoria wrapper.
6. Re: Wrapper Help
- Posted by petelomax May 19, 2017
- 1247 views
atom str = allocate_string(strw,1)
However when running the program I get ?????dltFont in the title bar. Not sure if it is handling the string correctly.
Have you tried allocate_wstring()?
Pete
7. Re: Wrapper Help
- Posted by Icy_Viking May 19, 2017
- 1263 views
atom str = allocate_string(strw,1)
However when running the program I get ?????dltFont in the title bar. Not sure if it is handling the string correctly.
Have you tried allocate_wstring()?
Pete
It worked! Thanks Pete!