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

vbfpackage.c

/* vbfpackage.c generated by valac 0.10.0, the Vala compiler
 * generated from vbfpackage.vala, do not modify */

/*
 *  vbfpackage.vala - Vala Build Framework library
 *  
 *  Copyright (C) 2008 - Andrea Del Signore <sejerpz@tin.it>
 *  
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <vala.h>
#include <valagee.h>


#define VBF_TYPE_PACKAGE (vbf_package_get_type ())
#define VBF_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_PACKAGE, VbfPackage))
#define VBF_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_PACKAGE, VbfPackageClass))
#define VBF_IS_PACKAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_PACKAGE))
#define VBF_IS_PACKAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_PACKAGE))
#define VBF_PACKAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_PACKAGE, VbfPackageClass))

typedef struct _VbfPackage VbfPackage;
typedef struct _VbfPackageClass VbfPackageClass;
typedef struct _VbfPackagePrivate VbfPackagePrivate;

#define VBF_TYPE_CONFIG_NODE (vbf_config_node_get_type ())
#define VBF_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNode))
#define VBF_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))
#define VBF_IS_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_CONFIG_NODE))
#define VBF_IS_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_CONFIG_NODE))
#define VBF_CONFIG_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))

typedef struct _VbfConfigNode VbfConfigNode;
typedef struct _VbfConfigNodeClass VbfConfigNodeClass;

#define VBF_TYPE_TARGET (vbf_target_get_type ())
#define VBF_TARGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_TARGET, VbfTarget))
#define VBF_TARGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_TARGET, VbfTargetClass))
#define VBF_IS_TARGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_TARGET))
#define VBF_IS_TARGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_TARGET))
#define VBF_TARGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_TARGET, VbfTargetClass))

typedef struct _VbfTarget VbfTarget;
typedef struct _VbfTargetClass VbfTargetClass;

#define VBF_TYPE_GROUP (vbf_group_get_type ())
#define VBF_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_GROUP, VbfGroup))
#define VBF_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_GROUP, VbfGroupClass))
#define VBF_IS_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_GROUP))
#define VBF_IS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_GROUP))
#define VBF_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_GROUP, VbfGroupClass))

typedef struct _VbfGroup VbfGroup;
typedef struct _VbfGroupClass VbfGroupClass;

#define VBF_TYPE_MODULE (vbf_module_get_type ())
#define VBF_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_MODULE, VbfModule))
#define VBF_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_MODULE, VbfModuleClass))
#define VBF_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_MODULE))
#define VBF_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_MODULE))
#define VBF_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_MODULE, VbfModuleClass))

typedef struct _VbfModule VbfModule;
typedef struct _VbfModuleClass VbfModuleClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_collection_object_unref0(var) ((var == NULL) ? NULL : (var = (vala_collection_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _vala_code_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_context_unref (var), NULL)))

struct _VbfPackage {
      GObject parent_instance;
      VbfPackagePrivate * priv;
      char* id;
      char* name;
      char* constraint;
      VbfConfigNode* version;
      VbfTarget* parent_target;
      VbfGroup* parent_group;
      VbfModule* parent_module;
};

struct _VbfPackageClass {
      GObjectClass parent_class;
};

00104 struct _VbfPackagePrivate {
      char* _uri;
};


static gpointer vbf_package_parent_class = NULL;

GType vbf_package_get_type (void) G_GNUC_CONST;
GType vbf_config_node_get_type (void) G_GNUC_CONST;
GType vbf_target_get_type (void) G_GNUC_CONST;
GType vbf_group_get_type (void) G_GNUC_CONST;
GType vbf_module_get_type (void) G_GNUC_CONST;
#define VBF_PACKAGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VBF_TYPE_PACKAGE, VbfPackagePrivate))
enum  {
      VBF_PACKAGE_DUMMY_PROPERTY,
      VBF_PACKAGE_URI
};
VbfPackage* vbf_package_new (const char* id);
VbfPackage* vbf_package_construct (GType object_type, const char* id);
static void vbf_package_initialize_uri (VbfPackage* self);
ValaList* vbf_target_get_include_dirs (VbfTarget* self);
void vbf_utils_trace (const char* format, ...);
const char* vbf_package_get_uri (VbfPackage* self);
static void vbf_package_finalize (GObject* obj);
static void vbf_package_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
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);



VbfPackage* vbf_package_construct (GType object_type, const char* id) {
      VbfPackage * self;
      char* _tmp0_;
      char* _tmp1_;
      g_return_val_if_fail (id != NULL, NULL);
      self = (VbfPackage*) g_object_new (object_type, NULL);
      self->id = (_tmp0_ = g_strdup (id), _g_free0 (self->id), _tmp0_);
      self->name = (_tmp1_ = g_strdup (id), _g_free0 (self->name), _tmp1_);
      return self;
}


VbfPackage* vbf_package_new (const char* id) {
      return vbf_package_construct (VBF_TYPE_PACKAGE, id);
}


static void vbf_package_initialize_uri (VbfPackage* self) {
      ValaCodeContext* ctx;
      gint vapi_dirs_length1;
      gint _vapi_dirs_size_;
      char** _tmp0_;
      char** vapi_dirs;
      GError * _inner_error_ = NULL;
      g_return_if_fail (self != NULL);
      ctx = vala_code_context_new ();
      vapi_dirs = (_tmp0_ = NULL, vapi_dirs_length1 = 0, _vapi_dirs_size_ = vapi_dirs_length1, _tmp0_);
      if (self->parent_target != NULL) {
            ValaList* _tmp1_;
            gint _tmp2_;
            char** _tmp3_;
            gint i;
            vapi_dirs = (_tmp3_ = g_new0 (char*, (_tmp2_ = vala_collection_get_size ((ValaCollection*) (_tmp1_ = vbf_target_get_include_dirs (self->parent_target)))) + 1), vapi_dirs = (_vala_array_free (vapi_dirs, vapi_dirs_length1, (GDestroyNotify) g_free), NULL), vapi_dirs_length1 = _tmp2_, _vapi_dirs_size_ = vapi_dirs_length1, _tmp3_);
            _vala_collection_object_unref0 (_tmp1_);
            i = 0;
            {
                  ValaList* _tmp4_;
                  ValaIterator* _tmp5_;
                  ValaIterator* _vapi_dir_it;
                  _vapi_dir_it = (_tmp5_ = vala_iterable_iterator ((ValaIterable*) (_tmp4_ = vbf_target_get_include_dirs (self->parent_target))), _vala_collection_object_unref0 (_tmp4_), _tmp5_);
                  while (TRUE) {
                        char* vapi_dir;
                        char* _tmp6_;
                        if (!vala_iterator_next (_vapi_dir_it)) {
                              break;
                        }
                        vapi_dir = (char*) vala_iterator_get (_vapi_dir_it);
                        vapi_dirs[i] = (_tmp6_ = g_strconcat (vapi_dir, "/", NULL), _g_free0 (vapi_dirs[i]), _tmp6_);
                        vbf_utils_trace ("vbfpackage.vala:65: **** adding vapidir: %s", vapi_dir);
                        i++;
                        _g_free0 (vapi_dir);
                  }
                  _vala_collection_object_unref0 (_vapi_dir_it);
            }
      }
      {
            char* package_filename;
            package_filename = vala_code_context_get_package_path (ctx, self->id, vapi_dirs, vapi_dirs_length1);
            if (package_filename == NULL) {
                  g_critical ("vbfpackage.vala:73: no vapi file for package: %s", self->id);
            } else {
                  char* _tmp7_;
                  char* _tmp8_;
                  _tmp7_ = g_filename_to_uri (package_filename, NULL, &_inner_error_);
                  if (_inner_error_ != NULL) {
                        _g_free0 (package_filename);
                        goto __catch2_g_error;
                  }
                  self->priv->_uri = (_tmp8_ = _tmp7_, _g_free0 (self->priv->_uri), _tmp8_);
            }
            _g_free0 (package_filename);
      }
      goto __finally2;
      __catch2_g_error:
      {
            GError * err;
            err = _inner_error_;
            _inner_error_ = NULL;
            {
                  g_critical ("vbfpackage.vala:78: error getting the uri for %s: %s", self->id, err->message);
                  _g_error_free0 (err);
            }
      }
      __finally2:
      if (_inner_error_ != NULL) {
            vapi_dirs = (_vala_array_free (vapi_dirs, vapi_dirs_length1, (GDestroyNotify) g_free), NULL);
            _vala_code_context_unref0 (ctx);
            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;
      }
      vapi_dirs = (_vala_array_free (vapi_dirs, vapi_dirs_length1, (GDestroyNotify) g_free), NULL);
      _vala_code_context_unref0 (ctx);
}


const char* vbf_package_get_uri (VbfPackage* self) {
      const char* result;
      g_return_val_if_fail (self != NULL, NULL);
      if (self->priv->_uri == NULL) {
            vbf_package_initialize_uri (self);
      }
      result = self->priv->_uri;
      return result;
}


static void vbf_package_class_init (VbfPackageClass * klass) {
      vbf_package_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (VbfPackagePrivate));
      G_OBJECT_CLASS (klass)->get_property = vbf_package_get_property;
      G_OBJECT_CLASS (klass)->finalize = vbf_package_finalize;
      g_object_class_install_property (G_OBJECT_CLASS (klass), VBF_PACKAGE_URI, g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void vbf_package_instance_init (VbfPackage * self) {
      self->priv = VBF_PACKAGE_GET_PRIVATE (self);
      self->parent_target = NULL;
      self->parent_group = NULL;
      self->parent_module = NULL;
}


static void vbf_package_finalize (GObject* obj) {
      VbfPackage * self;
      self = VBF_PACKAGE (obj);
      _g_free0 (self->id);
      _g_free0 (self->name);
      _g_free0 (self->constraint);
      _g_object_unref0 (self->version);
      _g_free0 (self->priv->_uri);
      G_OBJECT_CLASS (vbf_package_parent_class)->finalize (obj);
}


GType vbf_package_get_type (void) {
      static volatile gsize vbf_package_type_id__volatile = 0;
      if (g_once_init_enter (&vbf_package_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (VbfPackageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vbf_package_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VbfPackage), 0, (GInstanceInitFunc) vbf_package_instance_init, NULL };
            GType vbf_package_type_id;
            vbf_package_type_id = g_type_register_static (G_TYPE_OBJECT, "VbfPackage", &g_define_type_info, 0);
            g_once_init_leave (&vbf_package_type_id__volatile, vbf_package_type_id);
      }
      return vbf_package_type_id__volatile;
}


static void vbf_package_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
      VbfPackage * self;
      self = VBF_PACKAGE (object);
      switch (property_id) {
            case VBF_PACKAGE_URI:
            g_value_set_string (value, vbf_package_get_uri (self));
            break;
            default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
            break;
      }
}


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);
}





Generated by  Doxygen 1.6.0   Back to index