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);
33 // START_MANAGED_MAPPING
37 // END_MANAGED_MAPPING
40 static Type
*Find (Deployment
*deployment
, const char *name
);
41 static Type
*Find (Deployment
*deployment
, Type::Kind type
);
42 static Type
*Find (Deployment
*deployment
, const char *name
, bool ignore_case
);
44 bool IsSubclassOf (Type::Kind super
);
45 static bool IsSubclassOf (Deployment
*deployment
, Type::Kind type
, Type::Kind super
);
47 bool IsAssignableFrom (Type::Kind type
);
48 static bool IsAssignableFrom (Deployment
*deployment
, Type::Kind assignable
, Type::Kind type
);
50 int LookupEvent (const char *event_name
);
51 DependencyObject
*CreateInstance ();
52 const char *GetContentPropertyName ();
54 DependencyProperty
*LookupProperty (const char *name
);
55 void AddProperty (DependencyProperty
*property
);
57 GHashTable
*CopyProperties (bool inherited
);
59 Type::Kind
GetKind () { return type
; }
60 void SetKind (Type::Kind value
) { type
= value
; }
61 bool HasParent () { return parent
!= Type::INVALID
; }
62 Type
*GetParentType ();
63 bool IsValueType () { return is_value_type
; }
64 bool IsInterface () { return is_interface
; }
65 bool IsCustomType () { return type
> LASTTYPE
; }
66 const char *GetName () { return name
; }
67 int GetEventCount () { return total_event_count
; }
68 int GetInterfaceCount () { return interface_count
; }
69 Type::Kind
GetInterface (int i
) { return i
>= 0 && i
< interface_count
? interfaces
[i
] : Type::INVALID
; }
71 bool IsCtorVisible () { return ctor_visible
; }
74 Type (Deployment
*deployment
, Type::Kind type
, Type::Kind parent
, bool is_value_type
, bool is_interface
,
76 int event_count
, int total_event_count
, const char **events
,
77 int interface_count
, const Type::Kind
*interfaces
, bool ctor_visible
,
78 create_inst_func
*create_inst
, const char *content_property
);
83 Type::Kind type
; // this type
84 Type::Kind parent
; // parent type, INVALID if no parent
85 bool is_value_type
; // if this type is a value type
86 bool is_interface
; // if this type is a value type
88 const char *name
; // The name as it appears in code.
91 Type::Kind
*interfaces
;
93 int event_count
; // number of events in this class
94 int total_event_count
; // number of events in this class and all base classes
95 const char **events
; // the events this class has
97 bool ctor_visible
; // if the type is instantiable in xaml, basically if the managed type has a public default ctor.
98 create_inst_func
*create_inst
; // a function pointer to create an instance of this type
100 const char *content_property
;
102 // The catch here is that SL allows us to register several DPs with the same name,
103 // and when looking up DP on name they seem to return the latest DP registered
105 GHashTable
*properties
; // Registered DependencyProperties for this type
106 Deployment
*deployment
;
114 ArrayList properties
;
116 void RegisterNativeTypes ();
117 void RegisterNativeProperties ();
120 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
124 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
125 Type::Kind
RegisterType (const char *name
, void *gc_handle
, Type::Kind parent
, bool is_interface
, bool ctor_visible
, /* @MarshalAs=Kind[] */Type::Kind
*interfaces
, int interface_count
);
127 void AddProperty (DependencyProperty
*property
);
128 DependencyProperty
*GetProperty (int id
);
130 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
131 Type
*Find (Type::Kind type
)
133 if ((int) type
>= types
.GetCount ())
136 return (Type
*) types
[(int) 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
);
144 bool IsSubclassOrSuperclassOf (Type::Kind unknown
, Type::Kind known
);
145 static bool IsSubclassOrSuperclassOf (Types
*types
, Type::Kind unknown
, Type::Kind known
);
148 bool IsAssignableFrom (Type::Kind destination
, Type::Kind type
);
152 void DeleteProperties ();
157 /* @GeneratePInvoke */
158 bool type_get_value_type (Type::Kind type
);
159 DependencyObject
*type_create_instance (Type
*type
);
160 DependencyObject
*type_create_instance_from_kind (Type::Kind kind
);
162 void types_init (void);
164 /* @GeneratePInvoke */
165 bool type_is_dependency_object (Type::Kind type
);