help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Correct way to throw exceptions/errors from C to ST


From: Roland Plüss
Subject: Re: [Help-smalltalk] Correct way to throw exceptions/errors from C to ST
Date: Sun, 05 Apr 2015 17:47:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0


On 04/05/2015 08:06 AM, Paolo Bonzini wrote:
>
> On 04/04/2015 02:50, Roland Plüss wrote:
>> Another something that I could not really figure out using the 
>> documentations. Let's say you have a CCallOut from ST to C. Inside
>> this C function something goes wrong, for example an invalid
>> argument passed. How do you properly raise an exception back to
>> Smalltalk? I tried doing something like this:
>>
>> gst_eval_code( "SystemExceptions.InvalidArgument new signal" );
>>
>> But this causes the VM to call abort since an exception happened
>> outside the bytecode. I assume you need to be more clever in this
>> case. So what is the correct way to throw these kinds of exceptions
>> from inside a C function?
> You return a C-style error and have a Smalltalk wrapper convert it to
> a Smalltalk exception.  Or you do argument checking in Smalltalk and
> the rest in C.
>
> Paolo
What you mean with "C-style error"? A C++ exception (that doesn't work
it looks like)? The cCall is of void return type so I can't return
anything. And smalltalk side can't check the arguments as the
information required to perform the checks is sometimes located deep
inside the engine code base.

-- 
Yours sincerely
Plüss Roland

Leader and Head Programmer
- Game: Epsylon ( http://www.indiedb.com/games/epsylon )
- Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine
, http://dragengine.rptd.ch/wiki )
- Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php )
- As well as various Blender export scripts und game tools

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]