1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
/* valaccodeidentifier.vala
*
* Copyright (C) 2006 Jürg Billeter
*
* 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
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
#include <ccode/valaccodeidentifier.h>
struct _ValaCCodeIdentifierPrivate {
char* _name;
};
#define VALA_CCODE_IDENTIFIER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_CCODE_IDENTIFIER, ValaCCodeIdentifierPrivate))
enum {
VALA_CCODE_IDENTIFIER_DUMMY_PROPERTY,
VALA_CCODE_IDENTIFIER_NAME
};
static void vala_ccode_identifier_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer);
static gpointer vala_ccode_identifier_parent_class = NULL;
static void vala_ccode_identifier_dispose (GObject * obj);
ValaCCodeIdentifier* vala_ccode_identifier_new (const char* _name) {
GParameter * __params;
GParameter * __params_it;
ValaCCodeIdentifier * self;
g_return_val_if_fail (_name != NULL, NULL);
__params = g_new0 (GParameter, 1);
__params_it = __params;
__params_it->name = "name";
g_value_init (&__params_it->value, G_TYPE_STRING);
g_value_set_string (&__params_it->value, _name);
__params_it++;
self = g_object_newv (VALA_TYPE_CCODE_IDENTIFIER, __params_it - __params, __params);
while (__params_it > __params) {
--__params_it;
g_value_unset (&__params_it->value);
}
g_free (__params);
return self;
}
static void vala_ccode_identifier_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer) {
ValaCCodeIdentifier * self;
self = VALA_CCODE_IDENTIFIER (base);
g_return_if_fail (VALA_IS_CCODE_WRITER (writer));
vala_ccode_writer_write_string (writer, self->priv->_name);
}
const char* vala_ccode_identifier_get_name (ValaCCodeIdentifier* self) {
g_return_val_if_fail (VALA_IS_CCODE_IDENTIFIER (self), NULL);
return self->priv->_name;
}
void vala_ccode_identifier_set_name (ValaCCodeIdentifier* self, const char* value) {
char* _tmp2;
const char* _tmp1;
g_return_if_fail (VALA_IS_CCODE_IDENTIFIER (self));
_tmp2 = NULL;
_tmp1 = NULL;
self->priv->_name = (_tmp2 = (_tmp1 = value, (_tmp1 == NULL ? NULL : g_strdup (_tmp1))), (self->priv->_name = (g_free (self->priv->_name), NULL)), _tmp2);
}
static void vala_ccode_identifier_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
ValaCCodeIdentifier * self;
self = VALA_CCODE_IDENTIFIER (object);
switch (property_id) {
case VALA_CCODE_IDENTIFIER_NAME:
g_value_set_string (value, vala_ccode_identifier_get_name (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void vala_ccode_identifier_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
ValaCCodeIdentifier * self;
self = VALA_CCODE_IDENTIFIER (object);
switch (property_id) {
case VALA_CCODE_IDENTIFIER_NAME:
vala_ccode_identifier_set_name (self, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void vala_ccode_identifier_class_init (ValaCCodeIdentifierClass * klass) {
vala_ccode_identifier_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (klass, sizeof (ValaCCodeIdentifierPrivate));
G_OBJECT_CLASS (klass)->get_property = vala_ccode_identifier_get_property;
G_OBJECT_CLASS (klass)->set_property = vala_ccode_identifier_set_property;
G_OBJECT_CLASS (klass)->dispose = vala_ccode_identifier_dispose;
VALA_CCODE_NODE_CLASS (klass)->write = vala_ccode_identifier_real_write;
g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_CCODE_IDENTIFIER_NAME, g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}
static void vala_ccode_identifier_instance_init (ValaCCodeIdentifier * self) {
self->priv = VALA_CCODE_IDENTIFIER_GET_PRIVATE (self);
}
static void vala_ccode_identifier_dispose (GObject * obj) {
ValaCCodeIdentifier * self;
self = VALA_CCODE_IDENTIFIER (obj);
self->priv->_name = (g_free (self->priv->_name), NULL);
G_OBJECT_CLASS (vala_ccode_identifier_parent_class)->dispose (obj);
}
GType vala_ccode_identifier_get_type (void) {
static GType vala_ccode_identifier_type_id = 0;
if (G_UNLIKELY (vala_ccode_identifier_type_id == 0)) {
static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeIdentifierClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_identifier_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeIdentifier), 0, (GInstanceInitFunc) vala_ccode_identifier_instance_init };
vala_ccode_identifier_type_id = g_type_register_static (VALA_TYPE_CCODE_EXPRESSION, "ValaCCodeIdentifier", &g_define_type_info, 0);
}
return vala_ccode_identifier_type_id;
}
|