📄 swfdec_as_boolean.c
字号:
/* Swfdec * Copyright (C) 2007 Benjamin Otte <otte@gnome.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */#ifdef HAVE_CONFIG_H#include "config.h"#endif#include <math.h>#include "swfdec_as_boolean.h"#include "swfdec_as_context.h"#include "swfdec_as_native_function.h"#include "swfdec_as_strings.h"#include "swfdec_debug.h"G_DEFINE_TYPE (SwfdecAsBoolean, swfdec_as_boolean, SWFDEC_TYPE_AS_OBJECT)static voidswfdec_as_boolean_class_init (SwfdecAsBooleanClass *klass){}static voidswfdec_as_boolean_init (SwfdecAsBoolean *boolean){}/*** AS CODE ***/static voidswfdec_as_boolean_construct (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret){ gboolean b; if (argc > 0) { b = swfdec_as_value_to_boolean (object->context, &argv[0]); } else { b = FALSE; } if (swfdec_as_context_is_constructing (cx)) { SWFDEC_AS_BOOLEAN (object)->boolean = b; SWFDEC_AS_VALUE_SET_OBJECT (ret, object); } else { SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b); }}static voidswfdec_as_boolean_toString (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret){ SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); SWFDEC_AS_VALUE_SET_STRING (ret, b->boolean ? SWFDEC_AS_STR_true : SWFDEC_AS_STR_false);}static voidswfdec_as_boolean_valueOf (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *ret){ SwfdecAsBoolean *b = SWFDEC_AS_BOOLEAN (object); SWFDEC_AS_VALUE_SET_BOOLEAN (ret, b->boolean);}voidswfdec_as_boolean_init_context (SwfdecAsContext *context, guint version){ SwfdecAsObject *boolean, *proto; SwfdecAsValue val; g_return_if_fail (SWFDEC_IS_AS_CONTEXT (context)); proto = swfdec_as_object_new_empty (context); if (proto == NULL) return; boolean = SWFDEC_AS_OBJECT (swfdec_as_object_add_constructor (context->global, SWFDEC_AS_STR_Boolean, SWFDEC_TYPE_AS_BOOLEAN, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_construct, 0, proto)); if (!boolean) return; /* set the right properties on the Boolean.prototype object */ SWFDEC_AS_VALUE_SET_OBJECT (&val, boolean); swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR_constructor, &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT); swfdec_as_object_add_function (proto, SWFDEC_AS_STR_toString, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_toString, 0); swfdec_as_object_add_function (proto, SWFDEC_AS_STR_valueOf, SWFDEC_TYPE_AS_BOOLEAN, swfdec_as_boolean_valueOf, 0); SWFDEC_AS_VALUE_SET_OBJECT (&val, context->Object_prototype); swfdec_as_object_set_variable_and_flags (proto, SWFDEC_AS_STR___proto__, &val, SWFDEC_AS_VARIABLE_HIDDEN | SWFDEC_AS_VARIABLE_PERMANENT);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -