Re: g-ir-scanner not recognising non-virtual functions



On 09/26/2011 02:59 PM, Tony Houghton wrote:
I'm developing a simple wrapper library, with the objects defined using
gob2 and I want to export gi bindings for it. At first I didn't bother
making the object methods virtual but they didn't get exported into the
.gir file. When I made them virtual they did get exported. However, I
would also like to export *_new() constructor functions, which aren't
object methods for obvious reasons. And I'm likely to want some other
utility functions which won't be associated with any object.

I've had a quick look at pango (because I already had its source lying
around) and AFAICT that is using non-virtual functions in gir. But it
doesn't seem to be using any extra annotations or g-ir-scanner flags
(difficult to tell, because it uses autotools, and I'm not).

For example, I would like to export this function:

class Gsqlite:Database
         from G:Object
{
     // ...
     /**
      * new:
      *
      * @filename: filename of the database or ":memory:".
      * @error: (out) (allow-none) (default NULL):
      *
      * Returns: a new database object or %NULL
      *
      * Use g_object_unref() to close. All statements must be finalized
      * separately.
      */
     public Gsqlite:Database *
     new(const gchar *filename, GError **error)
     {
         GsqliteDatabase *self = GET_NEW;

         return self_check_open_for_new(self, self_open(self, filename, error));
     }
     // ...
}

and I'm calling g-ir-scanner like this:

${G_IR_SCANNER} --namespace=Gsqlite --nsversion=0.0 \
         --include=GObject-2.0 --pkg=gobject-2.0 --pkg=sqlite3 \
         --libtool=${LIBTOOL} --library=gsqlite \
         -L${BUILD_DIR} -I${BUILD_DIR} -I${SRC_DIR} \
         ${SRC} -o ${TGT}

Sorry if this is not a direct solution to your problem at hand, but if possible (and I guess it is, if it's a "simple library wrapper") you should reconsider writing your high level stuff in Vala, where you can get the Vala compiler to generate gir directly. And with Vala you still have it very easy with integrating bits and bobs in C if needed.

Cheers,
Mikkel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]