Re: Re: Assertion name not printed when using rescue

Frantisek Fuka <[email protected]>
Newsgroups gmane.comp.lang.eiffel.smalleiffel
Message-ID <[email protected]>
On Apr 5, 2005 8:56 AM, [email protected] <[email protected]> wrote:
> > I am sorry, but I don't know C/C++ at all. That's why I'm using
> > Eiffel. :) It was not easy for me just to link ncurses.h to my
> > SmartEiffel program. I can see in sf_newt.c that you can have some
> > hooks to be executed when runtime error happens but I don't understand
> > how I could use that in my program (which is written in Eiffel, just
> > calling some basic ncurses routines).
> 
> How do you call those routines? Using c_inline_c? This method is really
> discouraged. It is useful for small prototyping but you quickly strike its
> limits, and your problem is one of them.

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++.

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".

Is this even the correct solution? Does it mean that when I use
"rescue" the runtime error message is always lost (not accessible in
some sort of "exception" object)? 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?

I know these may seem like stupid questions to you. 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.

> 
> You should write an external plugin as I did. For example, look at
> http://www.cadrian.net/svn/SmartFactor/trunk/source/interfaces/dialog/newt/sf_newt_context.e
> which calls the C routine sf_newt_init (look for the `plugin_init'
> feature)
> 
> More explanations on how this works:
> 
> CAVEAT: the following only works with the upcoming 2.2 release, you should
> therefore download the latest snapshot. The plug_in external already
> exists in 2.1, but in a somewhat less powerful flavour.
> 
> An external plugin is a two-part component: it has an Eiffel part, and a C
> part. The Eiffel part is just glue code that calls the C part.
> 
> The Eiffel feature `plugin_init' is an external call. In that case, it is
> defined as an external "plug_in". This external specification requires an
> alias that describes:
> 
>   - its "location" i.e. the directory where the plugin should be found. I
> usually use "." but the standard SmartEiffel library for instance usually
> uses "${sys}plugins" (look at INPUT_STREAM for example)
> 
>   - its "module_name" i.e. the directory where the plugin is put. This
> directory must be a subdirectory of the location. It is separate from the
> location because it can describe something else (2.1 compatibility, out of
> scope of this mail). This directory should, in your case, contain a
> directory named "c" which contains C files (.c and .h) and a special
> "libs" file which describes the libraries to link into your executable,
> and maybe a "paths" file if some include paths have to be passed to the C
> compiler. For examples, look either at Vision (included in SmartEiffel) or
> SmartFactor.
> 
>   - its "feature_name" i.e. the name of the C symbol to use. It can be
> either a macro, a function or a global variable.
> 
> > I was programming some 20 years ago in assembler and now I am looking
> > for some different higher level language. And C/C++ is not that
> > language. :)
> 
> I understand that ;o) but knowing a bit of C cannot harm. To me C is just
> a multiplatform assembler.
> 
> PS- I'm sorry you cannot download the whole SmartFactor release anymore. I
> have technical problems, I'll put the feature back online some day. Stay
> tuned ;o)
> 
> 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.