1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * type.h: Generated code for the type system.
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
20 class DependencyObject
;
21 class DependencyProperty
;
25 /* @CBindingRequisite */
26 typedef gint64 TimeSpan
;
27 typedef DependencyObject
*create_inst_func (void);
32 // START_MANAGED_MAPPING
36 // END_MANAGED_MAPPING
39 static Type
*Find (Deployment
*deployment
, const char *name
);
40 static Type
*Find (const char *name
);
41 static Type
*Find (Deployment
*deployment
, Type::Kind type
);
42 static Type
*Find (Type::Kind type
);
43 static Type
*Find (Deployment
*deployment
, const char *name
, bool ignore_case
);
44 static Type
*Find (const char *name
, bool ignore_case
);
46 bool IsSubclassOf (Type::Kind super
);
47 bool IsSubclassOf (Deployment
*deployment
, Type::Kind super
);
48 static bool IsSubclassOf (Deployment
*deployment
, Type::Kind type
, Type::Kind super
);
49 static bool IsSubclassOf (Type::Kind type
, Type::Kind super
);
51 bool IsAssignableFrom (Type::Kind type
);
52 bool IsAssignableFrom (Deployment
*deployment
, Type::Kind type
);
53 static bool IsAssignableFrom (Deployment
*deployment
, Type::Kind assignable
, Type::Kind type
);
54 static bool IsAssignableFrom (Type::Kind assignable
, Type::Kind type
);
56 int LookupEvent (const char *event_name
);
57 const char *LookupEventName (int id
);
58 DependencyObject
*CreateInstance ();
59 const char *GetContentPropertyName ();
61 DependencyProperty
*LookupProperty (const char *name
);
62 void AddProperty (DependencyProperty
*property
);
64 GHashTable
*CopyProperties (bool inherited
);
66 Type::Kind
GetKind () { return type
; }
67 void SetKind (Type::Kind value
) { type
= value
; }
68 Type::Kind
GetParent () { return parent
; }
69 bool IsValueType () { return is_value_type
; }
70 bool IsInterface () { return is_interface
; }
71 bool IsCustomType () { return type
> LASTTYPE
; }
72 const char *GetName () { return name
; }
73 int GetEventCount () { return total_event_count
; }
74 int GetInterfaceCount () { return interface_count
; }
75 Type::Kind
GetInterface (int i
) { return i
>= 0 && i
< interface_count
? interfaces
[i
] : Type::INVALID
; }
77 bool IsCtorVisible () { return ctor_visible
; }
80 Type (Type::Kind type
, Type::Kind parent
, bool is_value_type
, bool is_interface
,
82 int event_count
, int total_event_count
, const char **events
,
83 int interface_count
, const Type::Kind
*interfaces
, bool ctor_visible
,
84 create_inst_func
*create_inst
, const char *content_property
);
89 Type::Kind type
; // this type
90 Type::Kind parent
; // parent type, INVALID if no parent
91 bool is_value_type
; // if this type is a value type
92 bool is_interface
; // if this type is a value type
94 const char *name
; // The name as it appears in code.
97 Type::Kind
*interfaces
;
99 int event_count
; // number of events in this class
100 int total_event_count
; // number of events in this class and all base classes
101 const char **events
; // the events this class has
103 bool ctor_visible
; // if the type is instantiable in xaml, basically if the managed type has a public default ctor.
104 create_inst_func
*create_inst
; // a function pointer to create an instance of this type
106 const char *content_property
;
108 // The catch here is that SL allows us to register several DPs with the same name,
109 // and when looking up DP on name they seem to return the latest DP registered
111 GHashTable
*properties
; // Registered DependencyProperties for this type
119 ArrayList properties
;
122 void RegisterNativeTypes ();
123 void RegisterNativeProperties ();
126 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
128 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
131 /* @GenerateCBinding,Version=2.0 */
132 Type::Kind
RegisterType (const char *name
, void *gc_handle
, Type::Kind parent
, bool is_interface
, bool ctor_visible
, Type::Kind
*interfaces
, int interface_count
);
134 void AddProperty (DependencyProperty
*property
);
135 DependencyProperty
*GetProperty (int id
);
137 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
138 Type
*Find (Type::Kind type
);
139 Type
*Find (const char *name
);
140 Type
*Find (const char *name
, bool ignore_case
);
142 bool IsSubclassOf (Type::Kind type
, Type::Kind super
);
143 bool IsSubclassOrSuperclassOf (Type::Kind unknown
, Type::Kind known
);
144 static bool IsSubclassOrSuperclassOf (Types
*types
, Type::Kind unknown
, Type::Kind known
);
146 bool IsAssignableFrom (Type::Kind destination
, Type::Kind type
);
154 /* @GeneratePInvoke */
155 bool type_get_value_type (Type::Kind type
);
156 DependencyObject
*type_create_instance (Type
*type
);
157 DependencyObject
*type_create_instance_from_kind (Type::Kind kind
);
159 void types_init (void);
160 const char *type_get_name (Type::Kind type
);
161 /* @GeneratePInvoke */
162 bool type_is_dependency_object (Type::Kind type
);
164 /* @IncludeInKinds */
165 struct ManagedTypeInfo
{
169 ManagedTypeInfo (const char *assembly_name
, const char *full_name
)
171 this->assembly_name
= g_strdup (assembly_name
);
172 this->full_name
= g_strdup (full_name
);