revert jeff's last commit since it breaks the build
[moon.git] / src / type.h.in
blob5fffb52e48bfebb7eb0b513af13383927d09ab5c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * type.h: Generated code for the type system.
5 * Contact:
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.
13 #ifndef __TYPE_H__
14 #define __TYPE_H__
16 #include <glib.h>
17 #include "list.h"
19 class Deployment;
20 class DependencyObject;
21 class DependencyProperty;
22 class Surface;
23 class Types;
25 /* @CBindingRequisite */
26 typedef gint64 TimeSpan;
27 typedef DependencyObject *create_inst_func (void);
29 class Type {
30 friend class Types;
31 public:
32 enum Kind {
33 // START_MANAGED_MAPPING
34 INVALID,
35 /*DO_KINDS*/
36 LASTTYPE,
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; }
73 ~Type ();
74 Type (Deployment *deployment, Type::Kind type, Type::Kind parent, bool is_value_type, bool is_interface,
75 const char *name,
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);
80 private:
81 Type () {}
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.
90 int interface_count;
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
104 // with that name.
105 GHashTable *properties; // Registered DependencyProperties for this type
106 Deployment *deployment;
109 class Types {
110 friend class Type;
112 private:
113 ArrayList types;
114 ArrayList properties;
116 void RegisterNativeTypes ();
117 void RegisterNativeProperties ();
119 public:
120 /* @GenerateCBinding,GeneratePInvoke,Version=2.0 */
121 Types ();
122 ~Types ();
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 ())
134 return NULL;
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);
143 #if SANITY || DEBUG
144 bool IsSubclassOrSuperclassOf (Type::Kind unknown, Type::Kind known);
145 static bool IsSubclassOrSuperclassOf (Types *types, Type::Kind unknown, Type::Kind known);
146 #endif
148 bool IsAssignableFrom (Type::Kind destination, Type::Kind type);
150 void Initialize ();
151 void Dispose ();
152 void DeleteProperties ();
155 G_BEGIN_DECLS
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);
167 G_END_DECLS
169 #endif