5
5
* This library is free software; you can redistribute it and/or
6
6
* modify it under the terms of the GNU Lesser General Public
7
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
8
* version 2.1 of the License, or (at your option) any later version.
10
10
* This library is distributed in the hope that it will be useful,
11
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
20
* Jürg Billeter <j@bitron.ch>
23
#include "valabooleanliteral.h"
23
#include <vala/valabooleanliteral.h>
24
24
#include <vala/valasourcereference.h>
25
#include <vala/valabooleanliteral.h>
26
25
#include <vala/valacodevisitor.h>
28
27
struct _ValaBooleanLiteralPrivate {
46
45
* @param source reference to source code
47
46
* @return newly created boolean literal
49
ValaBooleanLiteral* vala_boolean_literal_new (gboolean b, ValaSourceReference* source)
48
ValaBooleanLiteral* vala_boolean_literal_new (gboolean b, ValaSourceReference* source) {
51
49
ValaBooleanLiteral * self;
52
50
g_return_val_if_fail (source == NULL || VALA_IS_SOURCE_REFERENCE (source), NULL);
53
51
self = g_object_newv (VALA_TYPE_BOOLEAN_LITERAL, 0, NULL);
60
static void vala_boolean_literal_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor)
58
static void vala_boolean_literal_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor) {
62
59
ValaBooleanLiteral * self;
63
self = ((ValaBooleanLiteral*) base);
60
self = VALA_BOOLEAN_LITERAL (base);
64
61
g_return_if_fail (VALA_IS_CODE_VISITOR (visitor));
65
62
vala_code_visitor_visit_boolean_literal (visitor, self);
69
static char* vala_boolean_literal_real_to_string (ValaCodeNode* base)
66
static char* vala_boolean_literal_real_to_string (ValaCodeNode* base) {
71
67
ValaBooleanLiteral * self;
72
self = ((ValaBooleanLiteral*) base);
68
self = VALA_BOOLEAN_LITERAL (base);
73
69
if (vala_boolean_literal_get_value (self)) {
74
70
return g_strdup ("true");
81
gboolean vala_boolean_literal_get_value (ValaBooleanLiteral* self)
77
gboolean vala_boolean_literal_get_value (ValaBooleanLiteral* self) {
83
78
g_return_val_if_fail (VALA_IS_BOOLEAN_LITERAL (self), FALSE);
84
79
return self->priv->_value;
88
void vala_boolean_literal_set_value (ValaBooleanLiteral* self, gboolean value)
83
void vala_boolean_literal_set_value (ValaBooleanLiteral* self, gboolean value) {
90
84
g_return_if_fail (VALA_IS_BOOLEAN_LITERAL (self));
91
85
self->priv->_value = value;
95
static void vala_boolean_literal_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec)
89
static void vala_boolean_literal_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
97
90
ValaBooleanLiteral * self;
98
91
self = VALA_BOOLEAN_LITERAL (object);
99
92
switch (property_id) {
100
93
case VALA_BOOLEAN_LITERAL_VALUE:
101
94
g_value_set_boolean (value, vala_boolean_literal_get_value (self));
97
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
107
static void vala_boolean_literal_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec)
103
static void vala_boolean_literal_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
109
104
ValaBooleanLiteral * self;
110
105
self = VALA_BOOLEAN_LITERAL (object);
111
106
switch (property_id) {
112
107
case VALA_BOOLEAN_LITERAL_VALUE:
113
108
vala_boolean_literal_set_value (self, g_value_get_boolean (value));
111
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
119
static void vala_boolean_literal_class_init (ValaBooleanLiteralClass * klass)
117
static void vala_boolean_literal_class_init (ValaBooleanLiteralClass * klass) {
121
118
vala_boolean_literal_parent_class = g_type_class_peek_parent (klass);
122
119
g_type_class_add_private (klass, sizeof (ValaBooleanLiteralPrivate));
123
120
G_OBJECT_CLASS (klass)->get_property = vala_boolean_literal_get_property;
125
122
G_OBJECT_CLASS (klass)->dispose = vala_boolean_literal_dispose;
126
123
VALA_CODE_NODE_CLASS (klass)->accept = vala_boolean_literal_real_accept;
127
124
VALA_CODE_NODE_CLASS (klass)->to_string = vala_boolean_literal_real_to_string;
128
g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_BOOLEAN_LITERAL_VALUE, g_param_spec_boolean ("value", "foo", "bar", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
125
g_object_class_install_property (G_OBJECT_CLASS (klass), VALA_BOOLEAN_LITERAL_VALUE, g_param_spec_boolean ("value", "value", "value", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
132
static void vala_boolean_literal_init (ValaBooleanLiteral * self)
129
static void vala_boolean_literal_init (ValaBooleanLiteral * self) {
134
130
self->priv = VALA_BOOLEAN_LITERAL_GET_PRIVATE (self);
138
static void vala_boolean_literal_dispose (GObject * obj)
134
static void vala_boolean_literal_dispose (GObject * obj) {
140
135
ValaBooleanLiteral * self;
141
ValaBooleanLiteralClass * klass;
142
GObjectClass * parent_class;
143
136
self = VALA_BOOLEAN_LITERAL (obj);
144
klass = VALA_BOOLEAN_LITERAL_CLASS (g_type_class_peek (VALA_TYPE_BOOLEAN_LITERAL));
145
parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
146
parent_class->dispose (obj);
137
G_OBJECT_CLASS (vala_boolean_literal_parent_class)->dispose (obj);
150
GType vala_boolean_literal_get_type (void)
141
GType vala_boolean_literal_get_type (void) {
152
142
static GType vala_boolean_literal_type_id = 0;
153
143
if (G_UNLIKELY (vala_boolean_literal_type_id == 0)) {
154
144
static const GTypeInfo g_define_type_info = { sizeof (ValaBooleanLiteralClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_boolean_literal_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaBooleanLiteral), 0, (GInstanceInitFunc) vala_boolean_literal_init };