Re: Quick question

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

Oh, well, I just used 32-bits because you were using C_INT, which is a 32-bit signed integer on all of euphoria's platforms. Though I see that we have a bug there for interpreter callbacks for 64-bit platforms (the interpreter version uses make_atom32 instead of make_atom). Also, %d doesn't seem to handle a 64-bit unsigned value.

I just pushed up a fix for the callback stuff. Now I can do:

include std/dll.e   
include std/machine.e 
 
atom signed_buffer = allocate( sizeof( C_POINTER ) ) 
 
function f( atom i )  
	printf( 1, "i = %g (#%x)\n", i )  
	poke_pointer( signed_buffer, i ) 
	ifdef BITS64 then 
		i = peek8s( signed_buffer ) 
	elsedef 
		i = peek4s( signed_buffer ) 
	end ifdef 
    printf( 1, "i = %d (#%x)\n", i )  
    return 0  
end function  
  
constant r_f  = routine_id( "f")  
printf( 1, "r_f = %d\n", {r_f} )  
  
constant cb_f = call_back( r_f )  
printf( 1, "cb_f = #%08x\n", {cb_f} )  
  
constant c_f = define_c_func( {}, cb_f, {C_POINTER}, E_INTEGER )  
printf( 1, "c_f = %d\n", {c_f} )  
  
? c_func( c_f, {-1} )  

Note that there isn't a signed peek for pointer sized integers, which makes this a little more verbose to handle that detail.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu