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.
21 * ugly file containing the catchall value type we use.
37 struct RepeatBehavior
;
41 struct ManagedTypeInfo
;
46 class DependencyProperty
;
48 class AnimationStorage
;
53 #define checked_get_exact(kind, errval, mem) g_return_val_if_fail (k == (kind), errval); return mem;
54 #define checked_get_subclass(kind, castas) \
55 if (u.dependency_object == NULL || k == (kind)) \
56 return (castas*)u.dependency_object; \
57 g_return_val_if_fail (Types::IsSubclassOrSuperclassOf (types, k, kind), NULL); \
58 return (castas*)u.dependency_object;
60 #define checked_get_exact(kind, errval, mem) return mem;
61 #define checked_get_subclass(kind, castas) return (castas*)u.dependency_object;
69 Value (const Value
& v
);
70 explicit Value (Type::Kind k
);
71 explicit Value (bool z
);
72 explicit Value (double d
);
73 explicit Value (gint32 i
);
74 explicit Value (guint32 i
);
75 Value (gunichar c
, Type::Kind as
); // for use with char values.
76 Value (gint64 i
, Type::Kind as
); // Use for TimeSpan and int64 values.
78 Value (EventObject
*obj
);
79 Value (FontFamily family
);
80 Value (FontSource source
);
81 Value (FontWeight weight
);
82 Value (FontStyle style
);
83 Value (FontStretch stretch
);
84 Value (PropertyPath propertypath
);
89 Value (RepeatBehavior repeat
);
90 Value (Duration duration
);
91 Value (KeyTime keytime
);
92 Value (GridLength grid_length
);
93 Value (Thickness thickness
);
94 Value (CornerRadius radius
);
95 Value (ManagedTypeInfo type_info
);
96 Value (const char *s
, bool take
= false);
97 Value (Point
*points
, int count
);
98 Value (double *values
, int count
);
99 Value (Type::Kind
, void *npobj
);
103 // Use these to create Values with dependency objects with
104 // a reference count of 1 (giving the ownership of the object
106 // Useful in cases like this:
107 // SetValue (SomeProperty, new DependencyObject ())
108 // in which case we have to unref the newly created object.
109 static Value
* CreateUnrefPtr (EventObject
* dob
);
110 static Value
CreateUnref (EventObject
* dob
);
112 // essentially the same as the copy constructor, except it
113 // does a deep copy of DependencyObjects.
114 static Value
* Clone (Value
*v
, Types
*types
= NULL
);
117 void SetIsNull (bool isNull
);
119 bool operator!= (const Value
&v
) const;
120 bool operator== (const Value
&v
) const;
122 Value
& operator= (const Value
& other
);
124 bool Is (Deployment
*deployment
, Type::Kind type
) { return Type::IsSubclassOf (deployment
, k
, type
); }
126 bool AsBool () { checked_get_exact (Type::BOOL
, false, (bool)u
.i32
); }
127 gunichar
AsChar () { checked_get_exact (Type::CHAR
, 0, u
.c
); }
128 double AsDouble () { checked_get_exact (Type::DOUBLE
, 0.0, u
.d
); }
129 float AsFloat () { checked_get_exact (Type::FLOAT
, 0.0, u
.f
); }
130 guint64
AsUInt64 () { checked_get_exact (Type::UINT64
, 0, u
.ui64
); }
131 gint64
AsInt64 () { checked_get_exact (Type::INT64
, 0, u
.i64
); }
132 TimeSpan
AsTimeSpan () { checked_get_exact (Type::TIMESPAN
, 0, (TimeSpan
)u
.i64
); }
133 guint32
AsUInt32 () { checked_get_exact (Type::UINT32
, 0, u
.ui32
); }
134 gint32
AsInt32 () { checked_get_exact (Type::INT32
, 0, u
.i32
); }
135 Color
* AsColor () { checked_get_exact (Type::COLOR
, NULL
, u
.color
); }
136 Point
* AsPoint () { checked_get_exact (Type::POINT
, NULL
, u
.point
); }
137 Uri
* AsUri () { checked_get_exact (Type::URI
, NULL
, u
.uri
); }
138 Rect
* AsRect () { checked_get_exact (Type::RECT
, NULL
, u
.rect
); }
139 Size
* AsSize () { checked_get_exact (Type::SIZE
, NULL
, u
.size
); }
140 FontFamily
* AsFontFamily () { checked_get_exact (Type::FONTFAMILY
, NULL
, u
.fontfamily
); }
141 FontWeight
* AsFontWeight () { checked_get_exact (Type::FONTWEIGHT
, NULL
, u
.fontweight
); }
142 FontStyle
* AsFontStyle () { checked_get_exact (Type::FONTSTYLE
, NULL
, u
.fontstyle
); }
143 FontStretch
* AsFontStretch() { checked_get_exact (Type::FONTSTRETCH
, NULL
, u
.fontstretch
); }
144 FontSource
* AsFontSource () { checked_get_exact (Type::FONTSOURCE
, NULL
, u
.fontsource
); }
145 PropertyPath
* AsPropertyPath () { checked_get_exact (Type::PROPERTYPATH
, NULL
, u
.propertypath
); }
146 char* AsString () { checked_get_exact (Type::STRING
, NULL
, u
.s
); }
147 DependencyProperty
* AsDependencyProperty () { checked_get_exact (Type::DEPENDENCYPROPERTY
, NULL
, u
.dp
); }
149 void * AsManagedObject () { checked_get_exact (Type::MANAGED
, NULL
, u
.managed_object
); }
150 void * AsNPObj () { checked_get_exact (Type::NPOBJ
, NULL
, u
.npobj
); }
152 RepeatBehavior
* AsRepeatBehavior () { checked_get_exact (Type::REPEATBEHAVIOR
, NULL
, u
.repeat
); }
153 Duration
* AsDuration () { checked_get_exact (Type::DURATION
, NULL
, u
.duration
); }
154 KeyTime
* AsKeyTime () { checked_get_exact (Type::KEYTIME
, NULL
, u
.keytime
); }
155 GridLength
* AsGridLength () { checked_get_exact (Type::GRIDLENGTH
, NULL
, u
.grid_length
); }
156 Thickness
* AsThickness () { checked_get_exact (Type::THICKNESS
, NULL
, u
.thickness
); }
157 CornerRadius
* AsCornerRadius () { checked_get_exact (Type::CORNERRADIUS
, NULL
, u
.corner
); }
158 ManagedTypeInfo
* AsManagedTypeInfo () { checked_get_exact (Type::MANAGEDTYPEINFO
, NULL
, u
.type_info
); }
159 /* nullable primitives (all but bool) */
160 double* AsNullableDouble () { checked_get_exact (Type::DOUBLE
, NULL
, &u
.d
); }
161 guint64
* AsNullableUint64 () { checked_get_exact (Type::UINT64
, NULL
, &u
.ui64
); }
162 gint64
* AsNullableInt64 () { checked_get_exact (Type::INT64
, NULL
, &u
.i64
); }
163 gint32
* AsNullableInt32 () { checked_get_exact (Type::INT32
, NULL
, &u
.i32
); }
169 Type::Kind
GetKind ();
187 EventObject
*dependency_object
;
189 DependencyProperty
*dp
;
194 FontFamily
*fontfamily
;
195 FontSource
*fontsource
;
196 FontWeight
*fontweight
;
197 FontStretch
*fontstretch
;
198 FontStyle
*fontstyle
;
199 PropertyPath
*propertypath
;
200 RepeatBehavior
*repeat
;
203 GridLength
*grid_length
;
204 Thickness
*thickness
;
205 CornerRadius
*corner
;
206 ManagedTypeInfo
*type_info
;
207 void *managed_object
;
211 // You don't want to be using this ctor. it's here to help
212 // c++ recognize bad unspecified pointer args to Value ctors
213 // (it normally converts them to bool, which we handle, so you
214 // never see the error of your ways). So do the world a
215 // favor, and don't expose this ctor. :)
217 // You don't want to be using this ctor either.
218 // Use the Value (gint64, Type::Kind) ctor
219 // (Both for TimeSpan and int64_t)
220 // This one is bad because it get used by either int64_t
221 // and TimeSpan, and the constructor doesn't know which
222 // of the two types it is.
223 explicit Value (gint64 i
) {};
225 void Copy (const Value
& other
);
230 /* @GeneratePInvoke */
231 void value_free_value (Value
*value
);
232 /* @GeneratePInvoke */
233 void value_free_value2 (/* @MarshalAs=IntPtr */ Value
*value
);
237 #endif /* MOON_VALUE_H */