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

parser.c

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

/* parser.vala
 *
 * Copyright (C) 2009  Andrea Del Signore
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 *    Andrea Del Signore <sejerpz@tin.it>
 */

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


#define AFRODITE_TYPE_PARSER (afrodite_parser_get_type ())
#define AFRODITE_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_PARSER, AfroditeParser))
#define AFRODITE_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_PARSER, AfroditeParserClass))
#define AFRODITE_IS_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_PARSER))
#define AFRODITE_IS_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_PARSER))
#define AFRODITE_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_PARSER, AfroditeParserClass))

typedef struct _AfroditeParser AfroditeParser;
typedef struct _AfroditeParserClass AfroditeParserClass;
typedef struct _AfroditeParserPrivate AfroditeParserPrivate;

#define AFRODITE_TYPE_SOURCE_ITEM (afrodite_source_item_get_type ())
#define AFRODITE_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SOURCE_ITEM, AfroditeSourceItem))
#define AFRODITE_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SOURCE_ITEM, AfroditeSourceItemClass))
#define AFRODITE_IS_SOURCE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SOURCE_ITEM))
#define AFRODITE_IS_SOURCE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SOURCE_ITEM))
#define AFRODITE_SOURCE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SOURCE_ITEM, AfroditeSourceItemClass))

typedef struct _AfroditeSourceItem AfroditeSourceItem;
typedef struct _AfroditeSourceItemClass AfroditeSourceItemClass;
#define _vala_collection_object_unref0(var) ((var == NULL) ? NULL : (var = (vala_collection_object_unref (var), NULL)))
#define _vala_code_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_context_unref (var), NULL)))
typedef struct _AfroditeSourceItemPrivate AfroditeSourceItemPrivate;
#define _afrodite_source_item_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_item_unref (var), NULL)))
#define _vala_source_file_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_file_unref (var), NULL)))
#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_code_visitor_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_visitor_unref (var), NULL)))

struct _AfroditeParser {
      GObject parent_instance;
      AfroditeParserPrivate * priv;
      ValaCodeContext* context;
};

struct _AfroditeParserClass {
      GObjectClass parent_class;
};

00073 struct _AfroditeParserPrivate {
      ValaList* _sources;
};

struct _AfroditeSourceItem {
      GTypeInstance parent_instance;
      volatile int ref_count;
      AfroditeSourceItemPrivate * priv;
      char* path;
      char* content;
      gboolean is_glib;
      ValaCodeContext* context;
};

struct _AfroditeSourceItemClass {
      GTypeClass parent_class;
      void (*finalize) (AfroditeSourceItem *self);
};


static gpointer afrodite_parser_parent_class = NULL;

