bump libtool version
[swfdec.git] / libswfdec / swfdec_as_boolean.c
blob4645254186057055d17c8d6b2bd2c57256890fe3
1 /* Swfdec
2 * Copyright (C) 2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include <math.h>
26 #include "swfdec_as_boolean.h"
27 #include "swfdec_as_context.h"
28 #include "swfdec_as_internal.h"
29 #include "swfdec_as_native_function.h"
30 #include "swfdec_as_strings.h"
31 #include "swfdec_debug.h"
33 G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT)
35 static void
36 swfdec_as_boolean_class_init (SwfdecAsBooleanClass *klass)
40 static void
41 swfdec_as_boolean_init (SwfdecAsBoolean *boolean)
45 /*** AS CODE ***/
47 SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct, swfdec_as_boolean_get_type)
48 void
49 swfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object,
50 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
52 gboolean b;
54 if (argc > 0) {
55 b = swfdec_as_value_to_boolean (object->context, &argv[0]);
56 } else {
57 b = FALSE;
60 if (swfdec_as_context_is_constructing (cx)) {
61 SWFDEC_AS_BOOLEAN (object)->boolean = b;
62 SWFDEC_AS_VALUE_SET_OBJECT (ret, object);
63 } else {
64 SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b);
68 SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString)
69 void
70 swfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object,
71 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
73 SwfdecAsBoolean *b;
75 if (!SWFDEC_IS_AS_BOOLEAN (object))
76 return;
77 b = SWFDEC_AS_BOOLEAN (object);
79 SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false);
82 SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf)
83 void
84 swfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object,
85 guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret)
87 SwfdecAsBoolean *b;
89 if (!SWFDEC_IS_AS_BOOLEAN (object))
90 return;
91 b = SWFDEC_AS_BOOLEAN (object);
93 SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean);