~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/JavaScriptCore/API/APICast.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#ifndef APICast_h
27
27
#define APICast_h
28
28
 
 
29
#include "JSAPIValueWrapper.h"
29
30
#include "JSValue.h"
 
31
#include <wtf/Platform.h>
 
32
#include <wtf/UnusedParam.h>
30
33
 
31
34
namespace JSC {
32
35
    class ExecState;
34
37
    class JSGlobalData;
35
38
    class JSObject;
36
39
    class JSValue;
37
 
    class JSValuePtr;
38
40
}
39
41
 
40
42
typedef const struct OpaqueJSContextGroup* JSContextGroupRef;
56
58
    return reinterpret_cast<JSC::ExecState*>(c);
57
59
}
58
60
 
59
 
inline JSC::JSValuePtr toJS(JSValueRef v)
 
61
inline JSC::JSValue toJS(JSC::ExecState*, JSValueRef v)
60
62
{
61
 
    return JSC::JSValuePtr::decode(reinterpret_cast<JSC::JSValueEncodedAsPointer*>(const_cast<OpaqueJSValue*>(v)));
 
63
#if USE(JSVALUE32_64)
 
64
    JSC::JSCell* jsCell = reinterpret_cast<JSC::JSCell*>(const_cast<OpaqueJSValue*>(v));
 
65
    if (!jsCell)
 
66
        return JSC::JSValue();
 
67
    if (jsCell->isAPIValueWrapper())
 
68
        return static_cast<JSC::JSAPIValueWrapper*>(jsCell)->value();
 
69
    return jsCell;
 
70
#else
 
71
    return JSC::JSValue::decode(reinterpret_cast<JSC::EncodedJSValue>(const_cast<OpaqueJSValue*>(v)));
 
72
#endif
62
73
}
63
74
 
64
75
inline JSC::JSObject* toJS(JSObjectRef o)
76
87
    return reinterpret_cast<JSC::JSGlobalData*>(const_cast<OpaqueJSContextGroup*>(g));
77
88
}
78
89
 
79
 
inline JSValueRef toRef(JSC::JSValuePtr v)
80
 
{
81
 
    return reinterpret_cast<JSValueRef>(JSC::JSValuePtr::encode(v));
82
 
}
83
 
 
84
 
inline JSValueRef* toRef(JSC::JSValuePtr* v)
85
 
{
86
 
    return reinterpret_cast<JSValueRef*>(v);
 
90
inline JSValueRef toRef(JSC::ExecState* exec, JSC::JSValue v)
 
91
{
 
92
#if USE(JSVALUE32_64)
 
93
    if (!v)
 
94
        return 0;
 
95
    if (!v.isCell())
 
96
        return reinterpret_cast<JSValueRef>(asCell(JSC::jsAPIValueWrapper(exec, v)));
 
97
    return reinterpret_cast<JSValueRef>(asCell(v));
 
98
#else
 
99
    UNUSED_PARAM(exec);
 
100
    return reinterpret_cast<JSValueRef>(JSC::JSValue::encode(v));
 
101
#endif
87
102
}
88
103
 
89
104
inline JSObjectRef toRef(JSC::JSObject* o)