GType afrodite_parser_get_type (void) G_GNUC_CONST;
gpointer afrodite_source_item_ref (gpointer instance);
void afrodite_source_item_unref (gpointer instance);
GParamSpec* afrodite_param_spec_source_item (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_source_item (GValue* value, gpointer v_object);
void afrodite_value_take_source_item (GValue* value, gpointer v_object);
gpointer afrodite_value_get_source_item (const GValue* value);
GType afrodite_source_item_get_type (void) G_GNUC_CONST;
#define AFRODITE_PARSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AFRODITE_TYPE_PARSER, AfroditeParserPrivate))
enum  {
      AFRODITE_PARSER_DUMMY_PROPERTY
};
AfroditeParser* afrodite_parser_new (ValaList* sources);
AfroditeParser* afrodite_parser_construct (GType object_type, ValaList* sources);
void afrodite_parser_parse (AfroditeParser* self);
gboolean afrodite_utils_add_package (const char* pkg, ValaCodeContext* context);
gboolean afrodite_source_item_get_is_vapi (AfroditeSourceItem* self);
static void afrodite_parser_finalize (GObject* obj);
static int _vala_strcmp0 (const char * str1, const char * str2);



static gpointer _vala_collection_object_ref0 (gpointer self) {
      return self ? vala_collection_object_ref (self) : NULL;
}


AfroditeParser* afrodite_parser_construct (GType object_type, ValaList* sources) {
      AfroditeParser * self;
      ValaList* _tmp0_;
      g_return_val_if_fail (sources != NULL, NULL);
      self = (AfroditeParser*) g_object_new (object_type, NULL);
      self->priv->_sources = (_tmp0_ = _vala_collection_object_ref0 (sources), _vala_collection_object_unref0 (self->priv->_sources), _tmp0_);
      return self;
}


AfroditeParser* afrodite_parser_new (ValaList* sources) {
      return afrodite_parser_construct (AFRODITE_TYPE_PARSER, sources);
}


void afrodite_parser_parse (AfroditeParser* self) {
      ValaCodeContext* _tmp0_;
      gboolean has_glib;
      gint glib_major;
      gint glib_minor;
      ValaParser* parser;
      g_return_if_fail (self != NULL);
      self->context = (_tmp0_ = vala_code_context_new (), _vala_code_context_unref0 (self->context), _tmp0_);
      vala_code_context_push (self->context);
      has_glib = FALSE;
      {
            ValaIterator* _source_it;
            _source_it = vala_iterable_iterator ((ValaIterable*) self->priv->_sources);
            while (TRUE) {
                  AfroditeSourceItem* source;
                  if (!vala_iterator_next (_source_it)) {
                        break;
                  }
                  source = (AfroditeSourceItem*) vala_iterator_get (_source_it);
                  if (source->is_glib) {
                        has_glib = TRUE;
                        _afrodite_source_item_unref0 (source);
                        break;
                  }
                  _afrodite_source_item_unref0 (source);
            }
            _vala_collection_object_unref0 (_source_it);
      }
      if (!has_glib) {
            if (!afrodite_utils_add_package ("glib-2.0", self->context)) {
                  g_error ("parser.vala:56: failed to add GLib 2.0");
            }
            if (!afrodite_utils_add_package ("gobject-2.0", self->context)) {
                  g_error ("parser.vala:59: failed to add GObject 2.0");
            }
      }
      {
            ValaIterator* _source_it;
            _source_it = vala_iterable_iterator ((ValaIterable*) self->priv->_sources);
            while (TRUE) {
                  AfroditeSourceItem* source;
                  ValaSourceFile* source_file;
                  gboolean _tmp1_ = FALSE;
                  if (!vala_iterator_next (_source_it)) {
                        break;
                  }
                  source = (AfroditeSourceItem*) vala_iterator_get (_source_it);
                  source_file = NULL;
                  if (source->content == NULL) {
                        _tmp1_ = !g_file_test (source->path, G_FILE_TEST_EXISTS);
                  } else {
                        _tmp1_ = FALSE;
                  }
                  if (_tmp1_) {
                        g_warning ("parser.vala:65: file %s not exists", source->path);
                        _vala_source_file_unref0 (source_file);
                        _afrodite_source_item_unref0 (source);
                        continue;
                  }
                  if (source->content == NULL) {
                        ValaSourceFile* _tmp2_;
                        source_file = (_tmp2_ = vala_source_file_new (self->context, source->path, afrodite_source_item_get_is_vapi (source), NULL), _vala_source_file_unref0 (source_file), _tmp2_);
                  } else {
                        if (_vala_strcmp0 (source->content, "") != 0) {
                              ValaSourceFile* _tmp3_;
                              source_file = (_tmp3_ = vala_source_file_new (self->context, source->path, afrodite_source_item_get_is_vapi (source), source->content), _vala_source_file_unref0 (source_file), _tmp3_);
                        } else {
                              g_warning ("parser.vala:74: sourcefile %s with empty content not queued", source->path);
                        }
                  }
                  if (source_file != NULL) {
                        ValaUnresolvedSymbol* _tmp4_;
                        ValaUsingDirective* _tmp5_;
                        ValaUsingDirective* ns_ref;
                        ns_ref = (_tmp5_ = vala_using_directive_new ((ValaSymbol*) (_tmp4_ = vala_unresolved_symbol_new (NULL, "GLib", NULL)), NULL), _vala_code_node_unref0 (_tmp4_), _tmp5_);
                        if (!source->is_glib) {
                              vala_namespace_add_using_directive (vala_code_context_get_root (self->context), ns_ref);
                        }
                        vala_code_context_add_source_file (self->context, source_file);
                        if (!source->is_glib) {
                              vala_source_file_add_using_directive (source_file, ns_ref);
                        }
                        _vala_code_node_unref0 (ns_ref);
                  }
                  _vala_source_file_unref0 (source_file);
                  _afrodite_source_item_unref0 (source);
            }
            _vala_collection_object_unref0 (_source_it);
      }
      vala_code_context_set_assert (self->context, FALSE);
      vala_code_context_set_checking (self->context, FALSE);
      vala_code_context_set_experimental (self->context, FALSE);
      vala_code_context_set_experimental_non_null (self->context, FALSE);
      vala_code_context_set_compile_only (self->context, TRUE);
      vala_code_context_set_profile (self->context, VALA_PROFILE_GOBJECT);
      vala_code_context_add_define (self->context, "GOBJECT");
      glib_major = 2;
      glib_minor = 14;
      vala_code_context_set_target_glib_major (self->context, glib_major);
      vala_code_context_set_target_glib_minor (self->context, glib_minor);
      {
            gint i;
            i = 2;
            {
                  gboolean _tmp6_;
                  _tmp6_ = TRUE;
                  while (TRUE) {
                        char* _tmp7_;
                        if (!_tmp6_) {
                              i = i + 2;
                        }
                        _tmp6_ = FALSE;
                        if (!(i <= 10)) {
                              break;
                        }
                        vala_code_context_add_define (self->context, _tmp7_ = g_strdup_printf ("VALA_0_%d", i));
                        _g_free0 (_tmp7_);
                  }
            }
      }
      {
            gint i;
            i = 16;
            {
                  gboolean _tmp8_;
                  _tmp8_ = TRUE;
                  while (TRUE) {
                        char* _tmp9_;
                        if (!_tmp8_) {
                              i = i + 2;
                        }
                        _tmp8_ = FALSE;
                        if (!(i <= glib_minor)) {
                              break;
                        }
                        vala_code_context_add_define (self->context, _tmp9_ = g_strdup_printf ("GLIB_2_%d", i));
                        _g_free0 (_tmp9_);
                  }
            }
      }
      parser = vala_parser_new ();
      vala_parser_parse (parser, self->context);
      vala_code_context_pop ();
      _vala_code_visitor_unref0 (parser);
}


static void afrodite_parser_class_init (AfroditeParserClass * klass) {
      afrodite_parser_parent_class = g_type_class_peek_parent (klass);
      g_type_class_add_private (klass, sizeof (AfroditeParserPrivate));
      G_OBJECT_CLASS (klass)->finalize = afrodite_parser_finalize;
}


static void afrodite_parser_instance_init (AfroditeParser * self) {
      self->priv = AFRODITE_PARSER_GET_PRIVATE (self);
      self->context = NULL;
}


static void afrodite_parser_finalize (GObject* obj) {
      AfroditeParser * self;
      self = AFRODITE_PARSER (obj);
      {
            ValaList* _tmp0_;
            vala_collection_clear ((ValaCollection*) self->priv->_sources);
            self->priv->_sources = (_tmp0_ = NULL, _vala_collection_object_unref0 (self->priv->_sources), _tmp0_);
      }
      _vala_collection_object_unref0 (self->priv->_sources);
      _vala_code_context_unref0 (self->context);
      G_OBJECT_CLASS (afrodite_parser_parent_class)->finalize (obj);
}


GType afrodite_parser_get_type (void) {
      static volatile gsize afrodite_parser_type_id__volatile = 0;
      if (g_once_init_enter (&afrodite_parser_type_id__volatile)) {
            static const GTypeInfo g_define_type_info = { sizeof (AfroditeParserClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afrodite_parser_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AfroditeParser), 0, (GInstanceInitFunc) afrodite_parser_instance_init, NULL };
            GType afrodite_parser_type_id;
            afrodite_parser_type_id = g_type_register_static (G_TYPE_OBJECT, "AfroditeParser", &g_define_type_info, 0);
            g_once_init_leave (&afrodite_parser_type_id__volatile, afrodite_parser_type_id);
      }
      return afrodite_parser_type_id__volatile;
}


static int _vala_strcmp0 (const char * str1, const char * str2) {
      if (str1 == NULL) {
            return -(str1 != str2);
      }
      if (str2 == NULL) {
            return str1 != str2;
      }
      return strcmp (str1, str2);
}





Generated by  Doxygen 1.6.0   Back to index