[Vm-dev] nested structures with FFI?

Esteban Lorenzano estebanlm at gmail.com
Thu Aug 20 15:51:43 UTC 2015


I’m doing some tests with nested structures (to handle the conversion of NativeBoost-FFI to regular FFI) and I’m having some problems when accessing fields in the nested structure. 
For example, this tests: 

FFITestNestingStructure class>>#fieldsDesc 
	^ #(
		byte one;
		FFITestStructure nested;

FFITestStructure class>>#fieldsDesc
	^ #(
		byte byte;
		short short;
		long long;
		float float;
		double double;
		int64 int64;

(definition is NB-compatible, so do not take the differences with regular FFI into account)

	| s1 |
	s1 := FFITestNestingStructure new.
	s1 nested byte: 42.	
	self assert: s1 nested byte = 42

	| s1 |
	s1 := FFITestNestingStructure externalNew.
	self assert: s1 getHandle class = ExternalAddress.
	s1 nested byte: 42.	
	self assert: s1 nested byte = 42

fails always because 

s1 nested byte = 0. 

(which is obviously bad). 

I remember Eliot saying that structures with FFI was not being optimal, and I wonder (before start digging more in deep) if this could have something to do?


More information about the Vm-dev mailing list