[racket] C++ Extensions and Classes

From: Cody Eilar (cody.eilar at gmail.com)
Date: Wed Feb 5 19:16:54 EST 2014

>
>
>
>       I asked this same question on the dev side but didn't get any
> response, so I thought this list might be more appropriate. So I have been
> writing some racket extensions for some C++ classes using the tutorial (
> http://docs.racket-lang.org/inside/overview.html)  on the racket site and
> have been able to successfully load them into racket. However I was
> wondering if I can use inheritance to reuse some code.
>
> For example I have two classes that I have written in C++, Foo and Bar.
>
> Class Foo looks like this:
>
> Foo {
>      func1() { /* ... do stuff */ }
> }
>
> Class Bar looks like this:
>
> Bar : Foo {
>      func2() { /*... do more stuff /*}
> }
>
> I've currently written a single .cpp racket extension that creates Bar and
> creates the extensions for both func1() and func2(); however, I'd like to
> create two racket extension classes. One extension that does only functions
> inside Foo and then I just want to include Foo_ext.h (my racket extension
> to Foo) in Bar_ext.h so I have access to all the functions.
>
> So I currently have this:
>
> Bar_ext.cpp:
>
> func1_racket_ext() { /*... do racket stuff and run func1() */}
>
> func2_racket_ext() {/* ... do more racket stuff and run func2() /*}
>
> /* Scheme initializers etc... */
>
>
>
> But what I really want is:
>
> Foo_ext.h:
>
> func1_racket_ext() { /*... do racket stuff and run func1() */}
>
> /* Scheme initializes etc... */
>
>
> Bar_ext.cpp:
> #include "Foo_ext.h"
>
> func2_racket_ext() {/* ... do more racket stuff and run func2() /*}
>
> /* Scheme initializers etc... */
>
>
> Is this even possible? I feel like namespace might be an issue. This would
> be extremely useful for me because it would allow me to not write lots and
> lots of redundant code since I have many classes that use class Foo as a
> super class.
>
> Any advice would be greatly appreciated and if you could point me to an
> example (maybe there is something in the underlying racket code you can
> point me to?)
>
>
> Thanks!
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140205/07d152b8/attachment.html>

Posted on the users mailing list.