[Scilab-Dev] Hijacking built-in "set" almost works...
Samuel Gougeon
sgougeon at free.fr
Thu Mar 1 23:44:51 CET 2018
Le 01/03/2018 à 23:26, Stéphane Mottelet a écrit :
> Le 01/03/2018 à 21:57, Stéphane Mottelet a écrit :
>> Hello,
>>
>>> Le 1 mars 2018 à 20:18, Samuel Gougeon <sgougeon at free.fr> a écrit :
>>>
>>>> Le 01/03/2018 à 20:09, Stéphane Mottelet a écrit :
>>>> Hello,
>>>>
>>>> I have tried to implement a (naïve) hijacking mechanism that works
>>>> *like a charm* under scilab 5.5.2:
>>>>
>>>> newfun('scilab_set',funptr('set'));
>>>> clearfun('set');
>>>> function set(varargin)
>>>> scilab_set(varargin(:))
>>>> printf("...\n")
>>>> endfunction
>>>> // test the hijacked "set"
>>>> f=gcf()
>>>> set(f,"tag","1")
>>>> f.tag="2"
>>>>
>>>> When I test this under 6.0.0 or 6.0.1, the last line always
>>>> crashes Scilab. Is there an evident reason why ? When trying this
>>>> on the command line (scilab -nw)
>>>>
>>>>> --> set(f,"tag","1")
>>>>> ...
>>>>>
>>>>> --> f.tag="2"
>>>>> ...
>>>>> /Applications/scilab-6.0.1.app/Contents/MacOS/bin/scilab: line
>>>>> 972: 27117 Illegal instruction: 4 "$SCILABBIN" "$@"
>>>> I can see that the problem occurs *after* the insertion code
>>>> f.tag="2" has delegated the operation to the hijacked "set", hence
>>>> the crash occurs in the built-in function which does the insertion.
>>>> In order to understand why this crash occurs (under Linux or OSX),
>>>> I would like to know which module is in charge of the insertion for
>>>> handles (a kind of %h_i but built-in) ?
>>> You may have a look at
>>> SCI\modules\graphic_objects\src\cpp\setGraphicObjectProperty.cpp
>>> and
>>> SCI\modules\graphic_objects\src\java\org\scilab\modules\graphic_objects\*
>>>
>> Hmm, the crash occurs *after* the property has been set. So my
>> question was rather about the generic code that handles field
>> insertion, which is delegated to “set” for handles.
>>
>> S.
>>
>
> I have localized many methods for handle type in
> modules/ast/src/cpp/types/graphichandle.cpp. Although I don't know
> much of C++, I can see that GraphicHandle::invoke is delegated to the
> overloaded %h_e macro, hence is an extraction method, but I am not
> able to find any *insertion* method in this file. Maybe someone knows ?
Maybe
edit generic_i_h
More information about the dev
mailing list