Esempio n. 1
0
        public static GType[] Prerequisites(GType interfaceType)
        {
            uint nPrerequisites_;
            var  ret_ = g_type_interface_prerequisites(interfaceType, out nPrerequisites_);
            var  ret  = GMarshal.PtrToCArray <GType> (ret_, (int)nPrerequisites_, true);

            return(ret);
        }
Esempio n. 2
0
            /// <summary>
            /// Wraps <see cref="CollectValue"/> in an anonymous method that can be passed
            /// to unmaged code.
            /// </summary>
            /// <param name="method">The managed method to wrap.</param>
            /// <param name="freeUserData">Frees the <see cref="GCHandle"/> for any user
            /// data closure parameters in the unmanged function</param>
            /// <returns>The callback method for passing to unmanged code.</returns>
            /// <remarks>
            /// This function is used to marshal managed callbacks to unmanged code. If this
            /// callback is only called once, <paramref name="freeUserData"/> should be
            /// set to <c>true</c>. If it can be called multiple times, it should be set to
            /// <c>false</c> and the user data must be freed elsewhere. If the callback does
            /// not have closure user data, then the <paramref name="freeUserData"/>
            /// parameter has no effect.
            /// </remarks>
            public static UnmanagedCollectValue Create(CollectValue method, bool freeUserData)
            {
                UnmanagedCollectValue nativeCallback = (
                    /* <type name="Value" type="GValue*" managed-name="Value" /> */
                    /* transfer-ownership:none */
                    ref
                    Value value,
                    /* <type name="guint" type="guint" managed-name="Guint" /> */
                    /* transfer-ownership:none */
                    uint nCollectValues_,
                    /* <type name="TypeCValue" type="GTypeCValue*" managed-name="TypeCValue" /> */
                    /* transfer-ownership:none */
                    IntPtr collectValues_,
                    /* <type name="guint" type="guint" managed-name="Guint" /> */
                    /* transfer-ownership:none */
                    uint collectFlags_) => {
                    var collectValues = GMarshal.PtrToCArray <TypeCValue> (collectValues_, (int)nCollectValues_);
                    var ret           = method.Invoke(ref value, collectValues, collectFlags_);
                    var ret_          = GMarshal.StringToUtf8Ptr(ret);
                    return(ret_);
                };

                return(nativeCallback);
            }