Problem with cross-module class usage

2 views
Skip to first unread message

Conrad Steenberg

unread,
Apr 27, 2011, 5:18:14 PM4/27/11
to crack-l...@googlegroups.com
Hi all,

I'm hoping I'm just missing something, but here is the problem I'm
having with symbols appearing in compiled extensions not being usable in
other compiled extensions.

This involves the Cairo binding, which allows drawing on a variety of
surfaces, including an SDL_Surface as bound in the _sdl extentions.

In _sdl.crk, an SDL_Surface class is created as an opaque class with no
methods:
class SDL_Surface;

In _cairosdl.crk, a C function is wrapped with the signature

import crack.ext._sdl SDL_Surface;
import crack.ext._cairo cairo_surface_t;
..
cairo_surface_t
cairosdl_surface_create (SDL_Surface sdl_surface);

ParseError: opt/_cairosdl.crk:69: Unknown type cairo_surface_t

I.e. there needs to be a way in the extensions to declare a type as
defined in an external module.

Hope this makes sense :-)
Conrad


Michael Muller

unread,
Apr 27, 2011, 5:33:04 PM4/27/11
to Conrad Steenberg, crack-l...@googlegroups.com

Conrad Steenberg wrote:
> Hi all,
>
> I'm hoping I'm just missing something, but here is the problem I'm
> having with symbols appearing in compiled extensions not being usable in
> other compiled extensions.
>
> This involves the Cairo binding, which allows drawing on a variety of
> surfaces, including an SDL_Surface as bound in the _sdl extentions.
>
> In _sdl.crk, an SDL_Surface class is created as an opaque class with no
> methods:
> class SDL_Surface;
>
> In _cairosdl.crk, a C function is wrapped with the signature
>
> import crack.ext._sdl SDL_Surface;
> import crack.ext._cairo cairo_surface_t;
> ..
> cairo_surface_t
> cairosdl_surface_create (SDL_Surface sdl_surface);
>
> ParseError: opt/_cairosdl.crk:69: Unknown type cairo_surface_t

So am I correct in assuming that _cairosdl.crk is also an extension generator?
If so, this won't work because the extension generator doesn't know anything
about crack language imports. The extension generator has its own type
system.

>
> I.e. there needs to be a way in the extensions to declare a type as
> defined in an external module.


In order to make this happen, you need:

1) Support in the extension API for importing a module (probably in the form
of a method that returns a Module pointer). The getType() method (possibly
with some modifications) should allow you to extract the foreign type from
the module.
2) Support in the extension generator for a syntax that allows you to specify
the import of a type and bind it to a C++ type. Use of this syntax should
generate the import and type extraction.

Would you like to take a stab at this for 0.5?

>
> Hope this makes sense :-)
> Conrad
>
>


=============================================================================
michaelMuller = mmu...@enduden.com | http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
The world is full of security systems. Hack one of them. - Bruce Schneier
=============================================================================

Conrad Steenberg

unread,
Apr 28, 2011, 12:37:40 PM4/28/11
to crack-l...@googlegroups.com
Hi Michael,

On Wed, 2011-04-27 at 17:33 -0400, Michael Muller wrote:

>
> In order to make this happen, you need:
>
> 1) Support in the extension API for importing a module (probably in the form
> of a method that returns a Module pointer). The getType() method (possibly
> with some modifications) should allow you to extract the foreign type from
> the module.
> 2) Support in the extension generator for a syntax that allows you to specify
> the import of a type and bind it to a C++ type. Use of this syntax should
> generate the import and type extraction.
>
> Would you like to take a stab at this for 0.5?

Sure, I'd love to get it done.

I'll ask for some pointers on how to import modules when the time comes.

Cheers,
Conrad


Michael Muller

unread,
Apr 28, 2011, 1:12:20 PM4/28/11
to crack-l...@googlegroups.com
On Thu, Apr 28, 2011 at 12:37 PM, Conrad Steenberg
<conrad.s...@caltech.edu> wrote:
> Hi Michael,
>
> On Wed, 2011-04-27 at 17:33 -0400, Michael Muller wrote:
>
>>
>> In order to make this happen, you need:
>>
>> 1) Support in the extension API for importing a module (probably in the form
>>    of a method that returns a Module pointer).  The getType() method (possibly
>>    with some modifications) should allow you to extract the foreign type from
>>    the module.
>> 2) Support in the extension generator for a syntax that allows you to specify
>>    the import of a type and bind it to a C++ type.  Use of this syntax should
>>    generate the import and type extraction.
>>
>> Would you like to take a stab at this for 0.5?
>
> Sure, I'd love to get it done.

Cool!

>
> I'll ask for some pointers on how to import modules when the time comes.
>

You know where to find me :-)

> Cheers,
> Conrad
>
>
>

Reply all
Reply to author
Forward
0 new messages