summaryrefslogtreecommitdiffstats
path: root/WebCore/bridge/c
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /WebCore/bridge/c
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'WebCore/bridge/c')
-rw-r--r--WebCore/bridge/c/CRuntimeObject.cpp56
-rw-r--r--WebCore/bridge/c/CRuntimeObject.h55
-rw-r--r--WebCore/bridge/c/c_class.cpp120
-rw-r--r--WebCore/bridge/c/c_class.h60
-rw-r--r--WebCore/bridge/c/c_instance.cpp318
-rw-r--r--WebCore/bridge/c/c_instance.h93
-rw-r--r--WebCore/bridge/c/c_runtime.cpp83
-rw-r--r--WebCore/bridge/c/c_runtime.h68
-rw-r--r--WebCore/bridge/c/c_utility.cpp158
-rw-r--r--WebCore/bridge/c/c_utility.h55
10 files changed, 0 insertions, 1066 deletions
diff --git a/WebCore/bridge/c/CRuntimeObject.cpp b/WebCore/bridge/c/CRuntimeObject.cpp
deleted file mode 100644
index 4be4982..0000000
--- a/WebCore/bridge/c/CRuntimeObject.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "CRuntimeObject.h"
-#include "c_instance.h"
-
-namespace JSC {
-namespace Bindings {
-
-const ClassInfo CRuntimeObject::s_info = { "CRuntimeObject", &RuntimeObject::s_info, 0, 0 };
-
-CRuntimeObject::CRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
- : RuntimeObject(exec, globalObject, instance)
-{
-}
-
-CRuntimeObject::~CRuntimeObject()
-{
-}
-
-CInstance* CRuntimeObject::getInternalCInstance() const
-{
- return static_cast<CInstance*>(getInternalInstance());
-}
-
-
-}
-}
-
-#endif
diff --git a/WebCore/bridge/c/CRuntimeObject.h b/WebCore/bridge/c/CRuntimeObject.h
deleted file mode 100644
index bcd39d3..0000000
--- a/WebCore/bridge/c/CRuntimeObject.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef CRuntimeObject_h
-#define CRuntimeObject_h
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "runtime_object.h"
-
-namespace JSC {
-namespace Bindings {
-
-class CInstance;
-
-class CRuntimeObject : public RuntimeObject {
-public:
- CRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<CInstance>);
- virtual ~CRuntimeObject();
-
- CInstance* getInternalCInstance() const;
-
- static const ClassInfo s_info;
-
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
-};
-
-}
-}
-
-#endif
-#endif
diff --git a/WebCore/bridge/c/c_class.cpp b/WebCore/bridge/c/c_class.cpp
deleted file mode 100644
index f4ae5ca..0000000
--- a/WebCore/bridge/c/c_class.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "c_class.h"
-
-#include "c_instance.h"
-#include "c_runtime.h"
-#include "npruntime_impl.h"
-#include <runtime/Identifier.h>
-#include <runtime/JSLock.h>
-#include <wtf/text/StringHash.h>
-
-namespace JSC { namespace Bindings {
-
-CClass::CClass(NPClass* aClass)
-{
- _isa = aClass;
-}
-
-CClass::~CClass()
-{
- JSLock lock(SilenceAssertionsOnly);
-
- deleteAllValues(_methods);
- _methods.clear();
-
- deleteAllValues(_fields);
- _fields.clear();
-}
-
-typedef HashMap<NPClass*, CClass*> ClassesByIsAMap;
-static ClassesByIsAMap* classesByIsA = 0;
-
-CClass* CClass::classForIsA(NPClass* isa)
-{
- if (!classesByIsA)
- classesByIsA = new ClassesByIsAMap;
-
- CClass* aClass = classesByIsA->get(isa);
- if (!aClass) {
- aClass = new CClass(isa);
- classesByIsA->set(isa, aClass);
- }
-
- return aClass;
-}
-
-MethodList CClass::methodsNamed(const Identifier& identifier, Instance* instance) const
-{
- MethodList methodList;
-
- Method* method = _methods.get(identifier.ustring().impl());
- if (method) {
- methodList.append(method);
- return methodList;
- }
-
- NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii().data());
- const CInstance* inst = static_cast<const CInstance*>(instance);
- NPObject* obj = inst->getObject();
- if (_isa->hasMethod && _isa->hasMethod(obj, ident)){
- Method* aMethod = new CMethod(ident); // deleted in the CClass destructor
- {
- JSLock lock(SilenceAssertionsOnly);
- _methods.set(identifier.ustring().impl(), aMethod);
- }
- methodList.append(aMethod);
- }
-
- return methodList;
-}
-
-Field* CClass::fieldNamed(const Identifier& identifier, Instance* instance) const
-{
- Field* aField = _fields.get(identifier.ustring().impl());
- if (aField)
- return aField;
-
- NPIdentifier ident = _NPN_GetStringIdentifier(identifier.ascii().data());
- const CInstance* inst = static_cast<const CInstance*>(instance);
- NPObject* obj = inst->getObject();
- if (_isa->hasProperty && _isa->hasProperty(obj, ident)){
- aField = new CField(ident); // deleted in the CClass destructor
- {
- JSLock lock(SilenceAssertionsOnly);
- _fields.set(identifier.ustring().impl(), aField);
- }
- }
- return aField;
-}
-
-} } // namespace JSC::Bindings
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/bridge/c/c_class.h b/WebCore/bridge/c/c_class.h
deleted file mode 100644
index 52db2b9..0000000
--- a/WebCore/bridge/c/c_class.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BINDINGS_C_CLASS_H_
-#define BINDINGS_C_CLASS_H_
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "Bridge.h"
-#include "npruntime_internal.h"
-#include <wtf/HashMap.h>
-
-namespace JSC {
-namespace Bindings {
-
-class CClass : public Class {
-protected:
- CClass(NPClass*); // Use classForIsA to create a CClass.
-
-public:
- static CClass* classForIsA(NPClass*);
- virtual ~CClass();
-
- virtual MethodList methodsNamed(const Identifier&, Instance*) const;
- virtual Field* fieldNamed(const Identifier&, Instance*) const;
-
-private:
- NPClass* _isa;
- mutable MethodMap _methods;
- mutable FieldMap _fields;
-};
-
-} // namespace Bindings
-} // namespace JSC
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#endif
diff --git a/WebCore/bridge/c/c_instance.cpp b/WebCore/bridge/c/c_instance.cpp
deleted file mode 100644
index f1dd4e5..0000000
--- a/WebCore/bridge/c/c_instance.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "c_instance.h"
-
-#include "CRuntimeObject.h"
-#include "IdentifierRep.h"
-#include "c_class.h"
-#include "c_runtime.h"
-#include "c_utility.h"
-#include "npruntime_impl.h"
-#include "runtime_method.h"
-#include "runtime_root.h"
-#include <interpreter/CallFrame.h>
-#include <runtime/ArgList.h>
-#include <runtime/Error.h>
-#include <runtime/JSLock.h>
-#include <runtime/JSNumberCell.h>
-#include <runtime/PropertyNameArray.h>
-#include <wtf/Assertions.h>
-#include <wtf/StdLibExtras.h>
-#include <wtf/StringExtras.h>
-#include <wtf/Vector.h>
-
-using namespace WebCore;
-
-namespace JSC {
-namespace Bindings {
-
-using JSC::UString;
-
-static JSC::UString& globalExceptionString()
-{
- DEFINE_STATIC_LOCAL(JSC::UString, exceptionStr, ());
- return exceptionStr;
-}
-
-void CInstance::setGlobalException(UString exception)
-{
- globalExceptionString() = exception;
-}
-
-void CInstance::moveGlobalExceptionToExecState(ExecState* exec)
-{
- if (globalExceptionString().isNull())
- return;
-
- {
- JSLock lock(SilenceAssertionsOnly);
- throwError(exec, createError(exec, globalExceptionString()));
- }
-
- globalExceptionString() = UString();
-}
-
-CInstance::CInstance(NPObject* o, PassRefPtr<RootObject> rootObject)
- : Instance(rootObject)
-{
- _object = _NPN_RetainObject(o);
- _class = 0;
-}
-
-CInstance::~CInstance()
-{
- _NPN_ReleaseObject(_object);
-}
-
-RuntimeObject* CInstance::newRuntimeObject(ExecState* exec)
-{
- return new (exec) CRuntimeObject(exec, exec->lexicalGlobalObject(), this);
-}
-
-Class *CInstance::getClass() const
-{
- if (!_class)
- _class = CClass::classForIsA(_object->_class);
- return _class;
-}
-
-bool CInstance::supportsInvokeDefaultMethod() const
-{
- return _object->_class->invokeDefault;
-}
-
-class CRuntimeMethod : public RuntimeMethod {
-public:
- CRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
- : RuntimeMethod(exec, globalObject, name, list)
- {
- }
-
- virtual const ClassInfo* classInfo() const { return &s_info; }
-
- static const ClassInfo s_info;
-};
-
-const ClassInfo CRuntimeMethod::s_info = { "CRuntimeMethod", &RuntimeMethod::s_info, 0, 0 };
-
-JSValue CInstance::getMethod(ExecState* exec, const Identifier& propertyName)
-{
- MethodList methodList = getClass()->methodsNamed(propertyName, this);
- return new (exec) CRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
-}
-
-JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
-{
- if (!asObject(runtimeMethod)->inherits(&CRuntimeMethod::s_info))
- return throwError(exec, createTypeError(exec, "Attempt to invoke non-plug-in method on plug-in object."));
-
- const MethodList& methodList = *runtimeMethod->methods();
-
- // Overloading methods are not allowed by NPObjects. Should only be one
- // name match for a particular method.
- ASSERT(methodList.size() == 1);
-
- CMethod* method = static_cast<CMethod*>(methodList[0]);
-
- NPIdentifier ident = method->identifier();
- if (!_object->_class->hasMethod(_object, ident))
- return jsUndefined();
-
- unsigned count = exec->argumentCount();
- Vector<NPVariant, 8> cArgs(count);
-
- unsigned i;
- for (i = 0; i < count; i++)
- convertValueToNPVariant(exec, exec->argument(i), &cArgs[i]);
-
- // Invoke the 'C' method.
- bool retval = true;
- NPVariant resultVariant;
- VOID_TO_NPVARIANT(resultVariant);
-
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- ASSERT(globalExceptionString().isNull());
- retval = _object->_class->invoke(_object, ident, cArgs.data(), count, &resultVariant);
- moveGlobalExceptionToExecState(exec);
- }
-
- if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
-
- for (i = 0; i < count; i++)
- _NPN_ReleaseVariantValue(&cArgs[i]);
-
- JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
- _NPN_ReleaseVariantValue(&resultVariant);
- return resultValue;
-}
-
-
-JSValue CInstance::invokeDefaultMethod(ExecState* exec)
-{
- if (!_object->_class->invokeDefault)
- return jsUndefined();
-
- unsigned count = exec->argumentCount();
- Vector<NPVariant, 8> cArgs(count);
-
- unsigned i;
- for (i = 0; i < count; i++)
- convertValueToNPVariant(exec, exec->argument(i), &cArgs[i]);
-
- // Invoke the 'C' method.
- bool retval = true;
- NPVariant resultVariant;
- VOID_TO_NPVARIANT(resultVariant);
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- ASSERT(globalExceptionString().isNull());
- retval = _object->_class->invokeDefault(_object, cArgs.data(), count, &resultVariant);
- moveGlobalExceptionToExecState(exec);
- }
-
- if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
-
- for (i = 0; i < count; i++)
- _NPN_ReleaseVariantValue(&cArgs[i]);
-
- JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
- _NPN_ReleaseVariantValue(&resultVariant);
- return resultValue;
-}
-
-bool CInstance::supportsConstruct() const
-{
- return _object->_class->construct;
-}
-
-JSValue CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
-{
- if (!_object->_class->construct)
- return jsUndefined();
-
- unsigned count = args.size();
- Vector<NPVariant, 8> cArgs(count);
-
- unsigned i;
- for (i = 0; i < count; i++)
- convertValueToNPVariant(exec, args.at(i), &cArgs[i]);
-
- // Invoke the 'C' method.
- bool retval = true;
- NPVariant resultVariant;
- VOID_TO_NPVARIANT(resultVariant);
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- ASSERT(globalExceptionString().isNull());
- retval = _object->_class->construct(_object, cArgs.data(), count, &resultVariant);
- moveGlobalExceptionToExecState(exec);
- }
-
- if (!retval)
- throwError(exec, createError(exec, "Error calling method on NPObject."));
-
- for (i = 0; i < count; i++)
- _NPN_ReleaseVariantValue(&cArgs[i]);
-
- JSValue resultValue = convertNPVariantToValue(exec, &resultVariant, m_rootObject.get());
- _NPN_ReleaseVariantValue(&resultVariant);
- return resultValue;
-}
-
-JSValue CInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
-{
- if (hint == PreferString)
- return stringValue(exec);
- if (hint == PreferNumber)
- return numberValue(exec);
- return valueOf(exec);
-}
-
-JSValue CInstance::stringValue(ExecState* exec) const
-{
- char buf[1024];
- snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class);
- return jsString(exec, buf);
-}
-
-JSValue CInstance::numberValue(ExecState*) const
-{
- // FIXME: Implement something sensible.
- return jsNumber(0);
-}
-
-JSValue CInstance::booleanValue() const
-{
- // FIXME: Implement something sensible.
- return jsBoolean(false);
-}
-
-JSValue CInstance::valueOf(ExecState* exec) const
-{
- return stringValue(exec);
-}
-
-void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray)
-{
- if (!NP_CLASS_STRUCT_VERSION_HAS_ENUM(_object->_class) || !_object->_class->enumerate)
- return;
-
- uint32_t count;
- NPIdentifier* identifiers;
-
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- ASSERT(globalExceptionString().isNull());
- bool ok = _object->_class->enumerate(_object, &identifiers, &count);
- moveGlobalExceptionToExecState(exec);
- if (!ok)
- return;
- }
-
- for (uint32_t i = 0; i < count; i++) {
- IdentifierRep* identifier = static_cast<IdentifierRep*>(identifiers[i]);
-
- if (identifier->isString())
- nameArray.add(identifierFromNPIdentifier(exec, identifier->string()));
- else
- nameArray.add(Identifier::from(exec, identifier->number()));
- }
-
- // FIXME: This should really call NPN_MemFree but that's in WebKit
- free(identifiers);
-}
-
-}
-}
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/bridge/c/c_instance.h b/WebCore/bridge/c/c_instance.h
deleted file mode 100644
index cc1a806..0000000
--- a/WebCore/bridge/c/c_instance.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BINDINGS_C_INSTANCE_H_
-#define BINDINGS_C_INSTANCE_H_
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "Bridge.h"
-#include "runtime_root.h"
-#include <wtf/PassRefPtr.h>
-
-typedef struct NPObject NPObject;
-
-namespace JSC {
-
-class UString;
-
-namespace Bindings {
-
-class CClass;
-
-class CInstance : public Instance {
-public:
- static PassRefPtr<CInstance> create(NPObject* object, PassRefPtr<RootObject> rootObject)
- {
- return adoptRef(new CInstance(object, rootObject));
- }
-
- static void setGlobalException(JSC::UString exception);
- static void moveGlobalExceptionToExecState(ExecState*);
-
- ~CInstance ();
-
- virtual Class *getClass() const;
-
- virtual JSValue valueOf(ExecState*) const;
- virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
-
- virtual JSValue getMethod(ExecState* exec, const Identifier& propertyName);
- virtual JSValue invokeMethod(ExecState*, RuntimeMethod* method);
- virtual bool supportsInvokeDefaultMethod() const;
- virtual JSValue invokeDefaultMethod(ExecState*);
-
- virtual bool supportsConstruct() const;
- virtual JSValue invokeConstruct(ExecState*, const ArgList&);
-
- virtual void getPropertyNames(ExecState*, PropertyNameArray&);
-
- JSValue stringValue(ExecState*) const;
- JSValue numberValue(ExecState*) const;
- JSValue booleanValue() const;
-
- NPObject *getObject() const { return _object; }
-
-private:
- CInstance(NPObject*, PassRefPtr<RootObject>);
-
- virtual RuntimeObject* newRuntimeObject(ExecState*);
-
- mutable CClass *_class;
- NPObject *_object;
-};
-
-} // namespace Bindings
-
-} // namespace JSC
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#endif
diff --git a/WebCore/bridge/c/c_runtime.cpp b/WebCore/bridge/c/c_runtime.cpp
deleted file mode 100644
index e038cd4..0000000
--- a/WebCore/bridge/c/c_runtime.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "c_runtime.h"
-
-#include "c_instance.h"
-#include "c_utility.h"
-#include "npruntime_impl.h"
-#include <runtime/JSLock.h>
-
-namespace JSC {
-namespace Bindings {
-
-JSValue CField::valueFromInstance(ExecState* exec, const Instance* inst) const
-{
- const CInstance* instance = static_cast<const CInstance*>(inst);
- NPObject* obj = instance->getObject();
- if (obj->_class->getProperty) {
- NPVariant property;
- VOID_TO_NPVARIANT(property);
-
- bool result;
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- result = obj->_class->getProperty(obj, _fieldIdentifier, &property);
- CInstance::moveGlobalExceptionToExecState(exec);
- }
- if (result) {
- JSValue result = convertNPVariantToValue(exec, &property, instance->rootObject());
- _NPN_ReleaseVariantValue(&property);
- return result;
- }
- }
- return jsUndefined();
-}
-
-void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue aValue) const
-{
- const CInstance* instance = static_cast<const CInstance*>(inst);
- NPObject* obj = instance->getObject();
- if (obj->_class->setProperty) {
- NPVariant variant;
- convertValueToNPVariant(exec, aValue, &variant);
-
- {
- JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
- obj->_class->setProperty(obj, _fieldIdentifier, &variant);
- CInstance::moveGlobalExceptionToExecState(exec);
- }
-
- _NPN_ReleaseVariantValue(&variant);
- }
-}
-
-} }
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/bridge/c/c_runtime.h b/WebCore/bridge/c/c_runtime.h
deleted file mode 100644
index 5355934..0000000
--- a/WebCore/bridge/c/c_runtime.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef BINDINGS_C_RUNTIME_H_
-#define BINDINGS_C_RUNTIME_H_
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "Bridge.h"
-#include "npruntime_internal.h"
-
-namespace JSC {
-namespace Bindings {
-
-class CField : public Field {
-public:
- CField(NPIdentifier ident) : _fieldIdentifier(ident) { }
-
- virtual JSValue valueFromInstance(ExecState*, const Instance*) const;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const;
-
- NPIdentifier identifier() const { return _fieldIdentifier; }
-
-private:
- NPIdentifier _fieldIdentifier;
-};
-
-
-class CMethod : public Method
-{
-public:
- CMethod(NPIdentifier ident) : _methodIdentifier(ident) { }
-
- NPIdentifier identifier() const { return _methodIdentifier; }
- virtual int numParameters() const { return 0; }
-
-private:
- NPIdentifier _methodIdentifier;
-};
-
-} // namespace Bindings
-} // namespace JSC
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#endif
diff --git a/WebCore/bridge/c/c_utility.cpp b/WebCore/bridge/c/c_utility.cpp
deleted file mode 100644
index ea970eb..0000000
--- a/WebCore/bridge/c/c_utility.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "c_utility.h"
-
-#include "CRuntimeObject.h"
-#include "JSDOMBinding.h"
-#include "JSDOMWindow.h"
-#include "NP_jsobject.h"
-#include "c_instance.h"
-#include <runtime/JSGlobalObject.h>
-#include <runtime/JSLock.h>
-#include "PlatformString.h"
-#include "npruntime_impl.h"
-#include "npruntime_priv.h"
-#include "runtime_object.h"
-#include "runtime_root.h"
-#include <wtf/Assertions.h>
-
-namespace JSC { namespace Bindings {
-
-static String convertUTF8ToUTF16WithLatin1Fallback(const NPUTF8* UTF8Chars, int UTF8Length)
-{
- ASSERT(UTF8Chars || UTF8Length == 0);
-
- if (UTF8Length == -1)
- UTF8Length = static_cast<int>(strlen(UTF8Chars));
-
- String result = String::fromUTF8(UTF8Chars, UTF8Length);
-
- // If we got back a null string indicating an unsuccessful conversion, fall back to latin 1.
- // Some plugins return invalid UTF-8 in NPVariantType_String, see <http://bugs.webkit.org/show_bug.cgi?id=5163>
- // There is no "bad data" for latin1. It is unlikely that the plugin was really sending text in this encoding,
- // but it should have used UTF-8, and now we are simply avoiding a crash.
- if (result.isNull())
- result = String(UTF8Chars, UTF8Length);
-
- return result;
-}
-
-// Variant value must be released with NPReleaseVariantValue()
-void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result)
-{
- JSLock lock(SilenceAssertionsOnly);
-
- VOID_TO_NPVARIANT(*result);
-
- if (value.isString()) {
- UString ustring = value.toString(exec);
- CString cstring = ustring.utf8();
- NPString string = { (const NPUTF8*)cstring.data(), static_cast<uint32_t>(cstring.length()) };
- NPN_InitializeVariantWithStringCopy(result, &string);
- } else if (value.isNumber()) {
- DOUBLE_TO_NPVARIANT(value.toNumber(exec), *result);
- } else if (value.isBoolean()) {
- BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), *result);
- } else if (value.isNull()) {
- NULL_TO_NPVARIANT(*result);
- } else if (value.isObject()) {
- JSObject* object = asObject(value);
- if (object->classInfo() == &CRuntimeObject::s_info) {
- CRuntimeObject* runtimeObject = static_cast<CRuntimeObject*>(object);
- CInstance* instance = runtimeObject->getInternalCInstance();
- if (instance) {
- NPObject* obj = instance->getObject();
- _NPN_RetainObject(obj);
- OBJECT_TO_NPVARIANT(obj, *result);
- }
- } else {
-#ifdef ANDROID
- RootObject* rootObject = findRootObject(exec->dynamicGlobalObject());
- if (!rootObject)
- rootObject = findRootObject(exec->lexicalGlobalObject());
-#else
- JSGlobalObject* globalObject = exec->dynamicGlobalObject();
-
- RootObject* rootObject = findRootObject(globalObject);
-#endif
- if (rootObject) {
- NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject);
- OBJECT_TO_NPVARIANT(npObject, *result);
- }
- }
- }
-}
-
-JSValue convertNPVariantToValue(ExecState* exec, const NPVariant* variant, RootObject* rootObject)
-{
- JSLock lock(SilenceAssertionsOnly);
-
- NPVariantType type = variant->type;
-
- if (type == NPVariantType_Bool)
- return jsBoolean(NPVARIANT_TO_BOOLEAN(*variant));
- if (type == NPVariantType_Null)
- return jsNull();
- if (type == NPVariantType_Void)
- return jsUndefined();
- if (type == NPVariantType_Int32)
- return jsNumber(NPVARIANT_TO_INT32(*variant));
- if (type == NPVariantType_Double)
- return jsNumber(NPVARIANT_TO_DOUBLE(*variant));
- if (type == NPVariantType_String)
- return WebCore::jsString(exec, convertNPStringToUTF16(&variant->value.stringValue));
- if (type == NPVariantType_Object) {
- NPObject* obj = variant->value.objectValue;
-
- if (obj->_class == NPScriptObjectClass)
- // Get JSObject from NP_JavaScriptObject.
- return ((JavaScriptObject*)obj)->imp;
-
- // Wrap NPObject in a CInstance.
- return CInstance::create(obj, rootObject)->createRuntimeObject(exec);
- }
-
- return jsUndefined();
-}
-
-String convertNPStringToUTF16(const NPString* string)
-{
- return String::fromUTF8WithLatin1Fallback(string->UTF8Characters, string->UTF8Length);
-}
-
-Identifier identifierFromNPIdentifier(ExecState* exec, const NPUTF8* name)
-{
- return Identifier(exec, WebCore::stringToUString(convertUTF8ToUTF16WithLatin1Fallback(name, -1)));
-}
-
-} }
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/WebCore/bridge/c/c_utility.h b/WebCore/bridge/c/c_utility.h
deleted file mode 100644
index 43cb16c..0000000
--- a/WebCore/bridge/c/c_utility.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef C_UTILITY_H_
-#define C_UTILITY_H_
-
-#if ENABLE(NETSCAPE_PLUGIN_API)
-
-#include "npruntime_internal.h"
-#include <runtime/JSValue.h>
-#include <wtf/Forward.h>
-
-namespace JSC {
-
-class ExecState;
-class Identifier;
-
-namespace Bindings {
-
-class RootObject;
-
-typedef uint16_t NPUTF16;
-
-WTF::String convertNPStringToUTF16(const NPString *string);
-void convertValueToNPVariant(ExecState*, JSValue, NPVariant* result);
-JSValue convertNPVariantToValue(ExecState*, const NPVariant*, RootObject*);
-Identifier identifierFromNPIdentifier(ExecState*, const NPUTF8* name);
-
-} }
-
-#endif // ENABLE(NETSCAPE_PLUGIN_API)
-
-#endif