In the other thread you suggested me to declare a primitive:
> [Smalltalk]
> Smalltalk cCall: 'setShader' withArguments: #(1)
> [C side]
> SYX_FUNC_PRIMITIVE(setShader)
> {
> SYX_PRIM_ARGS(1); /* ensure there's at least one parameter, it's optional */
> int type = SYX_SMALL_INTEGER (es->message_arguments[0]);
> shaders.current = type;
> return 1;
>
> }
> [Interpreting the smalltalk code]
> SyxOop process = syx_process_new ();
> SyxOop string = syx_string_new (CODE_TO_BE_INTERPRETED);
> SyxOop context = syx_send_unary_message (string, "doIt");
> syx_interp_enter_context (process, context);
> syx_process_execute_blocking (process);
And objects with code:
> Object subclass: #Application
> instanceVariableNames: ''!
>
> !Application methodsFor: 'primitives'
> shader: aValue
> <cCall: 'setShader'>
> ! !
> Then you can have a string to interpret like this:
> self shader: 1
That's in fact pretty much clean and nice.
I do the following, though i don't get whatthe es is, maybe I'm
missing that:
//Syx Primitives (Functions syx can call)
SYX_FUNC_PRIMITIVE(SyxSetShader)
{
//SYX_PRIM_ARGS(1); /* ensure there's at least one parameter,
it's optional */
int type = SYX_SMALL_INTEGER (es->message_arguments[0]);
shaders.current = type;
return 1;
}
and in
do-me.st I wrote the following code:
Object subclass: #Application
instanceVariableNames: ''!
!Application methodsFor: 'primitives'
shader: aValue
Smalltalk cCall: 'SyxSetShader' withArguments: #(1)!
! !
It gives me back the following error:
Unhandled exception... process is going to be terminated.
= An error occurred during program execution.
Traceback:
PrimitiveFailed(Signal)>>#signal
PrimitiveFailed class(Signal class)>>#signal
CompilerParser(Object)>>#primitiveFailed
CompilerParser>>#primParseChunk:startingAt:
CompilerParser>>#runMultipleAndDeclarations
FileStream>>#fileIn
FileStream class>>#fileIn:
is it that I am supposed to have an object somewhere? Did I make any
smalltalk mistake? Other examples works fine, so now the interpreter
is up and running on linux.
D.