1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /** |
---|
3 | * bonobo-xobject.h: Modified Bonobo Unknown interface base implementation |
---|
4 | * |
---|
5 | * Authors: |
---|
6 | * Michael Meeks (michael@ximian.com) |
---|
7 | * |
---|
8 | * Copyright 2000 Ximian, Inc. |
---|
9 | */ |
---|
10 | #ifndef _BONOBO_X_OBJECT_H_ |
---|
11 | #define _BONOBO_X_OBJECT_H_ |
---|
12 | |
---|
13 | #include <libgnome/gnome-defs.h> |
---|
14 | #include <gtk/gtkobject.h> |
---|
15 | #include <bonobo/Bonobo.h> |
---|
16 | #include <bonobo/bonobo-object.h> |
---|
17 | |
---|
18 | BEGIN_GNOME_DECLS |
---|
19 | |
---|
20 | #define BONOBO_X_OBJECT_TYPE (bonobo_x_object_get_type ()) |
---|
21 | #define BONOBO_X_OBJECT(o) (GTK_CHECK_CAST ((o), BONOBO_X_OBJECT_TYPE, BonoboXObject)) |
---|
22 | #define BONOBO_X_OBJECT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), BONOBO_X_OBJECT_TYPE, BonoboXObjectClass)) |
---|
23 | #define BONOBO_IS_X_OBJECT(o) (GTK_CHECK_TYPE ((o), BONOBO_X_OBJECT_TYPE)) |
---|
24 | #define BONOBO_IS_X_OBJECT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), BONOBO_X_OBJECT_TYPE)) |
---|
25 | |
---|
26 | #define BONOBO_X_OBJECT_HEADER_SIZE (sizeof (BonoboObject)) |
---|
27 | |
---|
28 | /* |
---|
29 | * Macros to convert between types. |
---|
30 | * - foolproof versions to follow. |
---|
31 | */ |
---|
32 | #define BONOBO_X_OBJECT_GET_CORBA(o) ((CORBA_Object)&(o)->object) |
---|
33 | #define BONOBO_X_OBJECT_GET_SERVANT(o) ((PortableServer_Servant)&(o)->servant) |
---|
34 | #define BONOBO_X_CORBA_GET_OBJECT(o) ((BonoboXObject *)((guchar *)(o) \ |
---|
35 | - BONOBO_X_OBJECT_HEADER_SIZE)) |
---|
36 | #define BONOBO_X_CORBA_GET_SERVANT(o) ((BonoboXObject *)((guchar *)(o) \ |
---|
37 | + sizeof (struct CORBA_Object_struct) \ |
---|
38 | + sizeof (gpointer) * 4)) |
---|
39 | #define BONOBO_X_SERVANT_GET_CORBA(o) ((BonoboXObject *)((guchar *)(o) \ |
---|
40 | - sizeof (struct CORBA_Object_struct) \ |
---|
41 | - sizeof (gpointer) * 4)) |
---|
42 | #define BONOBO_X_SERVANT_GET_OBJECT(o) ((BonoboXObject *)((guchar *)(o) \ |
---|
43 | - BONOBO_X_OBJECT_HEADER_SIZE \ |
---|
44 | - sizeof (struct CORBA_Object_struct) \ |
---|
45 | - sizeof (gpointer) * 4)) |
---|
46 | |
---|
47 | typedef struct _BonoboXObject BonoboXObject; |
---|
48 | |
---|
49 | /* Detects the pointer type and returns the object reference - magic. */ |
---|
50 | BonoboXObject *bonobo_x_object (gpointer p); |
---|
51 | |
---|
52 | struct _BonoboXObject { |
---|
53 | BonoboObject base; |
---|
54 | |
---|
55 | /* Start: CORBA_Object */ |
---|
56 | struct CORBA_Object_struct object; |
---|
57 | gpointer bincompat[4]; /* expansion */ |
---|
58 | /* End: CORBA_Object */ |
---|
59 | |
---|
60 | /* Start: BonoboObjectServant */ |
---|
61 | BonoboObjectServant servant; |
---|
62 | int flags; /* discriminant */ |
---|
63 | /* End: BonoboObjectServant */ |
---|
64 | |
---|
65 | gpointer dummy; |
---|
66 | |
---|
67 | /* User data ... */ |
---|
68 | }; |
---|
69 | |
---|
70 | typedef void (*BonoboXObjectPOAFn) (PortableServer_Servant servant, |
---|
71 | CORBA_Environment *ev); |
---|
72 | |
---|
73 | typedef struct { |
---|
74 | BonoboObjectClass parent_class; |
---|
75 | |
---|
76 | BonoboXObjectPOAFn poa_init_fn; |
---|
77 | BonoboXObjectPOAFn poa_fini_fn; |
---|
78 | |
---|
79 | POA_Bonobo_Unknown__vepv *vepv; |
---|
80 | |
---|
81 | /* The offset of this class' additional epv */ |
---|
82 | int epv_struct_offset; |
---|
83 | |
---|
84 | POA_Bonobo_Unknown__epv epv; |
---|
85 | } BonoboXObjectClass; |
---|
86 | |
---|
87 | GtkType bonobo_x_object_get_type (void); |
---|
88 | |
---|
89 | /* Use GTK_STRUCT_OFFSET to calc. epv_struct_offset */ |
---|
90 | GtkType bonobo_x_type_unique (GtkType parent_type, |
---|
91 | BonoboXObjectPOAFn init_fn, |
---|
92 | BonoboXObjectPOAFn fini_fn, |
---|
93 | int epv_struct_offset, |
---|
94 | const GtkTypeInfo *info); |
---|
95 | |
---|
96 | gboolean bonobo_x_type_setup (GtkType type, |
---|
97 | BonoboXObjectPOAFn init_fn, |
---|
98 | BonoboXObjectPOAFn fini_fn, |
---|
99 | int epv_struct_offset); |
---|
100 | |
---|
101 | |
---|
102 | #define BONOBO_X_TYPE_FUNC_FULL(class_name, corba_name, parent, prefix) \ |
---|
103 | GtkType \ |
---|
104 | prefix##_get_type (void) \ |
---|
105 | { \ |
---|
106 | GtkType ptype; \ |
---|
107 | static GtkType type = 0; \ |
---|
108 | \ |
---|
109 | if (type == 0) { \ |
---|
110 | static GtkTypeInfo info = { \ |
---|
111 | #class_name, \ |
---|
112 | sizeof (class_name), \ |
---|
113 | sizeof (class_name##Class), \ |
---|
114 | (GtkClassInitFunc)prefix##_class_init, \ |
---|
115 | (GtkObjectInitFunc)prefix##_init, \ |
---|
116 | NULL, NULL, (GtkClassInitFunc) NULL \ |
---|
117 | }; \ |
---|
118 | ptype = (parent); \ |
---|
119 | type = bonobo_x_type_unique (ptype, \ |
---|
120 | POA_##corba_name##__init, POA_##corba_name##__fini, \ |
---|
121 | GTK_STRUCT_OFFSET (class_name##Class, epv), \ |
---|
122 | &info); \ |
---|
123 | } \ |
---|
124 | return type; \ |
---|
125 | } |
---|
126 | |
---|
127 | #define BONOBO_X_TYPE_FUNC(class_name, parent, prefix) \ |
---|
128 | GtkType \ |
---|
129 | prefix##_get_type (void) \ |
---|
130 | { \ |
---|
131 | GtkType ptype; \ |
---|
132 | static GtkType type = 0; \ |
---|
133 | \ |
---|
134 | if (type == 0) { \ |
---|
135 | static GtkTypeInfo info = { \ |
---|
136 | #class_name, \ |
---|
137 | sizeof (class_name), \ |
---|
138 | sizeof (class_name##Class), \ |
---|
139 | (GtkClassInitFunc)prefix##_class_init, \ |
---|
140 | (GtkObjectInitFunc)prefix##_init, \ |
---|
141 | NULL, NULL, (GtkClassInitFunc) NULL \ |
---|
142 | }; \ |
---|
143 | ptype = (parent); \ |
---|
144 | type = bonobo_x_type_unique (ptype, NULL, NULL, 0, &info); \ |
---|
145 | } \ |
---|
146 | return type; \ |
---|
147 | } |
---|
148 | |
---|
149 | END_GNOME_DECLS |
---|
150 | |
---|
151 | #endif |
---|