[Bf-gamedev] Lua

Jason Wilkins jason.a.wilkins at gmail.com
Thu Sep 26 18:54:07 CEST 2013


SWIG does a lot of checking of arguments and gives good error messages if
you pass the wrong arguments.  This is a good thing and I wouldn't give it
up to make the code very slightly faster and smaller.

Your CPU time should be spent inside of C/C++ if it is critical anyway.
 Who writes long running compute loops in Python that call into C enough
that the overhead of doing that outweighs what the C code does?  Put the
loop inside the C...

When using SWIG you should write your interface for SWIG so that you have a
nice clean connection.  Libraries that aren't SWIG friendly are going to
need a wrapper.  This isn't a big deal IMO because the wrapper is going to
be really straightforward compared to any particular languages embedding
API.

My strategy for using SWIG is to either write my interfaces simply with
SWIG in mind from the beginning or to write a simple wrapper.  I don't
really expect SWIG to work well if given an arbitrary interface (SWIG will
work just fine, but it will be ugly to use from the scripting language).

I've written a wrapper for GLUT and GLEW for SWIG (the GLEW produces a HUGE
file, lol).  You can even write callbacks for GLUT in Lua.  Problem is, I
need to write the callback interface for each language individually, so
yes, SWIG isn't perfect.  It can't do everything.

The GLEW interface is difficult to use because of all the pointers.  With a
little more work I could fix this.  I plan on following whatever strategy
WebGL uses.

I'm not suggesting SWIG at this time, just trying to convey some of my
experience.


On Thu, Sep 26, 2013 at 11:27 AM, Campbell Barton <ideasman42 at gmail.com>wrote:

> On Fri, Sep 27, 2013 at 1:39 AM, Jacob Merrill
> <blueprintrandom1 at gmail.com> wrote:
> > I'm no expert, but if the swig system has no drawbacks other than more
> code,
>
> There are various posts online and SWIG for sure has its drawbacks.
>
> http://pyvideo.org/video/1692/cython-vs-swig-fight
>
> http://stackoverflow.com/questions/456884/extending-python-to-swig-not-to-swig-or-cython
>
> > since it has python handles anyway, would that not be like cutting out
> > clutter and adding in a universal adapter?
> >
> > if it supports lua and python and X,
> > why not cut out the python handles and use the swig handles for python?
> >
> > What would be the disadvantage?
> > Build stability?
>
> I can't give a good answer since I never used SWIG as a developer,
> someone could try move to a SWIG based API, but I strongly doubt this
> is as simple as you make out - there are many details that come into
> play here and blenders python integration is one of the most complex I
> have seen (compared to other opensource projects at least).
>
> > On Thu, Sep 26, 2013 at 8:36 AM, Jason Wilkins <
> jason.a.wilkins at gmail.com>
> > wrote:
> >>
> >> To answer your question in that email (if it wasn't answered), yes, SWIG
> >> has a generic mechanism for throwing errors in the embedded language.
> >> I've used it to catch exceptions and rethrow them in Lua (but could
> just as
> >> well turn error codes into exceptions too).
> >>
> >>
> >>
> >> On Thu, Sep 26, 2013 at 10:33 AM, Campbell Barton <ideasman42 at gmail.com
> >
> >> wrote:
> >>>
> >>> On Fri, Sep 27, 2013 at 1:29 AM, Jacob Merrill
> >>> <blueprintrandom1 at gmail.com> wrote:
> >>> > What about this? - http://www.swig.org/
> >>> >
> >>> > this seems like a way to make "ANY" language grab the same handles in
> >>> > the
> >>> > BGE.
> >>>
> >>> yes and no, 4th paragraph.
> >>>
> >>> http://markmail.org/message/nkdhnkaas4mknakw
> >>>
> >>> > I could be mistaken...
> >>> >
> >>> > _______________________________________________
> >>> > Bf-gamedev mailing list
> >>> > Bf-gamedev at blender.org
> >>> > http://lists.blender.org/mailman/listinfo/bf-gamedev
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> - Campbell
> >>> _______________________________________________
> >>> Bf-gamedev mailing list
> >>> Bf-gamedev at blender.org
> >>> http://lists.blender.org/mailman/listinfo/bf-gamedev
> >>
> >>
> >>
> >> _______________________________________________
> >> Bf-gamedev mailing list
> >> Bf-gamedev at blender.org
> >> http://lists.blender.org/mailman/listinfo/bf-gamedev
> >>
> >
> >
> > _______________________________________________
> > Bf-gamedev mailing list
> > Bf-gamedev at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-gamedev
> >
>
>
>
> --
> - Campbell
> _______________________________________________
> Bf-gamedev mailing list
> Bf-gamedev at blender.org
> http://lists.blender.org/mailman/listinfo/bf-gamedev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.blender.org/pipermail/bf-gamedev/attachments/20130926/55402584/attachment.htm 


More information about the Bf-gamedev mailing list