Example #1
0
 public TSetCopyMarshaler(int length, UFieldAddress setProperty,
                          MarshalingDelegates <T> .FromNative fromNative, MarshalingDelegates <T> .ToNative toNative)
 {
     property          = setProperty;
     helper            = new FScriptSetHelper(property.Address);
     elementFromNative = fromNative;
     elementToNative   = toNative;
 }
Example #2
0
 public TSetReadWriteMarshaler(int length, UFieldAddress setProperty,
                               MarshalingDelegates <T> .FromNative fromNative, MarshalingDelegates <T> .ToNative toNative)
 {
     property          = setProperty;
     helper            = new FScriptSetHelper(property.Address);
     wrappers          = new TSetReadWrite <T> [length];
     elementFromNative = fromNative;
     elementToNative   = toNative;
 }
Example #3
0
        public static FScriptSetHelper CreateHelperFormInnerProperty(IntPtr elementProperty, IntPtr set)
        {
            FScriptSetHelper scriptSetHelper = new FScriptSetHelper();

            scriptSetHelper.elementProp = elementProperty;
            scriptSetHelper.set         = (FScriptSet *)set;
            scriptSetHelper.setLayout   = FScriptSet.GetScriptLayout(
                Native_UProperty.GetSize(elementProperty), Native_UProperty.GetMinAlignment(elementProperty));
            return(scriptSetHelper);
        }
Example #4
0
        internal static void ToNativeInternal(IntPtr nativeBuffer, int arrayIndex, IEnumerable <T> value,
                                              ref FScriptSetHelper helper, MarshalingDelegates <T> .ToNative elementToNative)
        {
            IntPtr scriptSetAddress = nativeBuffer + (arrayIndex * Marshal.SizeOf(typeof(FScriptSet)));

            helper.Set = scriptSetAddress;

            // Make sure any existing elements are properly destroyed
            helper.EmptyValues();

            if (value == null)
            {
                return;
            }

            unsafe
            {
                FScriptSet *set = (FScriptSet *)scriptSetAddress;

                IList <T> list = value as IList <T>;
                if (list != null)
                {
                    for (int i = 0; i < list.Count; ++i)
                    {
                        helper.AddElement(list[i], elementToNative);
                    }
                    return;
                }

                HashSet <T> hashSet = value as HashSet <T>;
                if (hashSet != null)
                {
                    foreach (T item in hashSet)
                    {
                        helper.AddElement(item, elementToNative);
                    }
                    return;
                }

                TSetBase <T> setBase = value as TSetBase <T>;
                if (setBase != null)
                {
                    foreach (T item in setBase)
                    {
                        helper.AddElement(item, elementToNative);
                    }
                    return;
                }

                foreach (T item in value)
                {
                    helper.AddElement(item, elementToNative);
                }
            }
        }
Example #5
0
        public TSetBase(UObject owner, UFieldAddress setProperty, IntPtr address,
                        MarshalingDelegates <T> .FromNative fromNative, MarshalingDelegates <T> .ToNative toNative)
        {
            property = setProperty;
            set      = (FScriptSet *)address;

            SetHelper = new FScriptSetHelper(property.Address, address);

            Owner      = owner;
            FromNative = fromNative;
            ToNative   = toNative;

            ContainerHashValidator.Validate(Native_USetProperty.Get_ElementProp(setProperty.Address));
        }
Example #6
0
        public static ISet <T> FromNative(IntPtr nativeBuffer, int arrayIndex, IntPtr prop)
        {
            IntPtr           scriptSetAddress = nativeBuffer + (arrayIndex * Marshal.SizeOf(typeof(FScriptSet)));
            FScriptSetHelper helper           = new FScriptSetHelper(prop, scriptSetAddress);

            unsafe
            {
                FScriptSet *set    = (FScriptSet *)scriptSetAddress;
                HashSet <T> result = new HashSet <T>();
                int         count  = set->Count;
                for (int i = 0; i < count; ++i)
                {
                    result.Add(elementFromNative(helper.GetElementPtr(i), 0, helper.ElementPropertyAddress));
                }
                return(result);
            }
        }
Example #7
0
        public static void ToNative(IntPtr nativeBuffer, int arrayIndex, IntPtr prop, ISet <T> value)
        {
            FScriptSetHelper helper = new FScriptSetHelper(prop);

            TSetReadWriteMarshaler <T> .ToNativeInternal(nativeBuffer, arrayIndex, value, ref helper, elementToNative);
        }