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_as_types.h"
32 #include "swfdec_debug.h"
34 G_DEFINE_TYPE (SwfdecAsBoolean
, swfdec_as_boolean
, SWFDEC_TYPE_AS_RELAY
)
37 swfdec_as_boolean_class_init (SwfdecAsBooleanClass
*klass
)
42 swfdec_as_boolean_init (SwfdecAsBoolean
*boolean
)
48 SWFDEC_AS_NATIVE (107, 2, swfdec_as_boolean_construct
)
50 swfdec_as_boolean_construct (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
51 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
53 if (swfdec_as_context_is_constructing (cx
)) {
54 SwfdecAsBoolean
*b
= g_object_new (SWFDEC_TYPE_AS_BOOLEAN
, "context", cx
, NULL
);
55 b
->boolean
= argc
> 0 ? swfdec_as_value_to_boolean (cx
, argv
[0]) : FALSE
;
56 swfdec_as_object_set_relay (object
, SWFDEC_AS_RELAY (b
));
57 SWFDEC_AS_VALUE_SET_OBJECT (ret
, object
);
60 SWFDEC_AS_CHECK (0, NULL
, "b", &b
);
61 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
);
65 SWFDEC_AS_NATIVE (107, 1, swfdec_as_boolean_toString
)
67 swfdec_as_boolean_toString (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
68 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
72 SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_BOOLEAN
, &b
, "");
74 SWFDEC_AS_VALUE_SET_STRING (ret
, b
->boolean
? SWFDEC_AS_STR_true
: SWFDEC_AS_STR_false
);
77 SWFDEC_AS_NATIVE (107, 0, swfdec_as_boolean_valueOf
)
79 swfdec_as_boolean_valueOf (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
80 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
84 SWFDEC_AS_CHECK (SWFDEC_TYPE_AS_BOOLEAN
, &b
, "");
86 SWFDEC_AS_VALUE_SET_BOOLEAN (ret
, b
->boolean
);
89 // only available as ASnative
90 SWFDEC_AS_NATIVE (3, 2, swfdec_as_boolean_old_constructor
)
92 swfdec_as_boolean_old_constructor (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
93 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*ret
)
95 SWFDEC_STUB ("old 'Boolean' function (only available as ASnative)");