Re: Re: Re: Assertion name not printed when using rescue

Frantisek Fuka <[email protected]>
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
Thank you VERY MUCH. This seems understandable to me, I'll try it out
ASAP. However, in the meantime, I already updated to the latest
SmartEiffel TGZ from your website, because you told me so. Will this
solution still work? And, all of sudden, "sedb_breakpoint" does not
work ("unknown"). Should I go back to regular 2.1 version?

On Apr 5, 2005 12:39 PM, [email protected] <[email protected]> wrote:
> > I don't know what is "c_inline_c". I simply have a few methods like
> > this in my program:
> >
> > ncurses_initscr:POINTER is
> >    external "C" alias "initscr"
> >    end
> 
> > And then I have 'external_lib: "-lncurses"' in my .ace file. That's
> > all. This seems really nice to me because I just have to know the
> > parameters of C library function and nothing else about C/C++.
> 
> Not too bad.
> 
> > I looked at "tutorial/external" to see how C file can be included in
> > my program (this is where I got the above solution). I know that
> > closing ncurses from C is probably easy, just writing something like
> > "endwin()" but I have no idea how to write a C code and tell
> > SmartEiffel "Please call this code before you want to print a runtime
> > error message".
> 
> That's what I tried to explain but obviously I failed to be clear. I'll
> give you a solution bellow. I'll stick to the simplest solution which
> works with SmartEiffel 2.1.
> 
> 1- write some C code, yes, really
> 2- call this code from Eiffel
> 3- recompile your code
> 
> How to do that?
> 
> 1- open your favorite editor, and write a my_ncurses.h file (or whatever)
> and a my_ncurses.c file
> 
> --[my_ncurses.h]--8<--------
> #ifndef MY_NCURSES
> #define MY_NCURSES 1
> 
> #define my_ncurses_init _my_ncurses_init()
> void _my_ncurses_init(void);
> 
> #endif
> -------->8------------------
> 
> --[my_ncurses.c]--8<--------
> #include "my_ncurses.h"
> 
> static void my_ncurses_handler(se_handler_action_t action, void*data) {
>   switch(action) {
>   case SE_HANDLE_RUNTIME_ERROR:
>   case SE_HANDLE_NO_MORE_MEMORY:
>     /* some code here to stop ncurses */
>     break;
>   case SE_HANDLE_SEDB_BREAK:
>     /* some code here to suspend ncurses */
>     break;
>   case SE_HANDLE_SEDB_CONTINUE:
>     /* some code here to restart ncurses */
>     break;
>   default:
>     /* nothing */
>     break;
>   }
> }
> 
> void _my_ncurses_init(void) {
>   register_handler(my_ncurses_handler);
> }
> -------->8------------------
> 
> 2- From some Eiffel code, you must call this code, preferably in a once
> feature. A solution would be to create an object of the following class:
> 
> --[my_ncurses.e]--8<--------
> class MY_NCRUSES
> create {ANY}
>    make
> feature {}
>    make is
>       do
>          init
>       end
> 
>    init is
>       once
>          ncurses_initscr
>          ncurses_init
>       end
> 
>    ncurses_init is
>       external "C" alias "my_ncurses_init"
>       end
> 
>    ncurses_initscr:POINTER is
>       external "C" alias "initscr"
>       end
> end
> -------->8------------------
> 
> 3- the command line must have my_ncurses.c somewhere on it.
> 
> > Is this even the correct solution?
> 
> It is basically the *only* solution. There is some C code to write to shut
> down ncurses at the right moment. Using an external "C" or an external
> "plug_in" is not relevant here (sorry I confused you).
> 
> > Does it mean that when I use "rescue" the runtime error message is
> > always lost (not accessible in some sort of "exception" object)?
> 
> Yes. There is no object but a low-level C structure displayed by the
> runtime.
> 
> > So I must not use "rescue" at all and write some C plugin that
> > somehow gets executed before the error message is printed and shuts
> > down the ncurses? What if this plugin is called because of the error
> > that occured before the ncurses was even initialized?
> 
> Keep cool. If you do as I explained above, the SmartEiffel runtime will
> call the handler above when an error occurs and correctly shut ncurses
> down.
> 
> > I know these may seem like stupid questions to you.
> 
> Not at all. They just show the lack of documentation, that's our biggest
> flaw :-(
> 
> > I'd really like to find this out alff of this myself but I cannot find
> > any useful documentation about SmartEiffel. I have only the tutorials
> > from eiffel.com. I now know the basics of the language and I can use it
> > AND call C libraries from it, which seems really nice to me.
> 
> Don't bother to look at eiffel.com, their compiler does not work at all as
> ours. The SmartEiffel site is http://SmartEiffel.loria.fr
> 
> Some tutorials are provided in our SmartEiffel release (look for the
> "tutorial" directory).
> 
> Hope it helps,
> 
> Best regards,
> --
> Cyril Adrian -- ALPLOG
> @ PSA Peugeot Citroën, Sochaux, France
> tél. +33 (0)3 81 33 48 76
> fax +33 (0)3 81 33 16 06
> 
> 


-- 
Frantisek Fuka (yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
My E-Mail: [email protected]
My Homepage: http://www.fuxoft.cz
My ICQ UIN: 2745855
FFFILM: http://www.fuxoft.cz/fffilm/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.