KJS

number_object.h
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (C) 1999-2000 Harri Porten ([email protected])
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 
21 #ifndef NUMBER_OBJECT_H_
22 #define NUMBER_OBJECT_H_
23 
24 #include "function_object.h"
25 #include "JSWrapperObject.h"
26 
27 namespace KJS
28 {
29 
30 class NumberInstance : public JSWrapperObject
31 {
32 public:
33  NumberInstance(JSObject *proto);
34 
35  virtual const ClassInfo *classInfo() const
36  {
37  return &info;
38  }
39  static const ClassInfo info;
40 
41  virtual JSObject *valueClone(Interpreter *targetCtx) const;
42 };
43 
50 class NumberPrototype : public NumberInstance
51 {
52 public:
54  ObjectPrototype *objProto,
55  FunctionPrototype *funcProto);
56 };
57 
64 class NumberProtoFunc : public InternalFunctionImp
65 {
66 public:
67  NumberProtoFunc(ExecState *, FunctionPrototype *, int i, int len, const Identifier &);
68 
69  virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
70 
71  enum { ToString, ToLocaleString, ValueOf, ToFixed, ToExponential, ToPrecision };
72 private:
73  int id;
74 };
75 
81 class NumberObjectImp : public InternalFunctionImp
82 {
83  using InternalFunctionImp::construct;
84 public:
86  FunctionPrototype *funcProto,
87  NumberPrototype *numberProto);
88 
89  virtual bool implementsConstruct() const;
90  virtual JSObject *construct(ExecState *exec, const List &args);
91 
92  virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
93 
94  using KJS::JSObject::getOwnPropertySlot;
95  bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot &);
96  JSValue *getValueProperty(ExecState *exec, int token) const;
97 
98  virtual const ClassInfo *classInfo() const
99  {
100  return &info;
101  }
102  static const ClassInfo info;
103  enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue,
104  //ES6 (Draft 08.11.2013)
105  MaxSafeInteger, MinSafeInteger,
106  IsFinite, IsInteger, IsNaN, IsSafeInteger, ParseInt, ParseFloat
107  };
108 
109  Completion execute(const List &);
110  JSObject *construct(const List &);
111 };
112 
113 class NumberFuncImp : public InternalFunctionImp {
114 public:
115  NumberFuncImp(ExecState *exec, int i, int l, const Identifier&);
116  virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
117 private:
118  int id;
119 };
120 
121 } // namespace
122 
123 #endif
JSValue is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects in...
Definition: value.h:58
Completion objects are used to convey the return status and value from functions. ...
Definition: completion.h:52
Native list type.
Definition: list.h:52
Class Information.
Definition: object.h:48
Represents the current state of script execution.
Definition: ExecState.h:53
Represents an Identifier for a Javascript object.
Definition: identifier.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jan 14 2021 23:02:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.