1. Wrapper Help

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.

new topic     » topic index » view message » categorize

2. Re: Wrapper Help

guessing change 
public procedure irrIrrlichtDeviceSetWindowCaption(atom strw) 
to 
public procedure irrIrrlichtDeviceSetWindowCaption(object strw) 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Wrapper Help

ne1uno said...
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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Wrapper Help

Icy_Viking said...
ne1uno said...
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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Wrapper Help

ne1uno said...
Icy_Viking said...
ne1uno said...
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

Yes I am using that C wrapper as the basis for the Euphoria wrapper.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Wrapper Help

Icy_Viking said...
 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

new topic     » goto parent     » topic index » view message » categorize

7. Re: Wrapper Help

petelomax said...
Icy_Viking said...
 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!

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu