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.
19 class DependencyObject
;
20 class DependencyProperty
;
24 /* @CBindingRequisite */
25 typedef gint64 TimeSpan
;
26 typedef DependencyObject
*create_inst_func (void);
31 // START_MANAGED_MAPPING
35 // END_MANAGED_MAPPING
38 static Type
*Find (const char *name
);
39 static Type
*Find (Type::Kind type
);
40 static Type
*Find (const char *name
, bool ignore_case
);
42 bool IsSubclassOf (Type::Kind super
);
43 static bool IsSubclassOf (Type::Kind type
, Type::Kind super
);
45 bool IsAssignableFrom (Type::Kind type
);
46 static bool IsAssignableFrom (Type::Kind assignable
, Type::Kind type
);
48 int LookupEvent (const char *event_name
);
49 const char *LookupEventName (int id
);
50 DependencyObject
*CreateInstance ();
51 const char *GetContentPropertyName ();
53 DependencyProperty
*LookupProperty (const char *name
);
54 void AddProperty (DependencyProperty
*property
);
56 GHashTable
*CopyProperties (bool inherited
);
58 Type::Kind
GetKind () { return type
; }
59 void SetKind (Type::Kind value
) { type
= value
; }
60 Type::Kind
GetParent () { return parent
; }
61 bool IsValueType () { return is_value_type
; }
62 bool IsInterface () { return is_interface
; }
63 bool IsCustomType () { return type
> LASTTYPE
; }
64 const char *GetName () { return name
; }
65 int GetEventCount () { return total_event_count
; }
66 int GetInterfaceCount () { return interface_count
; }
67 Type::Kind
GetInterface (int i
) { return i
>= 0 && i
< interface_count
? interfaces
[i
] : Type::INVALID
; }
69 bool IsCtorVisible () { return ctor_visible
; }
72 Type (Type::Kind type
, Type::Kind parent
, bool is_value_type
, bool is_interface
,
74 int event_count
, int total_event_count
, const char **events
,
75 int interface_count
, const Type::Kind
*interfaces
, bool ctor_visible
,
76 create_inst_func
*create_inst
, const char *content_property
);
81 Type::Kind type
; // this type
82 Type::Kind parent
; // parent type, INVALID if no parent
83 bool is_value_type
; // if this type is a value type
84 bool is_interface
; // if this type is a value type
86 const char *name
; // The name as it appears in code.
89 Type::Kind
*interfaces
;
91 int event_count
; // number of events in this class
92 int total_event_count
; // number of events in this class and all base classes
93 const char **events
; // the events this class has
95 bool ctor_visible
; // if the type is instantiable in xaml, basically if the managed type has a public default ctor.
96 create_inst_func
*create_inst
; // a function pointer to create an instance of this type
98 const char *content_property
;
100 // The catch here is that SL allows us to register several DPs with the same name,
101 // and when looking up DP on name they seem to return the latest DP registered
103 GHashTable
*properties
; // Registered DependencyProperties for this type
111 ArrayList properties
;
114 void RegisterNativeTypes ();
115 void RegisterNativeProperties ();
118 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
120 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
123 /* @GenerateCBinding,Version=2.0 */
124 Type::Kind
RegisterType (const char *name
, void *gc_handle
, Type::Kind parent
, bool is_interface
, bool ctor_visible
, Type::Kind
*interfaces
, int interface_count
);
126 void AddProperty (DependencyProperty
*property
);
127 DependencyProperty
*GetProperty (int id
);
129 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
130 Type
*Find (Type::Kind type
);
131 Type
*Find (const char *name
);
132 Type
*Find (const char *name
, bool ignore_case
);
134 bool IsSubclassOf (Type::Kind type
, Type::Kind super
);
135 bool IsSubclassOrSuperclassOf (Type::Kind unknown
, Type::Kind known
);
136 static bool IsSubclassOrSuperclassOf (Types
*types
, Type::Kind unknown
, Type::Kind known
);
138 bool IsAssignableFrom (Type::Kind destination
, Type::Kind type
);
146 /* @GeneratePInvoke */
147 bool type_get_value_type (Type::Kind type
);
148 DependencyObject
*type_create_instance (Type
*type
);
149 DependencyObject
*type_create_instance_from_kind (Type::Kind kind
);
151 void types_init (void);
152 const char *type_get_name (Type::Kind type
);
153 /* @GeneratePInvoke */
154 bool type_is_dependency_object (Type::Kind type
);
156 /* @IncludeInKinds */
157 struct ManagedTypeInfo
{
161 ManagedTypeInfo (const char *assembly_name
, const char *full_name
)
163 this->assembly_name
= g_strdup (assembly_name
);
164 this->full_name
= g_strdup (full_name
);