コード例 #1
0
static PyObject *
_wrap_g_interface_info_get_methods (PyGIBaseInfo *self)
{
    gssize n_infos;
    PyObject *infos;
    gssize i;

    n_infos = g_interface_info_get_n_methods ( (GIInterfaceInfo *) self->info);

    infos = PyTuple_New (n_infos);
    if (infos == NULL) {
        return NULL;
    }

    for (i = 0; i < n_infos; i++) {
        GIBaseInfo *info;
        PyObject *py_info;

        info = (GIBaseInfo *) g_interface_info_get_method ( (GIInterfaceInfo *) self->info, i);
        g_assert (info != NULL);

        py_info = _pygi_info_new (info);

        g_base_info_unref (info);

        if (py_info == NULL) {
            Py_CLEAR (infos);
            break;
        }

        PyTuple_SET_ITEM (infos, i, py_info);
    }

    return infos;
}
コード例 #2
0
ファイル: interface.c プロジェクト: Katyunechka/gjs
static JSBool
gjs_define_static_methods(JSContext       *context,
                          JSObject        *constructor,
                          GType            gtype,
                          GIInterfaceInfo *info)
{
    int i;
    int n_methods;

    n_methods = g_interface_info_get_n_methods(info);

    for (i = 0; i < n_methods; i++) {
        GIFunctionInfo *meth_info;
        GIFunctionInfoFlags flags;

        meth_info = g_interface_info_get_method (info, i);
        flags = g_function_info_get_flags (meth_info);

        /* Anything that isn't a method we put on the prototype of the
         * constructor.  This includes <constructor> introspection
         * methods, as well as the forthcoming "static methods"
         * support.  We may want to change this to use
         * GI_FUNCTION_IS_CONSTRUCTOR and GI_FUNCTION_IS_STATIC or the
         * like in the near future.
         */
        if (!(flags & GI_FUNCTION_IS_METHOD)) {
            gjs_define_function(context, constructor, gtype,
                                (GICallableInfo *)meth_info);
        }

        g_base_info_unref((GIBaseInfo*) meth_info);
    }
    return JS_TRUE;
}
コード例 #3
0
static VALUE
rg_get_method(VALUE self, VALUE rb_n_or_name)
{
    GIInterfaceInfo *info;
    GIFunctionInfo *function_info;

    info = SELF(self);
    if (RB_TYPE_P(rb_n_or_name, T_FIXNUM)) {
        gint n;
        n = NUM2INT(rb_n_or_name);
        function_info = g_interface_info_get_method(info, n);
    } else {
        const char *name;
        name = RVAL2CSTR(rb_n_or_name);
        function_info = g_interface_info_find_method(info, name);
    }

    return GI_BASE_INFO2RVAL_WITH_UNREF(function_info);
}
コード例 #4
0
ファイル: seed-importer.c プロジェクト: GNOME/seed
static void
seed_gi_importer_handle_iface(JSContextRef ctx,
                              JSObjectRef namespace_ref,
                              GIObjectInfo* info,
                              JSValueRef* exception)
{
    GType type;

    type = g_registered_type_info_get_g_type((GIRegisteredTypeInfo*) info);

    if (type != 0) {
        GIFunctionInfo* finfo;
        GIFunctionInfoFlags flags;
        JSObjectRef constructor_ref;
        guint i, n_methods;

        constructor_ref
          = JSObjectMake(ctx, gobject_constructor_class, (gpointer) type);

        seed_object_set_property(ctx, constructor_ref, "type",
                                 seed_value_from_long(ctx, type, exception));
        n_methods = g_interface_info_get_n_methods(info);
        for (i = 0; i < n_methods; i++) {
            finfo = g_interface_info_get_method(info, i);
            flags = g_function_info_get_flags(finfo);
            if (!(flags & GI_FUNCTION_IS_METHOD)) {
                seed_gobject_define_property_from_function_info(ctx, finfo,
                                                                constructor_ref,
                                                                FALSE);
            } else {
                g_base_info_unref((GIBaseInfo*) finfo);
            }
        }

        seed_object_set_property(ctx, namespace_ref,
                                 g_base_info_get_name((GIBaseInfo*) info),
                                 constructor_ref);
        seed_object_set_property(ctx, constructor_ref, "prototype",
                                 seed_gobject_get_prototype_for_gtype(type));
    }
}