Changeset 34921 in webkit for trunk/JavaScriptCore/kjs/JSCell.cpp


Ignore:
Timestamp:
Jul 1, 2008, 10:32:44 AM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-07-01 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Split JSCell and JSNumberCell class declarations out of JSValue.h

  • GNUmakefile.am:
  • JavaScriptCore.pri:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • JavaScriptCoreSources.bkl:
  • VM/JSPropertyNameIterator.h:
  • kjs/AllInOneFile.cpp:
  • kjs/JSCell.cpp: Copied from JavaScriptCore/kjs/JSValue.cpp.
  • kjs/JSCell.h: Copied from JavaScriptCore/kjs/JSValue.h. (KJS::JSValue::getJSNumber):
  • kjs/JSNumberCell.cpp:
  • kjs/JSNumberCell.h: Copied from JavaScriptCore/kjs/JSValue.h.
  • kjs/JSObject.h:
  • kjs/JSString.cpp: (KJS::jsString): (KJS::jsOwnedString):
  • kjs/JSString.h: (KJS::JSValue::toThisJSString):
  • kjs/JSValue.cpp:
  • kjs/JSValue.h:

WebCore:

2008-07-01 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Split JSCell and JSNumberCell class declarations out of JSValue.h

  • ForwardingHeaders/kjs/JSNumberCell.h: Added.
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/c/c_instance.cpp:
File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSCell.cpp

    r34892 r34921  
    2222
    2323#include "config.h"
    24 #include "JSValue.h"
     24#include "JSCell.h"
    2525
    2626#include "JSFunction.h"
    27 #include "nodes.h"
    28 #include <stdio.h>
    29 #include <string.h>
     27#include "JSString.h"
     28#include "JSObject.h"
    3029#include <wtf/MathExtras.h>
    3130
     
    7877#endif // !(defined NAN && defined INFINITY)
    7978
    80 static const double D16 = 65536.0;
    81 static const double D32 = 4294967296.0;
    82 
    8379void* JSCell::operator new(size_t size, ExecState* exec)
    8480{
     
    10399{
    104100    return false;
    105 }
    106 
    107 // ECMA 9.4
    108 double JSValue::toInteger(ExecState* exec) const
    109 {
    110     int32_t i;
    111     if (getTruncatedInt32(i))
    112         return i;
    113     double d = toNumber(exec);
    114     return isnan(d) ? 0.0 : trunc(d);
    115 }
    116 
    117 double JSValue::toIntegerPreserveNaN(ExecState* exec) const
    118 {
    119     int32_t i;
    120     if (getTruncatedInt32(i))
    121         return i;
    122     return trunc(toNumber(exec));
    123 }
    124 
    125 int32_t JSValue::toInt32SlowCase(double d, bool& ok)
    126 {
    127     ok = true;
    128 
    129     if (d >= -D32 / 2 && d < D32 / 2)
    130         return static_cast<int32_t>(d);
    131 
    132     if (isnan(d) || isinf(d)) {
    133         ok = false;
    134         return 0;
    135     }
    136 
    137     double d32 = fmod(trunc(d), D32);
    138     if (d32 >= D32 / 2)
    139         d32 -= D32;
    140     else if (d32 < -D32 / 2)
    141         d32 += D32;
    142     return static_cast<int32_t>(d32);
    143 }
    144 
    145 int32_t JSValue::toInt32SlowCase(ExecState* exec, bool& ok) const
    146 {
    147     return JSValue::toInt32SlowCase(toNumber(exec), ok);
    148 }
    149 
    150 uint32_t JSValue::toUInt32SlowCase(double d, bool& ok)
    151 {
    152     ok = true;
    153 
    154     if (d >= 0.0 && d < D32)
    155         return static_cast<uint32_t>(d);
    156 
    157     if (isnan(d) || isinf(d)) {
    158         ok = false;
    159         return 0;
    160     }
    161 
    162     double d32 = fmod(trunc(d), D32);
    163     if (d32 < 0)
    164         d32 += D32;
    165     return static_cast<uint32_t>(d32);
    166 }
    167 
    168 uint32_t JSValue::toUInt32SlowCase(ExecState* exec, bool& ok) const
    169 {
    170     return JSValue::toUInt32SlowCase(toNumber(exec), ok);
    171 }
    172 
    173 float JSValue::toFloat(ExecState* exec) const
    174 {
    175     return static_cast<float>(toNumber(exec));
    176101}
    177102
     
    291216}
    292217
    293 JSString* jsString(ExecState* exec, const char* s)
    294 {
    295     return new (exec) JSString(s ? s : "");
    296 }
    297 
    298 JSString* jsString(ExecState* exec, const UString& s)
    299 {
    300     return s.isNull() ? new (exec) JSString("") : new (exec) JSString(s);
    301 }
    302 
    303 JSString* jsOwnedString(ExecState* exec, const UString& s)
    304 {
    305     return s.isNull() ? new (exec) JSString("", JSString::HasOtherOwner) : new (exec) JSString(s, JSString::HasOtherOwner);
    306 }
    307 
    308 JSValue* call(ExecState* exec, JSValue* functionObject, CallType callType, const CallData& callData, JSValue* thisValue, const ArgList& args)
    309 {
    310     if (callType == CallTypeNative)
    311         return callData.native.function(exec, static_cast<JSObject*>(functionObject), thisValue, args);
    312     ASSERT(callType == CallTypeJS);
    313     // FIXME: Can this be done more efficiently using the callData?
    314     return static_cast<JSFunction*>(functionObject)->call(exec, thisValue, args);
    315 }
    316 
    317 JSObject* construct(ExecState* exec, JSValue* object, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
    318 {
    319     if (constructType == ConstructTypeNative)
    320         return constructData.native.function(exec, static_cast<JSObject*>(object), args);
    321     ASSERT(constructType == ConstructTypeJS);
    322     // FIXME: Can this be done more efficiently using the constructData?
    323     return static_cast<JSFunction*>(object)->construct(exec, args);
    324 }
    325 
    326218} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.