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
);
112 bool operator!= (const Value
&v
) const;
113 bool operator== (const Value
&v
) const;
115 Value
& operator= (const Value
& other
);
117 bool Is (Type::Kind type
) { return Type::IsSubclassOf (k
, type
); }
119 bool AsBool () { checked_get_exact (Type::BOOL
, false, (bool)u
.i32
); }
120 gunichar
AsChar () { checked_get_exact (Type::CHAR
, 0, u
.c
); }
121 double AsDouble () { checked_get_exact (Type::DOUBLE
, 0.0, u
.d
); }
122 float AsFloat () { checked_get_exact (Type::FLOAT
, 0.0, u
.f
); }
123 guint64
AsUInt64 () { checked_get_exact (Type::UINT64
, 0, u
.ui64
); }
124 gint64
AsInt64 () { checked_get_exact (Type::INT64
, 0, u
.i64
); }
125 TimeSpan
AsTimeSpan () { checked_get_exact (Type::TIMESPAN
, 0, (TimeSpan
)u
.i64
); }
126 guint32
AsUInt32 () { checked_get_exact (Type::UINT32
, 0, u
.ui32
); }
127 gint32
AsInt32 () { checked_get_exact (Type::INT32
, 0, u
.i32
); }
128 Color
* AsColor () { checked_get_exact (Type::COLOR
, NULL
, u
.color
); }
129 Point
* AsPoint () { checked_get_exact (Type::POINT
, NULL
, u
.point
); }
130 Uri
* AsUri () { checked_get_exact (Type::URI
, NULL
, u
.uri
); }
131 Rect
* AsRect () { checked_get_exact (Type::RECT
, NULL
, u
.rect
); }
132 Size
* AsSize () { checked_get_exact (Type::SIZE
, NULL
, u
.size
); }
133 FontFamily
* AsFontFamily () { checked_get_exact (Type::FONTFAMILY
, NULL
, u
.fontfamily
); }
134 FontWeight
* AsFontWeight () { checked_get_exact (Type::FONTWEIGHT
, NULL
, u
.fontweight
); }
135 FontStyle
* AsFontStyle () { checked_get_exact (Type::FONTSTYLE
, NULL
, u
.fontstyle
); }
136 FontStretch
* AsFontStretch() { checked_get_exact (Type::FONTSTRETCH
, NULL
, u
.fontstretch
); }
137 FontSource
* AsFontSource () { checked_get_exact (Type::FONTSOURCE
, NULL
, u
.fontsource
); }
138 PropertyPath
* AsPropertyPath () { checked_get_exact (Type::PROPERTYPATH
, NULL
, u
.propertypath
); }
139 char* AsString () { checked_get_exact (Type::STRING
, NULL
, u
.s
); }
140 DependencyProperty
* AsDependencyProperty () { checked_get_exact (Type::DEPENDENCYPROPERTY
, NULL
, u
.dp
); }
142 void * AsManagedObject () { checked_get_exact (Type::MANAGED
, NULL
, u
.managed_object
); }
143 void * AsNPObj () { checked_get_exact (Type::NPOBJ
, NULL
, u
.npobj
); }
145 RepeatBehavior
* AsRepeatBehavior () { checked_get_exact (Type::REPEATBEHAVIOR
, NULL
, u
.repeat
); }
146 Duration
* AsDuration () { checked_get_exact (Type::DURATION
, NULL
, u
.duration
); }
147 KeyTime
* AsKeyTime () { checked_get_exact (Type::KEYTIME
, NULL
, u
.keytime
); }
148 GridLength
* AsGridLength () { checked_get_exact (Type::GRIDLENGTH
, NULL
, u
.grid_length
); }
149 Thickness
* AsThickness () { checked_get_exact (Type::THICKNESS
, NULL
, u
.thickness
); }
150 CornerRadius
* AsCornerRadius () { checked_get_exact (Type::CORNERRADIUS
, NULL
, u
.corner
); }
151 ManagedTypeInfo
* AsManagedTypeInfo () { checked_get_exact (Type::MANAGEDTYPEINFO
, NULL
, u
.type_info
); }
152 /* nullable primitives (all but bool) */
153 double* AsNullableDouble () { checked_get_exact (Type::DOUBLE
, NULL
, &u
.d
); }
154 guint64
* AsNullableUint64 () { checked_get_exact (Type::UINT64
, NULL
, &u
.ui64
); }
155 gint64
* AsNullableInt64 () { checked_get_exact (Type::INT64
, NULL
, &u
.i64
); }
156 gint32
* AsNullableInt32 () { checked_get_exact (Type::INT32
, NULL
, &u
.i32
); }
162 Type::Kind
GetKind ();
180 EventObject
*dependency_object
;
182 DependencyProperty
*dp
;
187 FontFamily
*fontfamily
;
188 FontSource
*fontsource
;
189 FontWeight
*fontweight
;
190 FontStretch
*fontstretch
;
191 FontStyle
*fontstyle
;
192 PropertyPath
*propertypath
;
193 RepeatBehavior
*repeat
;
196 GridLength
*grid_length
;
197 Thickness
*thickness
;
198 CornerRadius
*corner
;
199 ManagedTypeInfo
*type_info
;
200 void *managed_object
;
204 // You don't want to be using this ctor. it's here to help
205 // c++ recognize bad unspecified pointer args to Value ctors
206 // (it normally converts them to bool, which we handle, so you
207 // never see the error of your ways). So do the world a
208 // favor, and don't expose this ctor. :)
210 // You don't want to be using this ctor either.
211 // Use the Value (gint64, Type::Kind) ctor
212 // (Both for TimeSpan and int64_t)
213 // This one is bad because it get used by either int64_t
214 // and TimeSpan, and the constructor doesn't know which
215 // of the two types it is.
216 explicit Value (gint64 i
) {};
218 void Copy (const Value
& other
);
223 /* @GeneratePInvoke */
224 void value_free_value (Value
*value
);
225 /* @GeneratePInvoke */
226 void value_free_value2 (/* @MarshalAs=IntPtr */ Value
*value
);
230 #endif /* MOON_VALUE_H */