[Ecls-list] embedding ecl into a game engine

Ilya Kliot plushe at gmail.com
Sat May 9 01:19:13 UTC 2009


Thanks a lot for the answer, sorry that I not described well the
things, but you got it right.
Sure I need to learn LISP much better than I know now.
Anyway let me clear a picture. The starting process is an engine,
all the objects (instances)  of the engine organized into a tree at
runtime - like a file system, so all the time
there is some object that is current for the script interpreter, like
cwd. Each class can export some
methods to general script interface facility, exactly as you wrote -
some hash tree that keeps the commands
and the args. After engine starts it loads an appropriate script dll -
in ecl case by cl_boot and
injects few basic functions like : new , delete, sel(like cd in fs),
psel(like pwd), exists etc.
Those functions should operate with engine functions  and data at
runtime. I thought that
I can achieve this by def_c_function(...).
Are those samples, mine and one you provided, equivalent from this
sight ? And which function from
externals.h corresponds to "(error "Could not create object of type
~A" class-name))" this statement ?
I found "unknown-function" in the conditions.lsp that called when some
wrong function called, I think
this is the exception handler you wrote about. The last thing I want
is to modify ecl :) But I really will glad to
help to comment or to document the externals.h because I still got no
which functions are right to call for string conversions from c to ecl
and vice versa. I found several, but which call when ? To provide this
general proxy
I can write some general function that will receive command and args,
but it's not too elegant solution at my
opinion. If I can't get command and args in "unknown-function" so may
be I can export the engine object
into lisp in some way ?


On Fri, May 8, 2009 at 8:21 PM, Juan Jose Garcia-Ripoll
<juanjose.garciaripoll at googlemail.com> wrote:
>
> On Tue, May 5, 2009 at 2:50 PM, Ilya Kliot <plushe at gmail.com> wrote:
> > Here is an example that supposed to be near to final result:
>
> Let me briefly comment your code. But before that I would give you
> this general advice: do not intend to just embed ECL without learning
> a bit of Common Lisp. If you do not grasp how errors are handled, how
> objects are created and destroyed, etc, then your efforts will be
> probably fruitless, since the library will not be very usable.
>
> First of all you must realize what def_c_function(...) does: it
> creates a new function that is available for Common Lisp. Now you
> should wonder:
> * What should the function return
> * What should the function do when it finds an error
>
> In this particular case you want a function that allocates a certain
> type of object.
> * Do you want the function to signal an error when it fails?
> * Or do you want it to return NIL or some other value?
>
> This is not a decision imposed by ECL, but rather a decision taken by you.
>
> In the first case your function should signal an error. However you
> might want that error object to have a type
> (http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/chap-9.html)
> and you might want to define a condition object and then create it
> with a call to the function ERROR.
>
> In the second case you might just want to return Cnil, which is a
> rather general object, equivalent to "false" and that can be checked
> easily.
>
> You will find it much easier to build wrappers using Lisp than using
> C++. Why? Because that way you will be forced to write Common Lisp and
> understand what you are doing and how people might use your code.
>
> For instance, the previous example might just be
>
> (defun new-object (class-name name)
>  (let* ((s1 (symbol-name class-name))
>         (s2 (symbol-name name))
>         (o (c-inline (s1 s2) (:c-string :c-string)
>       "
> nRoot* o = nEclServer::kernelServer->NewNoFail(ecl_base_string_pointer_safe(class_name),
> ecl_base_string_pointer_safe(name));
>
> @(return) = o? make_simple_base_string(o->GetFullName().c_str()) : Cnil;
> "))
>    (unless o
>       (error "Could not create object of type ~A" class-name))
>    o))
>
> This code can be stored in a lisp file and compiled using ECL.
>
> Juanjo
>
> --
> Instituto de Física Fundamental, CSIC
> c/ Serrano, 113b, Madrid 28009 (Spain)
> http://juanjose.garciaripoll.googlepages.com
>
> ------------------------------------------------------------------------------
> The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
> production scanning environment may not be a perfect world - but thanks to
> Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
> Series Scanner you'll get full speed at 300 dpi even with all image
> processing features enabled. http://p.sf.net/sfu/kodak-com
> _______________________________________________
> Ecls-list mailing list
> Ecls-list at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ecls-list




More information about the ecl-devel mailing list