[CCC DEV] FFI
Mathias Spiessens
mathias.spiessens at student.kuleuven.be
Mon Mar 12 08:45:59 GMT 2012
Hi all,
I have problems calling a function form the foreign function interface.
This is my FFI:
int _ffi_print(ECTX ectx, WORD args[])
{
printf("INFO: ffi.print called.\n");
char* str = (char*)args[0];
int len = args[1];
int pos = 0;
char buffer[256];
while(pos < len)
{
buffer[pos] = str[pos++];
}
buffer[len] = '\0';
printf(buffer);
return SFFI_OK;
}
SFFI_FUNCTION sffi_table[] = {_ffi_print};
const int sffi_table_length = sizeof(sffi_table) / sizeof(SFFI_FUNCTION);
This is a small test in occam:
-- Occam process to interface with the the print function from the
foreign function interface (FFI).
#PRAGMA EXTERNAL "PROC C.tvmspecial.0.ffi.print (VAL []BYTE buffer) = 0"
INLINE PROC write.screen (VAL []BYTE buffer)
C.tvmspecial.0.ffi.print (buffer)
:
PROC main ()
SEQ
write.screen("INFO: Test!")
:
I've followed the example of the nxt wrapper. In a paper about the FFI
another naming convention was mentioned, without the "tvmspecial.0" yet
in another paper a leading "__" is mentioned.
Anyway none of these naming conventions seem to work.
Am I overlooking something?
Best regards,
Mathias
More information about the developers
mailing list