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 (object
->context
, &argv
[0]);
60 if (swfdec_as_context_is_constructing (cx
)) {
61 SWFDEC_AS_BOOLEAN (object
)->boolean
= b
;
62 SWFDEC_AS_VALUE_SET_OBJECT (ret
, object
);
64 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
);
68 SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString
)
70 swfdec_as_boolean_toString (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
71 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
75 if (!SWFDEC_IS_AS_BOOLEAN (object
))
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
)
84 swfdec_as_boolean_valueOf (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
85 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
89 if (!SWFDEC_IS_AS_BOOLEAN (object
))
91 b
= SWFDEC_AS_BOOLEAN (object
);
93 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
->boolean
);