Exemplo n.º 1
0
        internal static string[] GetImmediateDependencies(string @namespace)
        {
            var native_namespace = GMarshal.StringToUtf8Ptr(@namespace);
            var raw_ret          = g_irepository_get_immediate_dependencies(IntPtr.Zero, native_namespace);
            var ret = GMarshal.GStrvPtrToStringArray(raw_ret, freePtr: true, freeElements: true);

            GMarshal.Free(native_namespace);
            return(ret);
        }
Exemplo n.º 2
0
        static object MarshalOutArg(Argument arg, TypeInfo info, Transfer ownership, ref Action free)
        {
            if (info.IsPointer)
            {
                switch (info.Tag)
                {
                case TypeTag.Array:
                    switch (info.ArrayType)
                    {
                    case ArrayType.C:
                        var arrayType = info.GetParamType(0);
                        if (arrayType.Tag == TypeTag.UTF8 && info.IsZeroTerminated)
                        {
                            // This is a Strv
                            return(GMarshal.GStrvPtrToStringArray(arg.Pointer, ownership != Transfer.Nothing, ownership == Transfer.Everything));
                        }
                        throw new NotImplementedException();

                    default:
                        throw new NotImplementedException();
                    }

                case TypeTag.UTF8:
                    var ret = GMarshal.Utf8PtrToString(arg.Pointer, ownership != Transfer.Nothing);
                    return(ret);

                case TypeTag.Interface:
                    switch (info.Interface.InfoType)
                    {
                    case InfoType.Interface:
                    case InfoType.Object:
                        if (arg.Pointer == IntPtr.Zero)
                        {
                            return(null);
                        }
                        return(new DynamicGObject(arg.Pointer));

                    case InfoType.Struct:
                        if (arg.Pointer == IntPtr.Zero)
                        {
                            return(null);
                        }
                        return(new DynamicStruct(arg.Pointer, (StructInfo)info.Interface));

                    default:
                        throw new NotImplementedException();
                    }

                case TypeTag.Void:
                    return(arg.Pointer);

                default:
                    throw new NotImplementedException();
                }
            }
            else
            {
                switch (info.Tag)
                {
                case TypeTag.Boolean:
                    return(arg.Boolean);

                case TypeTag.Int8:
                    return(arg.Int8);

                case TypeTag.UInt8:
                    return(arg.UInt8);

                case TypeTag.Int16:
                    return(arg.Int16);

                case TypeTag.UInt16:
                    return(arg.UInt16);

                case TypeTag.Int32:
                    return(arg.Int32);

                case TypeTag.UInt32:
                    return(arg.UInt32);

                case TypeTag.Int64:
                    return(arg.Int64);

                case TypeTag.UInt64:
                    return(arg.UInt64);

                case TypeTag.Void:
                    return(null);

                default:
                    throw new NotImplementedException();
                }
            }
        }