gen/osx_factory_gen.c
Go to the documentation of this file.
00001 /* THIS IS A GENERATED FILE, DO NOT EDIT!!! */
00027 /* 
00028  * See below for forward declarations that must be defined manually in the
00029  * implementing C file.
00030  */
00031 
00032 #include "osx_factory_gen.h"
00033 #include "gui_factory_friend_gen.h"
00034 
00035 /* Forward declarations */
00036 /* Begin structs that must be defined manually. */
00037 
00042 typedef struct osx_factory_data_st_ *osx_factory_data_handle;
00043 
00044 /* End structs that must be defined manually. */
00045 
00046 /* Forward declarations */
00047 /* Begin functions that must be defined manually. */
00048 
00049 static void
00050 osx_factory_data_delete(osx_factory_data_handle *osx_factory_data_h);
00051 
00052 static bool
00053 osx_factory_data_create(osx_factory_data_handle *osx_factory_data_h, void *context);
00054 
00055 static button_handle
00056 osx_factory_gui_factory_create_button(gui_factory_handle gui_factory_h);
00057 
00058 /* End functions that must be defined manually. */
00059 
00061 typedef struct osx_factory_st_ {
00063     gui_factory_st gui_factory;
00065     osx_factory_data_handle osx_factory_data_h;
00066 } osx_factory_st;
00067 
00068 /*
00069  * This is C, we need explicit casts to each of an object's parent classes.
00070  */
00071 
00078 static osx_factory_handle
00079 gui_factory_cast_to_osx_factory (gui_factory_handle gui_factory_h)
00080 {
00081     osx_factory_handle osx_factory_h = NULL;
00082 
00083     if (NULL != gui_factory_h) {
00084         osx_factory_h = (osx_factory_handle) ((uint8_t *) gui_factory_h -
00085             offsetof(osx_factory_st, gui_factory));
00086     }
00087 
00088     return (osx_factory_h);
00089 }
00090 
00097 gui_factory_handle
00098 osx_factory_cast_to_gui_factory (osx_factory_handle osx_factory_h)
00099 {
00100     gui_factory_handle gui_factory_h = NULL;
00101 
00102     if (NULL != osx_factory_h) {
00103         gui_factory_h = &(osx_factory_h->gui_factory);
00104     }
00105 
00106     return (gui_factory_h);
00107 }
00108 
00116 void
00117 osx_factory_delete (osx_factory_handle osx_factory_h)
00118 {
00119     if (NULL == osx_factory_h) {
00120         return;
00121     }
00122 
00123     osx_factory_data_delete(&(osx_factory_h->osx_factory_data_h));
00124 
00125     gui_factory_friend_delete(&(osx_factory_h->gui_factory));
00126 
00127     free(osx_factory_h);
00128 }
00129 
00135 static void
00136 osx_factory_gui_factory_delete (gui_factory_handle gui_factory_h)
00137 {
00138     if (NULL == gui_factory_h) {
00139         return;
00140     }
00141 
00142     osx_factory_delete(gui_factory_cast_to_osx_factory(gui_factory_h));
00143 }
00144 
00148 static gui_factory_vtable_st gui_factory_vtable = {
00149     osx_factory_gui_factory_create_button,
00150     osx_factory_gui_factory_delete
00151 };
00152 
00160 static bool
00161 osx_factory_init (osx_factory_handle osx_factory_h, void *context)
00162 {
00163     bool rc = false;
00164     bool gui_factory_initialized = false;
00165     bool osx_factory_data_created = false;
00166 
00167     if (NULL == osx_factory_h) {
00168         return (false);
00169     }
00170 
00171     rc = gui_factory_init(&(osx_factory_h->gui_factory));
00172     if (!rc) {
00173         goto err_exit;
00174     }
00175     gui_factory_initialized = true;
00176 
00177     rc = gui_factory_set_vtable(&(osx_factory_h->gui_factory),
00178              &gui_factory_vtable);
00179     if (!rc) {
00180         goto err_exit;
00181     }
00182 
00183     rc = osx_factory_data_create(&(osx_factory_h->osx_factory_data_h), context);
00184     if (!rc) {
00185         goto err_exit;
00186     }
00187     osx_factory_data_created = true;
00188 
00189     return (true);
00190 
00191 err_exit:
00192 
00193     if (osx_factory_data_created) {
00194         osx_factory_data_delete(&(osx_factory_h->osx_factory_data_h));
00195     }
00196 
00197     if (gui_factory_initialized) {
00198         gui_factory_friend_delete(&(osx_factory_h->gui_factory));
00199     }
00200 
00201     return (rc);
00202 }
 All Classes Files Functions Variables Typedefs