Hi,
Sorry but this will not work :(
There are two reasons… this is the output of IA32FFIPlugin:
void* IA32FFIPlugin_exports[][3] = { {"IA32FFIPlugin", "ffiLogCallsTo", (void*)ffiLogCallsTo}, {"IA32FFIPlugin", "getModuleName", (void*)getModuleName}, {"IA32FFIPlugin", "initialiseModule", (void*)initialiseModule}, {"IA32FFIPlugin", "primitiveCallout\000\002", (void*)primitiveCallout}, {"IA32FFIPlugin", "primitiveCalloutWithArgs\000\004", (void*)primitiveCalloutWithArgs}, {"IA32FFIPlugin", "primitiveCreateManualSurface\000\000", (void*)primitiveCreateManualSurface}, {"IA32FFIPlugin", "primitiveDestroyManualSurface\000\000", (void*)primitiveDestroyManualSurface}, {"IA32FFIPlugin", "primitiveFFIAllocate\000\001", (void*)primitiveFFIAllocate}, {"IA32FFIPlugin", "primitiveFFIDoubleAt\000\001", (void*)primitiveFFIDoubleAt}, {"IA32FFIPlugin", "primitiveFFIDoubleAtPut\000\001", (void*)primitiveFFIDoubleAtPut}, {"IA32FFIPlugin", "primitiveFFIFloatAt\000\001", (void*)primitiveFFIFloatAt}, {"IA32FFIPlugin", "primitiveFFIFloatAtPut\000\001", (void*)primitiveFFIFloatAtPut}, {"IA32FFIPlugin", "primitiveFFIFree\000\001", (void*)primitiveFFIFree}, {"IA32FFIPlugin", "primitiveFFIGetLastError\000\377", (void*)primitiveFFIGetLastError}, {"IA32FFIPlugin", "primitiveFFIIntegerAt\000\001", (void*)primitiveFFIIntegerAt}, {"IA32FFIPlugin", "primitiveFFIIntegerAtPut\000\001", (void*)primitiveFFIIntegerAtPut}, {"IA32FFIPlugin", "primitiveForceLoad\000\002", (void*)primitiveForceLoad}, {"IA32FFIPlugin", "primitiveLoadSymbolFromModule\000\002", (void*)primitiveLoadSymbolFromModule}, {"IA32FFIPlugin", "primitiveLogCallsTo\000\000", (void*)primitiveLogCallsTo}, {"IA32FFIPlugin", "primitiveSetManualSurfacePointer\000\000", (void*)primitiveSetManualSurfacePointer}, {"IA32FFIPlugin", "setInterpreter", (void*)setInterpreter}, {NULL, NULL, NULL} };
So, this:
# define IA32FFIPlugin_exports SqueakFFIPrims_exports
will just change the exports variable, but not the “IA32FFIPlugin” string… and defining:
# define IA32FFIPlugin SqueakFFIPrims
will not work either because preprocessor does not works inside strings :(
how can we fix this?
Esteban
On 23 Feb 2016, at 17:31, commits@source.squeak.org wrote:
Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1694.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1694 Author: eem Time: 23 February 2016, 9:30:35.750871 am UUID: e1381bbc-a5af-4a35-ac60-a739611c7e0e Ancestors: VMMaker.oscog-eem.1693
Fix compilation of ThreadedFFIPlugin subclasses as internal plugins.
=============== Diff against VMMaker.oscog-eem.1693 ===============
Item was changed: ----- Method: ThreadedFFIPlugin class>>generateCodeStringForPrimitives (in category 'translation') ----- generateCodeStringForPrimitives "Output a skeletal SqueakFFIPrims.c that includes the relevant FooFFIPlugin.c for each subclass based on the identifyingPredefinedMacros the subclass defines."
^String streamContents: [:s| s nextPutAll: '/* Automatically generated by\ ' withCRs. s nextPutAll: (CCodeGenerator monticelloDescriptionFor: self). s cr; nextPutAll: ' */'. s cr; cr; nextPut: $#. (self allSubclasses sort: [:a :b| a name < b name]) do: [:class | class identifyingPredefinedMacros ifNotNil: [:predefinedMacros| s nextPutAll: 'if '. class includingPredefinedMacros ifNotNil: [:includingMacros| includingMacros do: [:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPutAll: ') && ']. s nextPut: $(]. class excludingPredefinedMacros ifNotNil: [:excludingMacros| excludingMacros do: [:predefinedMacro| s nextPutAll: '!!defined('; nextPutAll: predefinedMacro; nextPutAll: ') && ']. s nextPut: $(]. predefinedMacros do: [:predefinedMacro| s nextPutAll: 'defined('; nextPutAll: predefinedMacro; nextPut: $)] separatedBy: [s nextPutAll: ' || ']. class excludingPredefinedMacros ifNotNil: [s nextPut: $)]. class includingPredefinedMacros ifNotNil: [s nextPut: $)].
s cr; cr; nextPutAll: '# define '; nextPutAll: class moduleName; nextPutAll: '_exports ';
nextPutAll: self moduleName; nextPutAll: '_exports'.
s cr; nextPutAll: '# include "'; nextPutAll: class moduleName; nextPutAll: '.c"'.
s nextPutAll: 'se'. #( 'As yet no FFI implementation appears to exist for your platform.' 'Consider implementing it, starting by adding a subclass of ThreadedFFIPlugin.') do:s cr; cr; nextPutAll: '# include "'; nextPutAll: class moduleName; nextPutAll: '.c"'. s cr; cr; nextPutAll: '#el']].
[:msg| s cr; nextPutAll: '# error '; nextPutAll: msg].
s cr; nextPutAll: '#endif'; cr]![:msg| s cr; nextPutAll: '# error '; nextPutAll: msg].
On 24 Feb 2016, at 12:31, Esteban Lorenzano estebanlm@gmail.com wrote:
Hi!
# define IA32FFIPlugin SqueakFFIPrims
will not work either because preprocessor does not works inside strings :(
I don't know the context but the classic is a "stringify" macro
echo '#define STRINGIFY1(x...) #x
#define STRINGIFY(x) STRINGIFY1(x) const char* = STRINGIFY(MYPLACE);' | cc - -E -DMYPLACE=BLABLABLA
# 1 "<stdin>" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 325 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "<stdin>" 2
const char* = "BLABLABLA";
I don’t think this will work… AFAIK stringify is to convert macro arguments into strings… we need to replace the contents of a string. … but I’m not cpp expert so I might be wrong…
Esteban
On 24 Feb 2016, at 15:55, Holger Freyther holger@freyther.de wrote:
On 24 Feb 2016, at 12:31, Esteban Lorenzano estebanlm@gmail.com wrote:
Hi!
# define IA32FFIPlugin SqueakFFIPrims
will not work either because preprocessor does not works inside strings :(
I don't know the context but the classic is a "stringify" macro
echo '#define STRINGIFY1(x...) #x
#define STRINGIFY(x) STRINGIFY1(x) const char* = STRINGIFY(MYPLACE);' | cc - -E -DMYPLACE=BLABLABLA
# 1 "<stdin>" # 1 "<built-in>" 1 # 1 "<built-in>" 3 # 325 "<built-in>" 3 # 1 "<command line>" 1 # 1 "<built-in>" 2 # 1 "<stdin>" 2
const char* = "BLABLABLA";
On 24 Feb 2016, at 16:06, Esteban Lorenzano estebanlm@gmail.com wrote:
I don’t think this will work… AFAIK stringify is to convert macro arguments into strings… we need to replace the contents of a string. … but I’m not cpp expert so I might be wrong…
Can't you generate the table as:
void* IA32FFIPlugin_exports[][3] = { {STRINGIFY(IA32FFIPlugin), "ffiLogCallsTo", (void*)ffiLogCallsTo}, {STRINGIFY(IA32FFIPlugin), "getModuleName", (void*)getModuleName},
?
no, I cannot… if anyone can, it is Eliot :)
(but in case we replace strings for macros, we do not need the stringify :)
On 24 Feb 2016, at 16:11, Holger Freyther holger@freyther.de wrote:
On 24 Feb 2016, at 16:06, Esteban Lorenzano estebanlm@gmail.com wrote:
I don’t think this will work… AFAIK stringify is to convert macro arguments into strings… we need to replace the contents of a string. … but I’m not cpp expert so I might be wrong…
Can't you generate the table as:
void* IA32FFIPlugin_exports[][3] = { {STRINGIFY(IA32FFIPlugin), "ffiLogCallsTo", (void*)ffiLogCallsTo}, {STRINGIFY(IA32FFIPlugin), "getModuleName", (void*)getModuleName},
?
On Wed, Feb 24, 2016 at 7:11 AM, Holger Freyther holger@freyther.de wrote:
On 24 Feb 2016, at 16:06, Esteban Lorenzano estebanlm@gmail.com wrote:
I don’t think this will work… AFAIK stringify is to convert macro
arguments into strings… we need to replace the contents of a string.
… but I’m not cpp expert so I might be wrong…
Can't you generate the table as:
void* IA32FFIPlugin_exports[][3] = { {STRINGIFY(IA32FFIPlugin), "ffiLogCallsTo", (void*)ffiLogCallsTo}, {STRINGIFY(IA32FFIPlugin), "getModuleName", (void*)getModuleName},
?
Yes. This is nice. Esteban, give me a while and I'll fix this. For now, you can compile the plugin as an external plugin.
_,,,^..^,,,_ best, Eliot
yes, thanks :)
On 24 Feb 2016, at 17:22, Eliot Miranda eliot.miranda@gmail.com wrote:
On Wed, Feb 24, 2016 at 7:11 AM, Holger Freyther <holger@freyther.de mailto:holger@freyther.de> wrote:
On 24 Feb 2016, at 16:06, Esteban Lorenzano <estebanlm@gmail.com mailto:estebanlm@gmail.com> wrote:
I don’t think this will work… AFAIK stringify is to convert macro arguments into strings… we need to replace the contents of a string. … but I’m not cpp expert so I might be wrong…
Can't you generate the table as:
void* IA32FFIPlugin_exports[][3] = { {STRINGIFY(IA32FFIPlugin), "ffiLogCallsTo", (void*)ffiLogCallsTo}, {STRINGIFY(IA32FFIPlugin), "getModuleName", (void*)getModuleName},
?
Yes. This is nice. Esteban, give me a while and I'll fix this. For now, you can compile the plugin as an external plugin.
_,,,^..^,,,_ best, Eliot
vm-dev@lists.squeakfoundation.org