Skip navigation
Currently Being Moderated

gluegen wrapper returning String or Array

Dec 1, 2008 7:58 PM

How can I setup a wrapper function to return a String or Array. In my wrapper.gg file I'd like to have something like:
-----
public function mystrcat(str1:String, str2:String):String
{
char *ret = strcat(str1, str2);
return ret;
}

public function myarrayfunc():Array
{
int a[10];
return a;
}
-----
Do I need to stuff the data in a ByteArray or something like that?
 
Replies
  • Currently Being Moderated
    Feb 5, 2009 10:03 PM   in reply to Robert Stehwien
    Hi,

    Have you had any progress on this subject over the last 2 months?

    Strings should work as you have described I think...

    For arrays: Below are a couple of functions I wrote which will wrap short integer arrays. However, due to the nature of the alchemy API (with variable arguments) I couldn't figure out how to write them for any sized array... It may be more efficient to use ByteArrays than to do it this way... the as3_crypto_wrapper has some useful functions for ByteArrays.

    Possibly you could download the source for the implementations of the type converting functions and modify the arguments to take arrays of values.

    Hopefully this helps... :)

    Regards,
    Joey
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 24, 2009 12:54 PM   in reply to Robert Stehwien
    You should be able to just return an AS3_Val.
     
    |
    Mark as:
  • Currently Being Moderated
    May 25, 2009 6:45 AM   in reply to Robert Stehwien

    I've got trouble getting Strings to work within a gg wrapper. I tried adding the following within a gluegen file (note there are no pure c-code blocks, only the pseudo-AS):

     

    public function getString():String {
        return AS3_String("hello");
    }

     

    running gluegen with the following:

    gluegen libharu.gg -oc hpdf.c -oas ../src/alchemy/hpdf/hpdf.as -cpackage cmodule.hpdf -package alchemy.hpdf -class hpdf

     

    and the compiling using:

    gcc hpdf.c -O3 -swc -o hpdf.swc

     

    But all I get is errors about some conflicting gg_string type and warnings about incompatible pointer types?

     

    ibharu.gg: In function 'impl_getString':
    libharu.gg:11: warning: return from incompatible pointer type
    libharu.gg: In function 'thunk_getString':
    libharu.gg:10: warning: return makes pointer from integer without a cast
    libharu.gg: At top level:
    libharu.gg:12: error: conflicting types for 'gg_string'
    libharu.gg:10: error: previous implicit declaration of 'gg_string' was here

    However, if I change the code as follows everything compiles fine, and I'm able to use the produced swc in Flex:

     

    public function getString():Array {
         return AS3_Array("StrType", "hey there");
    }
    

    So basically, all I've done is returned an AS3_Array instead of AS3_String. Since my C-skills are limited and about 10 years old, I might be missing something very trivial here, but can anyone help me spot what it is? I'm compiling on OS X 10.5.7

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)