Logo Search packages:      
Sourcecode: caribou version File versions  Download package

xml-deserializer.c

/* xml-deserializer.c generated by valac 0.13.3, the Vala compiler
 * generated from xml-deserializer.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <stdio.h>
#include <float.h>
#include <math.h>


#define CARIBOU_TYPE_XML_DESERIALIZER (caribou_xml_deserializer_get_type ())
#define CARIBOU_XML_DESERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializer))
#define CARIBOU_XML_DESERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializerClass))
#define CARIBOU_IS_XML_DESERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_XML_DESERIALIZER))
#define CARIBOU_IS_XML_DESERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_XML_DESERIALIZER))
#define CARIBOU_XML_DESERIALIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializerClass))

typedef struct _CaribouXmlDeserializer CaribouXmlDeserializer;
typedef struct _CaribouXmlDeserializerClass CaribouXmlDeserializerClass;
typedef struct _CaribouXmlDeserializerPrivate CaribouXmlDeserializerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))

#define CARIBOU_TYPE_GROUP_MODEL (caribou_group_model_get_type ())
#define CARIBOU_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModel))
#define CARIBOU_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))
#define CARIBOU_IS_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_IS_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_GROUP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))

typedef struct _CaribouGroupModel CaribouGroupModel;
typedef struct _CaribouGroupModelClass CaribouGroupModelClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define CARIBOU_TYPE_SCANNABLE_GROUP (caribou_scannable_group_get_type ())
#define CARIBOU_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup))
#define CARIBOU_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))
#define CARIBOU_IS_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_IS_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_SCANNABLE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))

typedef struct _CaribouScannableGroup CaribouScannableGroup;
typedef struct _CaribouScannableGroupClass CaribouScannableGroupClass;

#define CARIBOU_TYPE_LEVEL_MODEL (caribou_level_model_get_type ())
#define CARIBOU_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModel))
#define CARIBOU_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))
#define CARIBOU_IS_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_IS_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_LEVEL_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))

typedef struct _CaribouLevelModel CaribouLevelModel;
typedef struct _CaribouLevelModelClass CaribouLevelModelClass;

#define CARIBOU_TYPE_ROW_MODEL (caribou_row_model_get_type ())
#define CARIBOU_ROW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ROW_MODEL, CaribouRowModel))
#define CARIBOU_ROW_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_ROW_MODEL, CaribouRowModelClass))
#define CARIBOU_IS_ROW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ROW_MODEL))
#define CARIBOU_IS_ROW_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_ROW_MODEL))
#define CARIBOU_ROW_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_ROW_MODEL, CaribouRowModelClass))

typedef struct _CaribouRowModel CaribouRowModel;
typedef struct _CaribouRowModelClass CaribouRowModelClass;

#define CARIBOU_TYPE_COLUMN_MODEL (caribou_column_model_get_type ())
#define CARIBOU_COLUMN_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModel))
#define CARIBOU_COLUMN_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModelClass))
#define CARIBOU_IS_COLUMN_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_COLUMN_MODEL))
#define CARIBOU_IS_COLUMN_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_COLUMN_MODEL))
#define CARIBOU_COLUMN_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModelClass))

typedef struct _CaribouColumnModel CaribouColumnModel;
typedef struct _CaribouColumnModelClass CaribouColumnModelClass;

#define CARIBOU_TYPE_KEY_MODEL (caribou_key_model_get_type ())
#define CARIBOU_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel))
#define CARIBOU_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))
#define CARIBOU_IS_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_IS_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_KEY_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))

typedef struct _CaribouKeyModel CaribouKeyModel;
typedef struct _CaribouKeyModelClass CaribouKeyModelClass;

struct _CaribouXmlDeserializer {
      GObject parent_instance;
      CaribouXmlDeserializerPrivate * priv;
};

struct _CaribouXmlDeserializerClass {
      GObjectClass parent_class;
};


static gpointer caribou_xml_deserializer_parent_class = NULL;

GType caribou_xml_deserializer_get_type (void) G_GNUC_CONST;
enum  {
      CARIBOU_XML_DESERIALIZER_DUMMY_PROPERTY
};
gchar* caribou_xml_deserializer_get_layout_file_inner (const gchar* data_dir, const gchar* group, const gchar* variant);
gchar* caribou_xml_deserializer_get_layout_file (const gchar* keyboard_type, const gchar* group, const gchar* variant, GError** error);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
GType caribou_group_model_get_type (void) G_GNUC_CONST;
CaribouGroupModel* caribou_xml_deserializer_load_group (const gchar* keyboard_type, const gchar* group, const gchar* variant);
CaribouGroupModel* caribou_group_model_new (const gchar* group, const gchar* variant);
CaribouGroupModel* caribou_group_model_construct (GType object_type, const gchar* group, const gchar* variant);
void caribou_xml_deserializer_create_levels_from_xml (CaribouGroupModel* group, xmlNode* node);
CaribouLevelModel* caribou_level_model_new (const gchar* mode);
CaribouLevelModel* caribou_level_model_construct (GType object_type, const gchar* mode);
GType caribou_scannable_group_get_type (void) G_GNUC_CONST;
GType caribou_level_model_get_type (void) G_GNUC_CONST;
void caribou_xml_deserializer_load_rows (CaribouLevelModel* level, xmlNode* node);
void caribou_group_model_add_level (CaribouGroupModel* self, const gchar* lname, CaribouLevelModel* level);
CaribouRowModel* caribou_row_model_new (void);
CaribouRowModel* caribou_row_model_construct (GType object_type);
GType caribou_row_model_get_type (void) G_GNUC_CONST;
void caribou_level_model_add_row (CaribouLevelModel* self, CaribouRowModel* row);
void caribou_xml_deserializer_load_column (CaribouRowModel* row, const gchar* align, xmlNode* node);
CaribouColumnModel* caribou_column_model_new (void);
CaribouColumnModel* caribou_column_model_construct (GType object_type);
GType caribou_column_model_get_type (void) G_GNUC_CONST;
void caribou_row_model_add_column (CaribouRowModel* self, CaribouColumnModel* column);
GType caribou_key_model_get_type (void) G_GNUC_CONST;
void caribou_column_model_add_key (CaribouColumnModel* self, CaribouKeyModel* key);
CaribouKeyModel* caribou_xml_deserializer_load_key (xmlNode* node, const gchar* align);
CaribouKeyModel* caribou_key_model_new (const gchar* name);
CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name);
void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value);
void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key);
CaribouXmlDeserializer* caribou_xml_deserializer_new (void);
CaribouXmlDeserializer* caribou_xml_deserializer_construct (GType object_type);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


static const gchar* string_to_string (const gchar* self) {
      const gchar* result = NULL;
      g_return_val_if_fail (self != NULL, NULL);
      result = self;
      return result;
}


gchar* caribou_xml_deserializer_get_layout_file_inner (const gchar* data_dir, const gchar* group, const gchar* variant) {
      gchar* result = NULL;
      const gchar* _tmp0_;
      const gchar* _tmp1_ = NULL;
      const gchar* _tmp2_;
      const gchar* _tmp3_ = NULL;
      gchar* _tmp4_ = NULL;
      const gchar* _tmp5_;
      const gchar* _tmp6_ = NULL;
      gchar* _tmp7_ = NULL;
      gchar** _tmp8_ = NULL;
      gchar** files;
      gint files_length1;
      gint _files_size_;
      gchar** _tmp9_;
      gint _tmp9__length1;
      g_return_val_if_fail (data_dir != NULL, NULL);
      g_return_val_if_fail (group != NULL, NULL);
      g_return_val_if_fail (variant != NULL, NULL);
      _tmp0_ = group;
      _tmp1_ = string_to_string (_tmp0_);
      _tmp2_ = variant;
      _tmp3_ = string_to_string (_tmp2_);
      _tmp4_ = g_strconcat (_tmp1_, "_", _tmp3_, ".xml", NULL);
      _tmp5_ = group;
      _tmp6_ = string_to_string (_tmp5_);
      _tmp7_ = g_strconcat (_tmp6_, ".xml", NULL);
      _tmp8_ = g_new0 (gchar*, 2 + 1);
      _tmp8_[0] = _tmp4_;
      _tmp8_[1] = _tmp7_;
      files = _tmp8_;
      files_length1 = 2;
      _files_size_ = files_length1;
      _tmp9_ = files;
      _tmp9__length1 = files_length1;
      {
            gchar** fn_collection = NULL;
            gint fn_collection_length1 = 0;
            gint _fn_collection_size_ = 0;
            gint fn_it = 0;
            fn_collection = _tmp9_;
            fn_collection_length1 = _tmp9__length1;
            for (fn_it = 0; fn_it < _tmp9__length1; fn_it = fn_it + 1) {
                  gchar* _tmp10_;
                  gchar* fn = NULL;
                  _tmp10_ = g_strdup (fn_collection[fn_it]);
                  fn = _tmp10_;
                  {
                        const gchar* _tmp11_;
                        const gchar* _tmp12_;
                        gchar* _tmp13_ = NULL;
                        gchar* layout_fn;
                        const gchar* _tmp14_;
                        GFile* _tmp15_ = NULL;
                        GFile* fp;
                        GFile* _tmp16_;
                        gboolean _tmp17_ = FALSE;
                        _tmp11_ = data_dir;
                        _tmp12_ = fn;
                        _tmp13_ = g_build_filename (_tmp11_, _tmp12_, NULL);
                        layout_fn = _tmp13_;
                        _tmp14_ = layout_fn;
                        _tmp15_ = g_file_new_for_path (_tmp14_);
                        fp = _tmp15_;
                        _tmp16_ = fp;
                        _tmp17_ = g_file_query_exists (_tmp16_, NULL);
                        if (_tmp17_) {
                              result = layout_fn;
                              _g_object_unref0 (fp);
                              _g_free0 (fn);
                              files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
                              return result;
                        }
                        _g_object_unref0 (fp);
                        _g_free0 (layout_fn);
                        _g_free0 (fn);
                  }
            }
      }
      result = NULL;
      files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
      return result;
}


static void _g_free0_ (gpointer var) {
      var = (g_free (var), NULL);
}


static void _g_list_free__g_free0_ (GList* self) {
      g_list_foreach (self, (GFunc) _g_free0_, NULL);
      g_list_free (self);
}


gchar* caribou_xml_deserializer_get_layout_file (const gchar* keyboard_type, const gchar* group, const gchar* variant, GError** error) {
      gchar* result = NULL;
      GList* dirs;
      const gchar* _tmp0_ = NULL;
      gchar* _tmp1_;
      gchar* custom_dir;
      const gchar* _tmp2_;
      const gchar* _tmp6_ = NULL;
      const gchar* _tmp7_;
      gchar* _tmp8_ = NULL;
      gchar** _tmp9_;
      gchar** _tmp10_ = NULL;
      GList* _tmp15_;
      GList* _tmp22_;
      const gchar* _tmp27_;
      const gchar* _tmp28_;
      GError* _tmp29_;
      GError * _inner_error_ = NULL;
      g_return_val_if_fail (keyboard_type != NULL, NULL);
      g_return_val_if_fail (group != NULL, NULL);
      g_return_val_if_fail (variant != NULL, NULL);
      dirs = NULL;
      _tmp0_ = g_getenv ("CARIBOU_LAYOUTS_DIR");
      _tmp1_ = g_strdup (_tmp0_);
      custom_dir = _tmp1_;
      _tmp2_ = custom_dir;
      if (_tmp2_ != NULL) {
            const gchar* _tmp3_;
            const gchar* _tmp4_;
            gchar* _tmp5_ = NULL;
            _tmp3_ = custom_dir;
            _tmp4_ = keyboard_type;
            _tmp5_ = g_build_filename (_tmp3_, "layouts", _tmp4_, NULL);
            dirs = g_list_append (dirs, _tmp5_);
      }
      _tmp6_ = g_get_user_data_dir ();
      _tmp7_ = keyboard_type;
      _tmp8_ = g_build_filename (_tmp6_, "caribou", "layouts", _tmp7_, NULL);
      dirs = g_list_append (dirs, _tmp8_);
      _tmp10_ = _tmp9_ = g_get_system_data_dirs ();
      {
            gchar** dir_collection = NULL;
            gint dir_collection_length1 = 0;
            gint _dir_collection_size_ = 0;
            gint dir_it = 0;
            dir_collection = _tmp10_;
            dir_collection_length1 = _vala_array_length (_tmp9_);
            for (dir_it = 0; dir_it < _vala_array_length (_tmp9_); dir_it = dir_it + 1) {
                  gchar* _tmp11_;
                  gchar* dir = NULL;
                  _tmp11_ = g_strdup (dir_collection[dir_it]);
                  dir = _tmp11_;
                  {
                        const gchar* _tmp12_;
                        const gchar* _tmp13_;
                        gchar* _tmp14_ = NULL;
                        _tmp12_ = dir;
                        _tmp13_ = keyboard_type;
                        _tmp14_ = g_build_filename (_tmp12_, "caribou", "layouts", _tmp13_, NULL);
                        dirs = g_list_append (dirs, _tmp14_);
                        _g_free0 (dir);
                  }
            }
      }
      _tmp15_ = dirs;
      {
            GList* data_dir_collection = NULL;
            GList* data_dir_it = NULL;
            data_dir_collection = _tmp15_;
            for (data_dir_it = data_dir_collection; data_dir_it != NULL; data_dir_it = data_dir_it->next) {
                  gchar* _tmp16_;
                  gchar* data_dir = NULL;
                  _tmp16_ = g_strdup ((const gchar*) data_dir_it->data);
                  data_dir = _tmp16_;
                  {
                        const gchar* _tmp17_;
                        const gchar* _tmp18_;
                        const gchar* _tmp19_;
                        gchar* _tmp20_ = NULL;
                        gchar* fn;
                        const gchar* _tmp21_;
                        _tmp17_ = data_dir;
                        _tmp18_ = group;
                        _tmp19_ = variant;
                        _tmp20_ = caribou_xml_deserializer_get_layout_file_inner (_tmp17_, _tmp18_, _tmp19_);
                        fn = _tmp20_;
                        _tmp21_ = fn;
                        if (_tmp21_ != NULL) {
                              result = fn;
                              _g_free0 (data_dir);
                              _g_free0 (custom_dir);
                              __g_list_free__g_free0_0 (dirs);
                              return result;
                        }
                        _g_free0 (fn);
                        _g_free0 (data_dir);
                  }
            }
      }
      _tmp22_ = dirs;
      {
            GList* data_dir_collection = NULL;
            GList* data_dir_it = NULL;
            data_dir_collection = _tmp22_;
            for (data_dir_it = data_dir_collection; data_dir_it != NULL; data_dir_it = data_dir_it->next) {
                  gchar* _tmp23_;
                  gchar* data_dir = NULL;
                  _tmp23_ = g_strdup ((const gchar*) data_dir_it->data);
                  data_dir = _tmp23_;
                  {
                        const gchar* _tmp24_;
                        gchar* _tmp25_ = NULL;
                        gchar* fn;
                        const gchar* _tmp26_;
                        _tmp24_ = data_dir;
                        _tmp25_ = caribou_xml_deserializer_get_layout_file_inner (_tmp24_, "us", "");
                        fn = _tmp25_;
                        _tmp26_ = fn;
                        if (_tmp26_ != NULL) {
                              result = fn;
                              _g_free0 (data_dir);
                              _g_free0 (custom_dir);
                              __g_list_free__g_free0_0 (dirs);
                              return result;
                        }
                        _g_free0 (fn);
                        _g_free0 (data_dir);
                  }
            }
      }
      _tmp27_ = group;
      _tmp28_ = variant;
      _tmp29_ = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Could not find layout file for %s %s", _tmp27_, _tmp28_);
      _inner_error_ = _tmp29_;
      if (_inner_error_->domain == G_IO_ERROR) {
            g_propagate_error (error, _inner_error_);
            _g_free0 (custom_dir);
            __g_list_free__g_free0_0 (dirs);
            return NULL;
      } else {
            _g_free0 (custom_dir);
            __g_list_free__g_free0_0 (dirs);
            g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
            g_clear_error (&_inner_error_);
            return NULL;
      }
      _g_free0 (custom_dir);
      __g_list_free__g_free0_0 (dirs);
}


CaribouGroupModel* caribou_xml_deserializer_load_group (const gchar* keyboard_type, const gchar* group, const gchar* variant) {
      CaribouGroupModel* result = NULL;
      xmlDoc* doc = NULL;
      const gchar* _tmp12_;
      const gchar* _tmp13_;
      CaribouGroupModel* _tmp14_;
      CaribouGroupModel* grp;
      xmlDoc* _tmp15_;
      xmlNode* _tmp16_;
      xmlNode* node;
      CaribouGroupModel* _tmp17_;
      xmlNode* _tmp18_;
      xmlDoc* _tmp19_;
      GError * _inner_error_ = NULL;
      g_return_val_if_fail (keyboard_type != NULL, NULL);
      g_return_val_if_fail (group != NULL, NULL);
      g_return_val_if_fail (variant != NULL, NULL);
      {
            const gchar* _tmp0_;
            const gchar* _tmp1_;
            const gchar* _tmp2_;
            gchar* _tmp3_ = NULL;
            gchar* fn;
            const gchar* _tmp4_;
            xmlDoc* _tmp5_ = NULL;
            xmlDoc* _tmp6_;
            _tmp0_ = keyboard_type;
            _tmp1_ = group;
            _tmp2_ = variant;
            _tmp3_ = caribou_xml_deserializer_get_layout_file (_tmp0_, _tmp1_, _tmp2_, &_inner_error_);
            fn = _tmp3_;
            if (_inner_error_ != NULL) {
                  goto __catch1_g_error;
            }
            _tmp4_ = fn;
            _tmp5_ = xmlParseFile (_tmp4_);
            doc = _tmp5_;
            _tmp6_ = doc;
            if (_tmp6_ == NULL) {
                  const gchar* _tmp7_;
                  GError* _tmp8_;
                  _tmp7_ = fn;
                  _tmp8_ = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, "Cannot load XML text reader for %s", _tmp7_);
                  _inner_error_ = _tmp8_;
                  _g_free0 (fn);
                  goto __catch1_g_error;
            }
            _g_free0 (fn);
      }
      goto __finally1;
      __catch1_g_error:
      {
            GError* e = NULL;
            FILE* _tmp9_;
            GError* _tmp10_;
            const gchar* _tmp11_;
            e = _inner_error_;
            _inner_error_ = NULL;
            _tmp9_ = stdout;
            _tmp10_ = e;
            _tmp11_ = _tmp10_->message;
            fprintf (_tmp9_, "Failed to load XML: %s\n", _tmp11_);
            result = NULL;
            _g_error_free0 (e);
            return result;
      }
      __finally1:
      if (_inner_error_ != NULL) {
            g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
            g_clear_error (&_inner_error_);
            return NULL;
      }
      _tmp12_ = group;
      _tmp13_ = variant;
      _tmp14_ = caribou_group_model_new (_tmp12_, _tmp13_);
      grp = _tmp14_;
      _tmp15_ = doc;
      _tmp16_ = _tmp15_->children;
      node = _tmp16_;
      _tmp17_ = grp;
      _tmp18_ = node;
      caribou_xml_deserializer_create_levels_from_xml (_tmp17_, _tmp18_);
      _tmp19_ = doc;
      xmlFreeDoc (_tmp19_);
      xmlCleanupParser ();
      result = grp;
      return result;
}


void caribou_xml_deserializer_create_levels_from_xml (CaribouGroupModel* group, xmlNode* node) {
      xmlNode* _tmp0_;
      const gchar* _tmp1_;
      g_return_if_fail (group != NULL);
      _tmp0_ = node;
      _tmp1_ = _tmp0_->name;
      g_assert (g_strcmp0 (_tmp1_, "layout") == 0);
      {
            xmlNode* _tmp2_;
            xmlNode* _tmp3_;
            xmlNode* iter;
            _tmp2_ = node;
            _tmp3_ = _tmp2_->children;
            iter = _tmp3_;
            {
                  gboolean _tmp4_;
                  _tmp4_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp5_;
                        xmlNode* _tmp8_;
                        xmlNode* _tmp9_;
                        xmlElementType _tmp10_;
                        xmlNode* _tmp11_;
                        gchar* _tmp12_ = NULL;
                        gchar* levelname;
                        xmlNode* _tmp13_;
                        gchar* _tmp14_ = NULL;
                        gchar* mode;
                        const gchar* _tmp15_;
                        CaribouLevelModel* _tmp16_;
                        CaribouLevelModel* level;
                        CaribouLevelModel* _tmp17_;
                        xmlNode* _tmp18_;
                        CaribouGroupModel* _tmp19_;
                        const gchar* _tmp20_;
                        CaribouLevelModel* _tmp21_;
                        _tmp5_ = _tmp4_;
                        if (!_tmp5_) {
                              xmlNode* _tmp6_;
                              xmlNode* _tmp7_;
                              _tmp6_ = iter;
                              _tmp7_ = _tmp6_->next;
                              iter = _tmp7_;
                        }
                        _tmp4_ = FALSE;
                        _tmp8_ = iter;
                        if (!(_tmp8_ != NULL)) {
                              break;
                        }
                        _tmp9_ = iter;
                        _tmp10_ = _tmp9_->type;
                        if (_tmp10_ != XML_ELEMENT_NODE) {
                              continue;
                        }
                        _tmp11_ = iter;
                        _tmp12_ = xmlGetProp (_tmp11_, "name");
                        levelname = _tmp12_;
                        _tmp13_ = iter;
                        _tmp14_ = xmlGetProp (_tmp13_, "mode");
                        mode = _tmp14_;
                        _tmp15_ = mode;
                        _tmp16_ = caribou_level_model_new (_tmp15_);
                        level = _tmp16_;
                        _tmp17_ = level;
                        _tmp18_ = iter;
                        caribou_xml_deserializer_load_rows (_tmp17_, _tmp18_);
                        _tmp19_ = group;
                        _tmp20_ = levelname;
                        _tmp21_ = level;
                        caribou_group_model_add_level (_tmp19_, _tmp20_, _tmp21_);
                        _g_object_unref0 (level);
                        _g_free0 (mode);
                        _g_free0 (levelname);
                  }
            }
      }
}


void caribou_xml_deserializer_load_rows (CaribouLevelModel* level, xmlNode* node) {
      xmlNode* _tmp0_;
      const gchar* _tmp1_;
      g_return_if_fail (level != NULL);
      _tmp0_ = node;
      _tmp1_ = _tmp0_->name;
      g_assert (g_strcmp0 (_tmp1_, "level") == 0);
      {
            xmlNode* _tmp2_;
            xmlNode* _tmp3_;
            xmlNode* i;
            _tmp2_ = node;
            _tmp3_ = _tmp2_->children;
            i = _tmp3_;
            {
                  gboolean _tmp4_;
                  _tmp4_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp5_;
                        xmlNode* _tmp8_;
                        xmlNode* _tmp9_;
                        xmlElementType _tmp10_;
                        CaribouRowModel* _tmp11_;
                        CaribouRowModel* row;
                        CaribouLevelModel* _tmp12_;
                        CaribouRowModel* _tmp13_;
                        _tmp5_ = _tmp4_;
                        if (!_tmp5_) {
                              xmlNode* _tmp6_;
                              xmlNode* _tmp7_;
                              _tmp6_ = i;
                              _tmp7_ = _tmp6_->next;
                              i = _tmp7_;
                        }
                        _tmp4_ = FALSE;
                        _tmp8_ = i;
                        if (!(_tmp8_ != NULL)) {
                              break;
                        }
                        _tmp9_ = i;
                        _tmp10_ = _tmp9_->type;
                        if (_tmp10_ != XML_ELEMENT_NODE) {
                              continue;
                        }
                        _tmp11_ = caribou_row_model_new ();
                        row = _tmp11_;
                        _tmp12_ = level;
                        _tmp13_ = row;
                        caribou_level_model_add_row (_tmp12_, _tmp13_);
                        {
                              xmlNode* _tmp14_;
                              xmlNode* _tmp15_;
                              xmlNode* i2;
                              _tmp14_ = i;
                              _tmp15_ = _tmp14_->children;
                              i2 = _tmp15_;
                              {
                                    gboolean _tmp16_;
                                    _tmp16_ = TRUE;
                                    while (TRUE) {
                                          gboolean _tmp17_;
                                          xmlNode* _tmp20_;
                                          xmlNode* _tmp21_;
                                          xmlElementType _tmp22_;
                                          xmlNode* _tmp23_;
                                          const gchar* _tmp24_;
                                          CaribouRowModel* _tmp30_;
                                          xmlNode* _tmp31_;
                                          gchar* _tmp32_ = NULL;
                                          gchar* _tmp33_;
                                          xmlNode* _tmp34_;
                                          _tmp17_ = _tmp16_;
                                          if (!_tmp17_) {
                                                xmlNode* _tmp18_;
                                                xmlNode* _tmp19_;
                                                _tmp18_ = i2;
                                                _tmp19_ = _tmp18_->next;
                                                i2 = _tmp19_;
                                          }
                                          _tmp16_ = FALSE;
                                          _tmp20_ = i2;
                                          if (!(_tmp20_ != NULL)) {
                                                break;
                                          }
                                          _tmp21_ = i2;
                                          _tmp22_ = _tmp21_->type;
                                          if (_tmp22_ != XML_ELEMENT_NODE) {
                                                continue;
                                          }
                                          _tmp23_ = i2;
                                          _tmp24_ = _tmp23_->name;
                                          if (g_strcmp0 (_tmp24_, "key") == 0) {
                                                CaribouRowModel* _tmp25_;
                                                xmlNode* _tmp26_;
                                                gchar* _tmp27_ = NULL;
                                                gchar* _tmp28_;
                                                xmlNode* _tmp29_;
                                                _tmp25_ = row;
                                                _tmp26_ = i;
                                                _tmp27_ = xmlGetProp (_tmp26_, "align");
                                                _tmp28_ = _tmp27_;
                                                _tmp29_ = i;
                                                caribou_xml_deserializer_load_column (_tmp25_, _tmp28_, _tmp29_);
                                                _g_free0 (_tmp28_);
                                                break;
                                          }
                                          _tmp30_ = row;
                                          _tmp31_ = i2;
                                          _tmp32_ = xmlGetProp (_tmp31_, "align");
                                          _tmp33_ = _tmp32_;
                                          _tmp34_ = i2;
                                          caribou_xml_deserializer_load_column (_tmp30_, _tmp33_, _tmp34_);
                                          _g_free0 (_tmp33_);
                                    }
                              }
                        }
                        _g_object_unref0 (row);
                  }
            }
      }
}


void caribou_xml_deserializer_load_column (CaribouRowModel* row, const gchar* align, xmlNode* node) {
      CaribouColumnModel* _tmp0_;
      CaribouColumnModel* column;
      CaribouRowModel* _tmp1_;
      CaribouColumnModel* _tmp2_;
      g_return_if_fail (row != NULL);
      _tmp0_ = caribou_column_model_new ();
      column = _tmp0_;
      _tmp1_ = row;
      _tmp2_ = column;
      caribou_row_model_add_column (_tmp1_, _tmp2_);
      {
            xmlNode* _tmp3_;
            xmlNode* _tmp4_;
            xmlNode* i;
            _tmp3_ = node;
            _tmp4_ = _tmp3_->children;
            i = _tmp4_;
            {
                  gboolean _tmp5_;
                  _tmp5_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp6_;
                        xmlNode* _tmp9_;
                        xmlNode* _tmp10_;
                        xmlElementType _tmp11_;
                        CaribouColumnModel* _tmp12_;
                        xmlNode* _tmp13_;
                        const gchar* _tmp14_;
                        CaribouKeyModel* _tmp15_ = NULL;
                        CaribouKeyModel* _tmp16_;
                        _tmp6_ = _tmp5_;
                        if (!_tmp6_) {
                              xmlNode* _tmp7_;
                              xmlNode* _tmp8_;
                              _tmp7_ = i;
                              _tmp8_ = _tmp7_->next;
                              i = _tmp8_;
                        }
                        _tmp5_ = FALSE;
                        _tmp9_ = i;
                        if (!(_tmp9_ != NULL)) {
                              break;
                        }
                        _tmp10_ = i;
                        _tmp11_ = _tmp10_->type;
                        if (_tmp11_ != XML_ELEMENT_NODE) {
                              continue;
                        }
                        _tmp12_ = column;
                        _tmp13_ = i;
                        _tmp14_ = align;
                        _tmp15_ = caribou_xml_deserializer_load_key (_tmp13_, _tmp14_);
                        _tmp16_ = _tmp15_;
                        caribou_column_model_add_key (_tmp12_, _tmp16_);
                        _g_object_unref0 (_tmp16_);
                  }
            }
      }
      _g_object_unref0 (column);
}


static gdouble double_parse (const gchar* str) {
      gdouble result = 0.0;
      const gchar* _tmp0_;
      gdouble _tmp1_ = 0.0;
      g_return_val_if_fail (str != NULL, 0.0);
      _tmp0_ = str;
      _tmp1_ = g_ascii_strtod (_tmp0_, NULL);
      result = _tmp1_;
      return result;
}


CaribouKeyModel* caribou_xml_deserializer_load_key (xmlNode* node, const gchar* align) {
      CaribouKeyModel* result = NULL;
      xmlNode* _tmp0_;
      const gchar* _tmp1_;
      xmlNode* _tmp2_;
      gchar* _tmp3_ = NULL;
      gchar* name;
      const gchar* _tmp4_;
      const gchar* _tmp5_;
      CaribouKeyModel* _tmp6_;
      CaribouKeyModel* key;
      const gchar* _tmp7_;
      _tmp0_ = node;
      _tmp1_ = _tmp0_->name;
      g_assert (g_strcmp0 (_tmp1_, "key") == 0);
      _tmp2_ = node;
      _tmp3_ = xmlGetProp (_tmp2_, "name");
      name = _tmp3_;
      _tmp4_ = name;
      g_assert (_tmp4_ != NULL);
      _tmp5_ = name;
      _tmp6_ = caribou_key_model_new (_tmp5_);
      key = _tmp6_;
      _tmp7_ = align;
      if (_tmp7_ != NULL) {
            CaribouKeyModel* _tmp8_;
            const gchar* _tmp9_;
            _tmp8_ = key;
            _tmp9_ = align;
            caribou_key_model_set_align (_tmp8_, _tmp9_);
      }
      {
            xmlNode* _tmp10_;
            xmlAttr* _tmp11_;
            xmlAttr* prop;
            _tmp10_ = node;
            _tmp11_ = _tmp10_->properties;
            prop = _tmp11_;
            {
                  gboolean _tmp12_;
                  _tmp12_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp13_;
                        xmlAttr* _tmp16_;
                        xmlAttr* _tmp17_;
                        const gchar* _tmp18_;
                        _tmp13_ = _tmp12_;
                        if (!_tmp13_) {
                              xmlAttr* _tmp14_;
                              xmlAttr* _tmp15_;
                              _tmp14_ = prop;
                              _tmp15_ = _tmp14_->next;
                              prop = _tmp15_;
                        }
                        _tmp12_ = FALSE;
                        _tmp16_ = prop;
                        if (!(_tmp16_ != NULL)) {
                              break;
                        }
                        _tmp17_ = prop;
                        _tmp18_ = _tmp17_->name;
                        if (g_strcmp0 (_tmp18_, "toggle") == 0) {
                              CaribouKeyModel* _tmp19_;
                              xmlAttr* _tmp20_;
                              xmlNode* _tmp21_;
                              const gchar* _tmp22_;
                              _tmp19_ = key;
                              _tmp20_ = prop;
                              _tmp21_ = _tmp20_->children;
                              _tmp22_ = _tmp21_->content;
                              caribou_key_model_set_toggle (_tmp19_, _tmp22_);
                        } else {
                              xmlAttr* _tmp23_;
                              const gchar* _tmp24_;
                              _tmp23_ = prop;
                              _tmp24_ = _tmp23_->name;
                              if (g_strcmp0 (_tmp24_, "align") == 0) {
                                    CaribouKeyModel* _tmp25_;
                                    xmlAttr* _tmp26_;
                                    xmlNode* _tmp27_;
                                    const gchar* _tmp28_;
                                    _tmp25_ = key;
                                    _tmp26_ = prop;
                                    _tmp27_ = _tmp26_->children;
                                    _tmp28_ = _tmp27_->content;
                                    caribou_key_model_set_align (_tmp25_, _tmp28_);
                              } else {
                                    xmlAttr* _tmp29_;
                                    const gchar* _tmp30_;
                                    _tmp29_ = prop;
                                    _tmp30_ = _tmp29_->name;
                                    if (g_strcmp0 (_tmp30_, "width") == 0) {
                                          CaribouKeyModel* _tmp31_;
                                          xmlAttr* _tmp32_;
                                          xmlNode* _tmp33_;
                                          const gchar* _tmp34_;
                                          gdouble _tmp35_ = 0.0;
                                          _tmp31_ = key;
                                          _tmp32_ = prop;
                                          _tmp33_ = _tmp32_->children;
                                          _tmp34_ = _tmp33_->content;
                                          _tmp35_ = double_parse (_tmp34_);
                                          caribou_key_model_set_width (_tmp31_, _tmp35_);
                                    }
                              }
                        }
                  }
            }
      }
      {
            xmlNode* _tmp36_;
            xmlNode* _tmp37_;
            xmlNode* i;
            _tmp36_ = node;
            _tmp37_ = _tmp36_->children;
            i = _tmp37_;
            {
                  gboolean _tmp38_;
                  _tmp38_ = TRUE;
                  while (TRUE) {
                        gboolean _tmp39_;
                        xmlNode* _tmp42_;
                        xmlNode* _tmp43_;
                        xmlElementType _tmp44_;
                        CaribouKeyModel* _tmp45_;
                        xmlNode* _tmp46_;
                        CaribouKeyModel* _tmp47_ = NULL;
                        CaribouKeyModel* _tmp48_;
                        _tmp39_ = _tmp38_;
                        if (!_tmp39_) {
                              xmlNode* _tmp40_;
                              xmlNode* _tmp41_;
                              _tmp40_ = i;
                              _tmp41_ = _tmp40_->next;
                              i = _tmp41_;
                        }
                        _tmp38_ = FALSE;
                        _tmp42_ = i;
                        if (!(_tmp42_ != NULL)) {
                              break;
                        }
                        _tmp43_ = i;
                        _tmp44_ = _tmp43_->type;
                        if (_tmp44_ != XML_ELEMENT_NODE) {
                              continue;
                        }
                        _tmp45_ = key;
                        _tmp46_ = i;
                        _tmp47_ = caribou_xml_deserializer_load_key (_tmp46_, NULL);
                        _tmp48_ = _tmp47_;
                        caribou_key_model_add_subkey (_tmp45_, _tmp48_);
                        _g_object_unref0 (_tmp48_);
                  }
            }
      }
      result = key;
      _g_free0 (name);
      return result;
}


CaribouXmlDeserializer* caribou_xml_deserializer_construct (GType object_type) {
      CaribouXmlDeserializer * self = NULL;
      self = (CaribouXmlDeserializer*) g_object_new (object_type, NULL);
      return self;
}


CaribouXmlDeserializer* caribou_xml_deserializer_new (void) {
      return caribou_xml_deserializer_construct (CARIBOU_TYPE_XML_DESERIALIZER);
}


static void caribou_xml_deserializer_class_init (CaribouXmlDeserializerClass * klass) {
      caribou_xml_deserializer_parent_class = g_type_class_peek_parent (klass);
}


static void caribou_xml_deserializer_instance_init (CaribouXmlDeserializer * self) {
}


GType caribou_xml_deserializer_get_type (void) {
      static volatile gsize caribou_xml_deserializer_type_id__volatile = 0;
      if (g_once_init_enter (&caribou_xml_deserializer_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (CaribouXmlDeserializerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_xml_deserializer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouXmlDeserializer), 0, (GInstanceInitFunc) caribou_xml_deserializer_instance_init, NULL };
            GType caribou_xml_deserializer_type_id;
            caribou_xml_deserializer_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouXmlDeserializer", &g_define_type_info, 0);
            g_once_init_leave (&caribou_xml_deserializer_type_id__volatile, caribou_xml_deserializer_type_id);
      }
      return caribou_xml_deserializer_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
      if ((array != NULL) && (destroy_func != NULL)) {
            int i;
            for (i = 0; i < array_length; i = i + 1) {
                  if (((gpointer*) array)[i] != NULL) {
                        destroy_func (((gpointer*) array)[i]);
                  }
            }
      }
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
      _vala_array_destroy (array, array_length, destroy_func);
      g_free (array);
}


static gint _vala_array_length (gpointer array) {
      int length;
      length = 0;
      if (array) {
            while (((gpointer*) array)[length]) {
                  length++;
            }
      }
      return length;
}




Generated by  Doxygen 1.6.0   Back to index