1/*
2 * Copyright (C) 2006, 2007 Apple Inc.  All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "WebScriptObject.h"
28
29#include "WebKitDLL.h"
30
31#include <wtf/Assertions.h>
32
33// WebScriptObject ------------------------------------------------------------
34
35WebScriptObject::WebScriptObject()
36: m_refCount(0)
37{
38    gClassCount++;
39    gClassNameCount.add("WebScriptObject");
40}
41
42WebScriptObject::~WebScriptObject()
43{
44    gClassCount--;
45    gClassNameCount.remove("WebScriptObject");
46}
47
48// IUnknown -------------------------------------------------------------------
49
50HRESULT STDMETHODCALLTYPE WebScriptObject::QueryInterface(REFIID riid, void** ppvObject)
51{
52    *ppvObject = 0;
53    if (IsEqualGUID(riid, IID_IUnknown))
54        *ppvObject = static_cast<IWebScriptObject*>(this);
55    else if (IsEqualGUID(riid, IID_IWebScriptObject))
56        *ppvObject = static_cast<IWebScriptObject*>(this);
57    else
58        return E_NOINTERFACE;
59
60    AddRef();
61    return S_OK;
62}
63
64ULONG STDMETHODCALLTYPE WebScriptObject::AddRef(void)
65{
66    return ++m_refCount;
67}
68
69ULONG STDMETHODCALLTYPE WebScriptObject::Release(void)
70{
71    ULONG newRef = --m_refCount;
72    if (!newRef)
73        delete(this);
74
75    return newRef;
76}
77
78// WebScriptObject ------------------------------------------------------------
79
80HRESULT STDMETHODCALLTYPE WebScriptObject::throwException(
81    /* [in] */ BSTR /*exceptionMessage*/,
82    /* [retval][out] */ BOOL* /*result*/)
83{
84    ASSERT_NOT_REACHED();
85    return E_NOTIMPL;
86}
87
88HRESULT STDMETHODCALLTYPE WebScriptObject::callWebScriptMethod(
89    /* [in] */ BSTR /*name*/,
90    /* [size_is][in] */ const VARIANT /*args*/[  ],
91    /* [in] */ int /*cArgs*/,
92    /* [retval][out] */ VARIANT* /*result*/)
93{
94    ASSERT_NOT_REACHED();
95    return E_NOTIMPL;
96}
97
98HRESULT STDMETHODCALLTYPE WebScriptObject::evaluateWebScript(
99    /* [in] */ BSTR /*script*/,
100    /* [retval][out] */ VARIANT* /*result*/)
101{
102    ASSERT_NOT_REACHED();
103    return E_NOTIMPL;
104}
105
106HRESULT STDMETHODCALLTYPE WebScriptObject::removeWebScriptKey(
107    /* [in] */ BSTR /*name*/)
108{
109    ASSERT_NOT_REACHED();
110    return E_NOTIMPL;
111}
112
113HRESULT STDMETHODCALLTYPE WebScriptObject::stringRepresentation(
114    /* [retval][out] */ BSTR* /*stringRepresentation*/)
115{
116    ASSERT_NOT_REACHED();
117    return E_NOTIMPL;
118}
119
120HRESULT STDMETHODCALLTYPE WebScriptObject::webScriptValueAtIndex(
121    /* [in] */ unsigned int /*index*/,
122    /* [retval][out] */ VARIANT* /*result*/)
123{
124    ASSERT_NOT_REACHED();
125    return E_NOTIMPL;
126}
127
128HRESULT STDMETHODCALLTYPE WebScriptObject::setWebScriptValueAtIndex(
129    /* [in] */ unsigned int /*index*/,
130    /* [in] */ VARIANT /*val*/)
131{
132    ASSERT_NOT_REACHED();
133    return E_NOTIMPL;
134}
135
136HRESULT STDMETHODCALLTYPE WebScriptObject::setException(
137    /* [in] */ BSTR /*description*/)
138{
139    ASSERT_NOT_REACHED();
140    return E_NOTIMPL;
141}
142