2 * value.h: Generated code for the type system.
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2007 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
23 * ugly file containing the catchall value type we use.
39 struct RepeatBehavior
;
43 struct ManagedTypeInfo
;
48 class DependencyProperty
;
50 class AnimationStorage
;
54 #define checked_get_exact(kind, errval, mem) g_return_val_if_fail (k == (kind), errval); return mem;
55 #define checked_get_subclass(kind, castas) if (u.dependency_object == NULL) return NULL; g_return_val_if_fail (Types::IsSubclassOrSuperclassOf (types, k, kind), NULL); return (castas*)u.dependency_object;
62 Value (const Value
& v
);
63 explicit Value (Type::Kind k
);
64 explicit Value (bool z
);
65 explicit Value (double d
);
66 explicit Value (gint32 i
);
67 explicit Value (guint32 i
);
68 Value (gunichar c
, Type::Kind as
); // for use with char values.
69 Value (gint64 i
, Type::Kind as
); // Use for TimeSpan and int64 values.
71 Value (EventObject
*obj
);
72 Value (FontFamily family
);
73 Value (FontSource source
);
74 Value (FontWeight weight
);
75 Value (FontStyle style
);
76 Value (FontStretch stretch
);
77 Value (PropertyPath propertypath
);
82 Value (RepeatBehavior repeat
);
83 Value (Duration duration
);
84 Value (KeyTime keytime
);
85 Value (GridLength grid_length
);
86 Value (Thickness thickness
);
87 Value (CornerRadius radius
);
88 Value (ManagedTypeInfo type_info
);
89 Value (const char *s
, bool take
= false);
90 Value (Point
*points
, int count
);
91 Value (double *values
, int count
);
92 Value (Type::Kind
, void *npobj
);
96 // Use these to create Values with dependency objects with
97 // a reference count of 1 (giving the ownership of the object
99 // Useful in cases like this:
100 // SetValue (SomeProperty, new DependencyObject ())
101 // in which case we have to unref the newly created object.
102 static Value
* CreateUnrefPtr (EventObject
* dob
);
103 static Value
CreateUnref (EventObject
* dob
);
105 // essentially the same as the copy constructor, except it
106 // does a deep copy of DependencyObjects.
107 static Value
* Clone (Value
*v
, Types
*types
= NULL
);
110 void SetIsNull (bool isNull
);
111 void Set (double value
);
113 bool operator!= (const Value
&v
) const;
114 bool operator== (const Value
&v
) const;
116 Value
& operator= (const Value
& other
);
118 bool Is (Type::Kind type
) { return Type::IsSubclassOf (k
, type
); }
120 bool AsBool () { checked_get_exact (Type::BOOL
, false, (bool)u
.i32
); }
121 gunichar
AsChar () { checked_get_exact (Type::CHAR
, 0, u
.c
); }
122 double AsDouble () { checked_get_exact (Type::DOUBLE
, 0.0, u
.d
); }
123 float AsFloat () { checked_get_exact (Type::FLOAT
, 0.0, u
.f
); }
124 guint64
AsUInt64 () { checked_get_exact (Type::UINT64
, 0, u
.ui64
); }
125 gint64
AsInt64 () { checked_get_exact (Type::INT64
, 0, u
.i64
); }
126 TimeSpan
AsTimeSpan () { checked_get_exact (Type::TIMESPAN
, 0, (TimeSpan
)u
.i64
); }
127 guint32
AsUInt32 () { checked_get_exact (Type::UINT32
, 0, u
.ui32
); }
128 gint32
AsInt32 () { checked_get_exact (Type::INT32
, 0, u
.i32
); }
129 Color
* AsColor () { checked_get_exact (Type::COLOR
, NULL
, u
.color
); }
130 Point
* AsPoint () { checked_get_exact (Type::POINT
, NULL
, u
.point
); }
131 Uri
* AsUri () { checked_get_exact (Type::URI
, NULL
, u
.uri
); }
132 Rect
* AsRect () { checked_get_exact (Type::RECT
, NULL
, u
.rect
); }
133 Size
* AsSize () { checked_get_exact (Type::SIZE
, NULL
, u
.size
); }
134 FontFamily
* AsFontFamily () { checked_get_exact (Type::FONTFAMILY
, NULL
, u
.fontfamily
); }
135 FontWeight
* AsFontWeight () { checked_get_exact (Type::FONTWEIGHT
, NULL
, u
.fontweight
); }
136 FontStyle
* AsFontStyle () { checked_get_exact (Type::FONTSTYLE
, NULL
, u
.fontstyle
); }
137 FontStretch
* AsFontStretch() { checked_get_exact (Type::FONTSTRETCH
, NULL
, u
.fontstretch
); }
138 FontSource
* AsFontSource () { checked_get_exact (Type::FONTSOURCE
, NULL
, u
.fontsource
); }
139 PropertyPath
* AsPropertyPath () { checked_get_exact (Type::PROPERTYPATH
, NULL
, u
.propertypath
); }
140 char* AsString () { checked_get_exact (Type::STRING
, NULL
, u
.s
); }
141 DependencyProperty
* AsDependencyProperty () { checked_get_exact (Type::DEPENDENCYPROPERTY
, NULL
, u
.dp
); }
143 void * AsManagedObject () { checked_get_exact (Type::MANAGED
, NULL
, u
.managed_object
); }
144 void * AsNPObj () { checked_get_exact (Type::NPOBJ
, NULL
, u
.npobj
); }
146 RepeatBehavior
* AsRepeatBehavior () { checked_get_exact (Type::REPEATBEHAVIOR
, NULL
, u
.repeat
); }
147 Duration
* AsDuration () { checked_get_exact (Type::DURATION
, NULL
, u
.duration
); }
148 KeyTime
* AsKeyTime () { checked_get_exact (Type::KEYTIME
, NULL
, u
.keytime
); }
149 GridLength
* AsGridLength () { checked_get_exact (Type::GRIDLENGTH
, NULL
, u
.grid_length
); }
150 Thickness
* AsThickness () { checked_get_exact (Type::THICKNESS
, NULL
, u
.thickness
); }
151 CornerRadius
* AsCornerRadius () { checked_get_exact (Type::CORNERRADIUS
, NULL
, u
.corner
); }
152 ManagedTypeInfo
* AsManagedTypeInfo () { checked_get_exact (Type::MANAGEDTYPEINFO
, NULL
, u
.type_info
); }
153 /* nullable primitives (all but bool) */
154 double* AsNullableDouble () { checked_get_exact (Type::DOUBLE
, NULL
, &u
.d
); }
155 guint64
* AsNullableUint64 () { checked_get_exact (Type::UINT64
, NULL
, &u
.ui64
); }
156 gint64
* AsNullableInt64 () { checked_get_exact (Type::INT64
, NULL
, &u
.i64
); }
157 gint32
* AsNullableInt32 () { checked_get_exact (Type::INT32
, NULL
, &u
.i32
); }
163 Type::Kind
GetKind ();
181 EventObject
*dependency_object
;
183 DependencyProperty
*dp
;
188 FontFamily
*fontfamily
;
189 FontSource
*fontsource
;
190 FontWeight
*fontweight
;
191 FontStretch
*fontstretch
;
192 FontStyle
*fontstyle
;
193 PropertyPath
*propertypath
;
194 RepeatBehavior
*repeat
;
197 GridLength
*grid_length
;
198 Thickness
*thickness
;
199 CornerRadius
*corner
;
200 ManagedTypeInfo
*type_info
;
201 void *managed_object
;
205 // You don't want to be using this ctor. it's here to help
206 // c++ recognize bad unspecified pointer args to Value ctors
207 // (it normally converts them to bool, which we handle, so you
208 // never see the error of your ways). So do the world a
209 // favor, and don't expose this ctor. :)
211 // You don't want to be using this ctor either.
212 // Use the Value (gint64, Type::Kind) ctor
213 // (Both for TimeSpan and int64_t)
214 // This one is bad because it get used by either int64_t
215 // and TimeSpan, and the constructor doesn't know which
216 // of the two types it is.
217 explicit Value (gint64 i
) {};
219 void Copy (const Value
& other
);
224 /* @GeneratePInvoke */
225 void value_free_value (Value
*value
);
226 /* @GeneratePInvoke */
227 void value_free_value2 (/* @MarshalAs=IntPtr */ Value
*value
);
231 #endif /* MOON_VALUE_H */