Re: Wrapper Help Again

new topic     » goto parent     » topic index » view thread      » older message » newer message
Icy_Viking said...

Hello,

I am having some trouble wrapping the key codes for my Irrlicht wrapper.

C Code in Header File

I copied and pasted this part into a temp file, and used gcc -E on it (to only run the C preprocessor.

#ifndef CIRR_KEY_CODE 
  #define CIRR_KEY_CODE(x) CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_ ## x (); 
#endif 
 
 
 
CIRR_KEY_CODE(LBUTTON) 
CIRR_KEY_CODE(RBUTTON) 
CIRR_KEY_CODE(CANCEL) 
CIRR_KEY_CODE(MBUTTON) 
CIRR_KEY_CODE(XBUTTON1) 

It produced the following output:

CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_LBUTTON (); 
CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_RBUTTON (); 
CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_CANCEL (); 
CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_MBUTTON (); 
CIRR_API irr_EKEY_CODE irr_EKEY_CODE_KEY_XBUTTON1 (); 

So you'd have to wrap those. Each one looks like a separate function, so it looks like it is one function per C code to wrap. (ugh.)

Based on what you have here (and assuming it is 100% correct):

--Irr Key Code 
 
public constant xirrEKeyCodeEqual = define_c_func(irr,"irrEKeyCodeEqual",{C_POINTER,C_POINTER},C_BOOL) 
 
public function irrEKeyCodeEqual(atom code,atom code2) 
 
 return c_func(xirrEKeyCodeEqual,{code,code2}) 
	 
end function 

I reckon that one way to do the wrap would be like this:

public constant xirrEKeyCodeKeyCancel = define_c_func(irr,"irr_EKEY_CODE_KEY_CANCEL",{},C_POINTER) 
 
public function irrEKeyCodeKeyCancel() 
 
 return c_func(xirrEKeyCodeKeyCancel,{}) 
	 
end function 

There are ways you can significantly improve on this, mind you, but it's a start.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu