enhanced LONGLONG argument handling in mod/ffi.c
This commit is contained in:
		@ -35,7 +35,7 @@ class FFI(Object)
 | 
			
		||||
 | 
			
		||||
		x := self.ffi open(name).
 | 
			
		||||
		//(x isError) ifTrue: [^x].
 | 
			
		||||
		if (x isError) { FFIException signal: ('Unable to open %s' strfmt(name)) }.
 | 
			
		||||
		if (x isError) { FFIException signal: ('Unable to open %O' strfmt(name)) }.
 | 
			
		||||
 | 
			
		||||
		^self.
 | 
			
		||||
	}
 | 
			
		||||
@ -51,7 +51,7 @@ class FFI(Object)
 | 
			
		||||
 | 
			
		||||
		/* f := self.funcs at: name ifAbsent: [ 
 | 
			
		||||
			f := self.ffi getsym(name).
 | 
			
		||||
			if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
 | 
			
		||||
			if (f isError) { FFIException signal: ('Unable to find %O' strfmt(name)) }.
 | 
			
		||||
			self.funcs at: name put: f.
 | 
			
		||||
			f. // need this as at:put: returns an association
 | 
			
		||||
		]. */
 | 
			
		||||
@ -60,12 +60,12 @@ class FFI(Object)
 | 
			
		||||
		if (f isNil)
 | 
			
		||||
		{
 | 
			
		||||
			f := self.ffi getsym(name).
 | 
			
		||||
			if (f isError) { FFIException signal: ('Unable to find %s' strfmt(name)) }.
 | 
			
		||||
			if (f isError) { FFIException signal: ('Unable to find %O' strfmt(name)) }.
 | 
			
		||||
			self.funcs at: name put: f.
 | 
			
		||||
		}.
 | 
			
		||||
 | 
			
		||||
		rc := self.ffi call(f, sig, args).
 | 
			
		||||
		if (rc isError)	{ FFIException signal: ('Unable to call %s' strfmt(name)) }.
 | 
			
		||||
		if (rc isError)	{ FFIException signal: ('Unable to call %O' strfmt(name)) }.
 | 
			
		||||
 | 
			
		||||
		^rc.
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -390,14 +390,14 @@ static MOO_INLINE int add_ffi_arg (moo_t* moo, ffi_t* ffi, moo_ooch_t fmtc, int
 | 
			
		||||
			break;
 | 
			
		||||
 | 
			
		||||
		case FMTC_LONGLONG:
 | 
			
		||||
		#if (MOO_SIZEOF_LONG_LONG <= 0)
 | 
			
		||||
		#if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG)
 | 
			
		||||
			goto arg_as_long;
 | 
			
		||||
		#else
 | 
			
		||||
			if (_unsigned)
 | 
			
		||||
			{
 | 
			
		||||
				moo_oow_t v;
 | 
			
		||||
				moo_uintmax_t v;
 | 
			
		||||
				/* TODO: if (MOO_SIZEOF_LONG_LONG > MOO_SIZEOF_OOI_T) use moo_inttointmax() or something */
 | 
			
		||||
				if (moo_inttooow(moo, arg, &v) == 0) goto oops;
 | 
			
		||||
				if (moo_inttouintmax(moo, arg, &v) == 0) goto oops;
 | 
			
		||||
			#if defined(USE_DYNCALL)
 | 
			
		||||
				dcArgLongLong (ffi->dc, v);
 | 
			
		||||
			#elif defined(USE_LIBFFI)
 | 
			
		||||
@ -407,8 +407,8 @@ static MOO_INLINE int add_ffi_arg (moo_t* moo, ffi_t* ffi, moo_ooch_t fmtc, int
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				moo_ooi_t v;
 | 
			
		||||
				if (moo_inttoooi(moo, arg, &v) == 0) goto oops;
 | 
			
		||||
				moo_intmax_t v;
 | 
			
		||||
				if (moo_inttointmax(moo, arg, &v) == 0) goto oops;
 | 
			
		||||
			#if defined(USE_DYNCALL)
 | 
			
		||||
				dcArgLongLong (ffi->dc, v);
 | 
			
		||||
			#elif defined(USE_LIBFFI)
 | 
			
		||||
@ -671,7 +671,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
 | 
			
		||||
 | 
			
		||||
		case FMTC_LONGLONG:
 | 
			
		||||
		{
 | 
			
		||||
		#if (MOO_SIZEOF_LONG_LONG <= 0)
 | 
			
		||||
		#if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_LONG)
 | 
			
		||||
			goto ret_as_long;
 | 
			
		||||
		#else
 | 
			
		||||
			moo_oop_t r;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user