Esempio n. 1
0
 extern static IntPtr g_param_spec_long(
     IntPtr name,
     IntPtr nick,
     IntPtr blurb,
     nlong min,
     nlong max,
     nlong defaultValue,
     ParamFlags flags);
Esempio n. 2
0
        public void TestParamSpecLong()
        {
            nlong min          = 1;
            nlong max          = 5;
            nlong defaultValue = 3;

            var param = TestParamSpec(GType.Long, (name, nick, blurb, flags) =>
                                      new ParamSpecLong(name, nick, blurb, min, max, defaultValue, flags));

            Assert.That(param.Minimum, Is.EqualTo(min));
            Assert.That(param.Maximum, Is.EqualTo(max));
            Assert.That(param.DefaultValue, Is.EqualTo(defaultValue));
            Assert.That(param.GetGType().Name, Is.EqualTo("GParamLong"));

            Utility.AssertNoGLibLog();
        }
Esempio n. 3
0
        public void TestLong()
        {
            var v = new Value(GType.Long);

            Assert.That(v.ValueGType, Is.EqualTo(GType.Long));
            nlong expected = 1;

            v.Set(expected);
            Assert.That((nlong)v, Is.EqualTo(expected));
            Assert.That(v.Get(), Is.EqualTo(expected));

            var v2 = new Value(GType.Boolean);

            Assert.That(() => v2.Set(1L), Throws.ArgumentException);
            Assert.That(() => (nlong)v2, Throws.InstanceOf <InvalidCastException> ());

            Utility.AssertNoGLibLog();
        }
Esempio n. 4
0
        static IntPtr New(string name, string nick, string blurb, nlong min, nlong max, nlong defaultValue, ParamFlags flags)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (nick == null)
            {
                throw new ArgumentNullException(nameof(nick));
            }
            if (blurb == null)
            {
                throw new ArgumentNullException(nameof(blurb));
            }
            var namePtr  = GMarshal.StringToUtf8Ptr(name);
            var nickPtr  = GMarshal.StringToUtf8Ptr(nick);
            var blurbPtr = GMarshal.StringToUtf8Ptr(blurb);
            var ret      = g_param_spec_long(namePtr, nickPtr, blurbPtr, min, max, defaultValue, flags);

            // Any strings that have the cooresponding static flag set must not
            // be freed because they are passed to g_intern_static_string().
            if (!flags.HasFlag(ParamFlags.StaticName))
            {
                GMarshal.Free(namePtr);
            }
            if (!flags.HasFlag(ParamFlags.StaticNick))
            {
                GMarshal.Free(nickPtr);
            }
            if (!flags.HasFlag(ParamFlags.StaticBlurb))
            {
                GMarshal.Free(blurbPtr);
            }

            return(ret);
        }
Esempio n. 5
0
 public ParamSpecLong(string name, string nick, string blurb, nlong min, nlong max, nlong defaultValue, ParamFlags flags)
     : this(New(name, nick, blurb, min, max, defaultValue, flags), Transfer.None)
 {
 }