Exemplo n.º 1
0
        static unsafe IntPtr CreateFromSettings(CTParagraphStyleSettings s)
        {
            var handle = IntPtr.Zero;

            var specifiers = s.GetSpecifiers();

            var settings = new CTParagraphStyleSetting [specifiers.Count];
            var values   = new CTParagraphStyleSettingValue [specifiers.Count];

            int i = 0;

            foreach (var e in specifiers)
            {
                e.WriteValue(values, i);
                settings [i].spec      = e.Spec;
                settings [i].valueSize = (uint)e.ValueSize;
                ++i;
            }

            fixed(CTParagraphStyleSettingValue *pv = values)
            {
                for (i = 0; i < settings.Length; ++i)
                {
                    // TODO: is this safe on the ARM?
                    byte *p = &pv[i].int8;
                    settings[i].value = (IntPtr)p;
                }
                handle = CTParagraphStyleCreate(settings, settings.Length);
            }

            // Yes this weird Dispose implementation is correct, this bugzilla
            // comment explains more about it. TL;DR: check CTParagraphStyleSpecifierIntPtrsValue
            // https://bugzilla.xamarin.com/show_bug.cgi?id=54148#c4
            i = 0;
            foreach (var e in specifiers)
            {
                e.Dispose(values, i);
            }

            return(handle);
        }
Exemplo n.º 2
0
        static unsafe IntPtr CreateFromSettings(CTParagraphStyleSettings s)
        {
            var handle = IntPtr.Zero;

            var specifiers = s.GetSpecifiers();

            var settings = new CTParagraphStyleSetting [specifiers.Count];
            var values   = new CTParagraphStyleSettingValue [specifiers.Count];

            int i = 0;

            foreach (var e in specifiers)
            {
                e.WriteValue(values, i);
                settings [i].spec      = e.Spec;
                settings [i].valueSize = (uint)e.ValueSize;
                ++i;
            }

            fixed(CTParagraphStyleSettingValue *pv = values)
            {
                for (i = 0; i < settings.Length; ++i)
                {
                    // TODO: is this safe on the ARM?
                    byte *p = &pv[i].int8;
                    settings[i].value = (IntPtr)p;
                }
                handle = CTParagraphStyleCreate(settings, settings.Length);
            }

            i = 0;
            foreach (var e in specifiers)
            {
                e.Dispose(values, i);
            }

            return(handle);
        }
Exemplo n.º 3
0
 static extern IntPtr CTParagraphStyleCreate(CTParagraphStyleSetting[] settings, nint settingCount);
Exemplo n.º 4
0
        static unsafe IntPtr CreateFromSettings(CTParagraphStyleSettings s)
        {
            var handle = IntPtr.Zero;

            var specifiers = s.GetSpecifiers ();

            var settings  = new CTParagraphStyleSetting [specifiers.Count];
            var values    = new CTParagraphStyleSettingValue [specifiers.Count];

            int i = 0;
            foreach (var e in specifiers) {
                e.WriteValue (values, i);
                settings [i].spec       = e.Spec;
                settings [i].valueSize  = (uint) e.ValueSize;
                ++i;
            }

            fixed (CTParagraphStyleSettingValue* pv = values) {
                for (i = 0; i < settings.Length; ++i) {
                    // TODO: is this safe on the ARM?
                    byte* p = &pv[i].int8;
                    settings[i].value = (IntPtr) p;
                }
                handle = CTParagraphStyleCreate (settings, settings.Length);
            }

            i = 0;
            foreach (var e in specifiers) {
                e.Dispose (values, i);
            }

            return handle;
        }