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.
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
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
)
36 swfdec_as_boolean_class_init (SwfdecAsBooleanClass
*klass
)
41 swfdec_as_boolean_init (SwfdecAsBoolean
*boolean
)
47 SWFDEC_AS_CONSTRUCTOR (107, 2, swfdec_as_boolean_construct
, swfdec_as_boolean_get_type
)
49 swfdec_as_boolean_construct (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
50 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
55 b
= swfdec_as_value_to_boolean (swfdec_gc_object_get_context (object
), &argv
[0]);
57 if (!swfdec_as_context_is_constructing (cx
))
62 if (swfdec_as_context_is_constructing (cx
)) {
63 SWFDEC_AS_BOOLEAN (object
)->boolean
= b
;
64 SWFDEC_AS_VALUE_SET_OBJECT (ret
, object
);
66 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
);
70 SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString
)
72 swfdec_as_boolean_toString (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
73 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
77 if (!SWFDEC_IS_AS_BOOLEAN (object
))
79 b
= SWFDEC_AS_BOOLEAN (object
);
81 SWFDEC_AS_VALUE_SET_STRING (ret
, b
->boolean
? SWFDEC_AS_STR_true
: SWFDEC_AS_STR_false
);
84 SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf
)
86 swfdec_as_boolean_valueOf (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
87 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
91 if (!SWFDEC_IS_AS_BOOLEAN (object
))
93 b
= SWFDEC_AS_BOOLEAN (object
);
95 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
->boolean
);
98 // only available as ASnative
99 SWFDEC_AS_NATIVE (3, 2, swfdec_as_boolean_old_constructor
)
101 swfdec_as_boolean_old_constructor (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
102 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
104 SWFDEC_STUB ("old 'Boolean' function (only available as ASnative)");