Slang: Suppressing 'static' declarations
Stephan Rudlof
sr at evolgo.de
Fri Jan 13 20:56:45 UTC 2006
Hello Eddie,
On 13.01.2006 06:15, Eddie Cottongim wrote:
> Thanks Stephan. I tried using a header file and this worked. However, it
> means I have to remove the Plugin's variable declarations so the
> translator doesn't generate a definition for them, which in turn means
> that I can't reference them from Slang at all (can only use cCode). I
> might try hacking the CCodeGenerator to put out the extern more directly.
A workaround:
- define the static Plugin's variables as before, but with another name
as the extern ones (rename the vars in one of these sets), and then
- assign the extern to the static ones and vice versa via
self cCode: 'pluginVar = externVar;'
self cCode: 'externVar = pluginVar;'
or
self cCode: 'ptrToExternVar = &externVar;'
.
Then the hacked code is small and you are able to use Slang vars.
Regards,
Stephan
>
> Eddie
>
> Stephan Rudlof wrote:
>
>
>>Some refinements:
>>
>>On 12.01.2006 20:20, I wrote:
>>
>>
>>
>>>Hello Eddie,
>>>
>>>there is Object>>cCode: or Object>>cCode:inSmalltalk:, see e.g.
>>> RePlugin>>allocateByteArrayAndSetRcvrPCREPtrFromPCRE: aPCREPtr
>>>for an example. With these constructs you can inject arbitrary C code
>>>into the generated C code.
>>>
>>>
>>
>>
>>
>>
>>>In RePlugin>>declareCVarsIn:
>>>
>>>
>>
>>You should look into the corresponding Category to see what you have to
>>do else.
>>
>>
>>
>>
>>>you can see how to declare a header file,
>>>there is the line
>>> cg addHeaderFile:'"rePlugin.h"'.
>>>; this header file is located in dir
>>> SomeBaseDir/platforms/Cross/plugins/RePlugin/
>>>
>>>
>>
>>
>>
>>
>>>You could put the extern vars into a respective header file.
>>>
>>>
>>
>>should be: You could put the *declarations* of the extern vars
>>(definitions being in some *.c file) into a respective header file.
>>
>>Stephan
>>
>>
>
>
>
>
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|