[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
rjw
rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:15:50 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 48ebf26da0d4376fc3c452102dd5a986af471073
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Dec 3 01:21:39 2003 +0000
WebCore:
Return a value that is backed by RuntimeObjectImpl, instead
of a DOM object for applet[0]. This is better than having
the DOM object redirect to the RuntimeObjectImpl.
Reviewed by Chris.
* khtml/ecma/kjs_html.cpp:
(KJS::HTMLCollection::tryGet):
JavaScriptCore:
Added support for calling simple methods in Java from JavaScript.
(void return and no parameters). Yay, LiveConnect lives.
Still need write argument and return value conversion code.
Reviewed by Chris.
* JavaScriptCore.pbproj/project.pbxproj:
* bindings/jni/jni_instance.cpp:
(JavaInstance::getClass):
(JavaInstance::invokeMethod):
* bindings/jni/jni_instance.h:
* bindings/jni/jni_runtime.cpp:
(JavaMethod::JavaMethod):
(JavaMethod::signature):
(JavaMethod::JNIReturnType):
* bindings/jni/jni_runtime.h:
(Bindings::JavaMethod::_commonDelete):
(Bindings::JavaMethod::_commonCopy):
(Bindings::JavaMethod::name):
* bindings/jni/jni_utility.cpp:
(signatureFromPrimitiveType):
* bindings/jni/jni_utility.h:
* bindings/runtime.h:
* bindings/runtime_method.cpp: Added.
(RuntimeMethodImp::RuntimeMethodImp):
(RuntimeMethodImp::~RuntimeMethodImp):
(RuntimeMethodImp::get):
(RuntimeMethodImp::implementsCall):
(RuntimeMethodImp::call):
(RuntimeMethodImp::codeType):
(RuntimeMethodImp::execute):
* bindings/runtime_method.h: Added.
* bindings/runtime_object.cpp:
(RuntimeObjectImp::RuntimeObjectImp):
(RuntimeObjectImp::get):
* bindings/runtime_object.h:
* kjs/function.cpp:
(FunctionImp::FunctionImp):
* kjs/interpreter.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5671 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 3b7dd51..98db8ba 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,46 @@
+2003-12-02 Richard Williamson <rjw at apple.com>
+
+ Added support for calling simple methods in Java from JavaScript.
+ (void return and no parameters). Yay, LiveConnect lives.
+
+ Still need write argument and return value conversion code.
+
+ Reviewed by Chris.
+
+ * JavaScriptCore.pbproj/project.pbxproj:
+ * bindings/jni/jni_instance.cpp:
+ (JavaInstance::getClass):
+ (JavaInstance::invokeMethod):
+ * bindings/jni/jni_instance.h:
+ * bindings/jni/jni_runtime.cpp:
+ (JavaMethod::JavaMethod):
+ (JavaMethod::signature):
+ (JavaMethod::JNIReturnType):
+ * bindings/jni/jni_runtime.h:
+ (Bindings::JavaMethod::_commonDelete):
+ (Bindings::JavaMethod::_commonCopy):
+ (Bindings::JavaMethod::name):
+ * bindings/jni/jni_utility.cpp:
+ (signatureFromPrimitiveType):
+ * bindings/jni/jni_utility.h:
+ * bindings/runtime.h:
+ * bindings/runtime_method.cpp: Added.
+ (RuntimeMethodImp::RuntimeMethodImp):
+ (RuntimeMethodImp::~RuntimeMethodImp):
+ (RuntimeMethodImp::get):
+ (RuntimeMethodImp::implementsCall):
+ (RuntimeMethodImp::call):
+ (RuntimeMethodImp::codeType):
+ (RuntimeMethodImp::execute):
+ * bindings/runtime_method.h: Added.
+ * bindings/runtime_object.cpp:
+ (RuntimeObjectImp::RuntimeObjectImp):
+ (RuntimeObjectImp::get):
+ * bindings/runtime_object.h:
+ * kjs/function.cpp:
+ (FunctionImp::FunctionImp):
+ * kjs/interpreter.h:
+
2003-12-01 Darin Adler <darin at apple.com>
Reviewed by Maciej.
diff --git a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
index 68ca1ca..cda5f0a 100644
--- a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
@@ -240,6 +240,7 @@
70B16A290569A10A00DB756D,
517D52DF056BF2F6003851BD,
517D534A056BFB5D003851BD,
+ 51A58A90057D3A6A00A3E942,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -298,6 +299,7 @@
70B16A280569A10A00DB756D,
517D52DE056BF2F6003851BD,
517D5349056BFB5D003851BD,
+ 51A58A8F057D3A6A00A3E942,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -574,18 +576,20 @@
};
51856D950562EE9C008B9D83 = {
children = (
+ 517D52DC056BF2F5003851BD,
+ 517D52DD056BF2F6003851BD,
+ 517D5347056BFB5D003851BD,
+ 517D5348056BFB5D003851BD,
511B0877056468BB0080E486,
511B0876056468BB0080E486,
51856D8F0562EE95008B9D83,
51856D900562EE95008B9D83,
704FD44505698F17003DBED9,
511B0870056468730080E486,
+ 51A58A8D057D3A6A00A3E942,
+ 51A58A8E057D3A6A00A3E942,
70B16A260569A10900DB756D,
70B16A270569A10900DB756D,
- 517D52DC056BF2F5003851BD,
- 517D52DD056BF2F6003851BD,
- 517D5347056BFB5D003851BD,
- 517D5348056BFB5D003851BD,
);
isa = PBXGroup;
name = bindings;
@@ -606,6 +610,36 @@
settings = {
};
};
+ 51A58A8D057D3A6A00A3E942 = {
+ expectedFileType = sourcecode.cpp.cpp;
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ name = runtime_method.cpp;
+ path = bindings/runtime_method.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 51A58A8E057D3A6A00A3E942 = {
+ expectedFileType = sourcecode.c.h;
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ name = runtime_method.h;
+ path = bindings/runtime_method.h;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 51A58A8F057D3A6A00A3E942 = {
+ fileRef = 51A58A8D057D3A6A00A3E942;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
+ 51A58A90057D3A6A00A3E942 = {
+ fileRef = 51A58A8E057D3A6A00A3E942;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
//510
//511
//512
diff --git a/JavaScriptCore/bindings/jni/jni_instance.cpp b/JavaScriptCore/bindings/jni/jni_instance.cpp
index 9c3475d..0b7890a 100644
--- a/JavaScriptCore/bindings/jni/jni_instance.cpp
+++ b/JavaScriptCore/bindings/jni/jni_instance.cpp
@@ -22,12 +22,13 @@
* (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 <jni_utility.h>
#include <jni_class.h>
#include <jni_instance.h>
#include <jni_runtime.h>
+#include <jni_utility.h>
using namespace Bindings;
+using namespace KJS;
JavaInstance::JavaInstance (jobject instance)
{
@@ -51,6 +52,88 @@ Class *JavaInstance::getClass() const
return JavaClass::classForInstance (_instance->_instance);
}
+Value JavaInstance::invokeMethod (const Method *method, const List &args)
+{
+ const JavaMethod *jMethod = static_cast<const JavaMethod*>(method);
+ int i, count = args.size();
+ jvalue *jArgs;
+
+ fprintf(stderr,"%s: this=%p, invoking %s which returns %s and takes %d args\n", __PRETTY_FUNCTION__, this, method->name(), method->returnType(), count);
+
+ if (count > 0) {
+ jArgs = (jvalue *)malloc (count * sizeof(jvalue));
+ }
+ else
+ jArgs = 0;
+
+ for (i = 0; i < count; i++) {
+ fprintf (stderr, "%s: %d, type %d\n", __PRETTY_FUNCTION__, i, args.at(i).type());
+ }
+
+ jvalue result;
+ switch (jMethod->JNIReturnType()){
+ case void_type: {
+ callJNIVoidMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case object_type: {
+ result.l = callJNIObjectMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case boolean_type: {
+ result.z = callJNIBooleanMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case byte_type: {
+ result.b = callJNIByteMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case char_type: {
+ result.c = callJNICharMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case short_type: {
+ result.s = callJNIShortMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case int_type: {
+ result.i = callJNIIntMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case long_type: {
+ result.j = callJNILongMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case float_type: {
+ result.f = callJNIFloatMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case double_type: {
+ result.d = callJNIDoubleMethod (_instance->_instance, method->name(), jMethod->signature(), jArgs);
+ }
+ break;
+
+ case invalid_type:
+ default:
+ break;
+ }
+
+ // FIXME: create a KJS::Value from the jvalue result.
+
+ free (jArgs);
+
+ return Undefined();
+}
+
JObjectWrapper::JObjectWrapper(jobject instance)
{
diff --git a/JavaScriptCore/bindings/jni/jni_instance.h b/JavaScriptCore/bindings/jni/jni_instance.h
index ef79d4d..896a028 100644
--- a/JavaScriptCore/bindings/jni/jni_instance.h
+++ b/JavaScriptCore/bindings/jni/jni_instance.h
@@ -38,6 +38,7 @@ class JavaClass;
class JObjectWrapper
{
friend class JavaInstance;
+friend class JavaMethod;
protected:
JObjectWrapper(jobject instance);
@@ -83,6 +84,8 @@ public:
};
jobject javaInstance() const { return _instance->_instance; }
+
+ virtual KJS::Value invokeMethod (const Method *method, const KJS::List &args);
private:
JObjectWrapper *_instance;
diff --git a/JavaScriptCore/bindings/jni/jni_runtime.cpp b/JavaScriptCore/bindings/jni/jni_runtime.cpp
index e0e36df..20bc897 100644
--- a/JavaScriptCore/bindings/jni/jni_runtime.cpp
+++ b/JavaScriptCore/bindings/jni/jni_runtime.cpp
@@ -22,8 +22,9 @@
* (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 <value.h>
#include <internal.h>
+#include <ustring.h>
+#include <value.h>
#include <jni_utility.h>
#include <jni_runtime.h>
@@ -125,8 +126,34 @@ JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod)
jobject returnType = callJNIObjectMethod (aMethod, "getReturnType", "()Ljava/lang/Class;");
jstring returnTypeName = (jstring)callJNIObjectMethod (returnType, "getName", "()Ljava/lang/String;");
_returnType = new JavaString (env, returnTypeName);
+ _JNIReturnType = primitiveTypeFromClassName (_returnType->characters());
// Get method name
jstring methodName = (jstring)callJNIObjectMethod (aMethod, "getName", "()Ljava/lang/String;");
_name = new JavaString (env, methodName);
}
+
+const char *JavaMethod::signature() const
+{
+ if (_signature == 0){
+ int i;
+
+ _signature = new UString("(");
+ for (i = 0; i < _numParameters; i++) {
+ }
+ _signature->append(")");
+
+ _signature->append(signatureFromPrimitiveType (_JNIReturnType));
+ if (_JNIReturnType == object_type) {
+ _signature->append(_returnType->characters());
+ _signature->append(";");
+ }
+ }
+
+ return _signature->ascii();
+}
+
+JNIType JavaMethod::JNIReturnType() const
+{
+ return _JNIReturnType;
+}
diff --git a/JavaScriptCore/bindings/jni/jni_runtime.h b/JavaScriptCore/bindings/jni/jni_runtime.h
index 34ffa69..62fd6d3 100644
--- a/JavaScriptCore/bindings/jni/jni_runtime.h
+++ b/JavaScriptCore/bindings/jni/jni_runtime.h
@@ -215,6 +215,7 @@ public:
void _commonDelete() {
delete _name;
delete _returnType;
+ delete _signature;
delete [] _parameters;
};
@@ -232,6 +233,7 @@ public:
for (i = 0; i < _numParameters; i++) {
_parameters[i] = other._parameters[i];
}
+ _signature = other._signature;
};
JavaMethod(const JavaMethod &other) : Method() {
@@ -251,17 +253,20 @@ public:
virtual KJS::Value value() const { return KJS::Value(0); }
virtual const char *name() const { return _name->characters(); };
- virtual const char *signature() const { return _signature->characters(); };
virtual RuntimeType returnType() const { return _returnType->characters(); };
virtual Parameter *parameterAt(long i) const { return &_parameters[i]; };
virtual long numParameters() const { return _numParameters; };
+ const char *signature() const;
+ JNIType JNIReturnType() const;
+
private:
JavaParameter *_parameters;
long _numParameters;
JavaString *_name;
- JavaString *_signature;
+ mutable KJS::UString *_signature;
JavaString *_returnType;
+ JNIType _JNIReturnType;
};
}
diff --git a/JavaScriptCore/bindings/jni/jni_utility.cpp b/JavaScriptCore/bindings/jni/jni_utility.cpp
index 452bca2..dd21487 100644
--- a/JavaScriptCore/bindings/jni/jni_utility.cpp
+++ b/JavaScriptCore/bindings/jni/jni_utility.cpp
@@ -363,6 +363,46 @@ JNIType primitiveTypeFromClassName(const char *name)
return type;
}
+const char *signatureFromPrimitiveType(JNIType type)
+{
+ switch (type){
+ case void_type:
+ return "V";
+
+ case object_type:
+ return "L";
+
+ case boolean_type:
+ return "Z";
+
+ case byte_type:
+ return "B";
+
+ case char_type:
+ return "C";
+
+ case short_type:
+ return "S";
+
+ case int_type:
+ return "I";
+
+ case long_type:
+ return "J";
+
+ case float_type:
+ return "F";
+
+ case double_type:
+ return "D";
+
+ case invalid_type:
+ default:
+ break;
+ }
+ return "";
+}
+
jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature)
{
JavaVM *jvm = getJavaVM();
diff --git a/JavaScriptCore/bindings/jni/jni_utility.h b/JavaScriptCore/bindings/jni/jni_utility.h
index 6d25bc7..e8e2da2 100644
--- a/JavaScriptCore/bindings/jni/jni_utility.h
+++ b/JavaScriptCore/bindings/jni/jni_utility.h
@@ -48,6 +48,8 @@ const char *getCharactersFromJStringInEnv (JNIEnv *env, jstring aJString);
void releaseCharactersForJStringInEnv (JNIEnv *env, jstring aJString, const char *s);
JNIType primitiveTypeFromClassName(const char *name);
+const char *signatureFromPrimitiveType(JNIType type);
+
jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *signature);
jobject callJNIObjectMethod( jobject obj, const char *name, const char *sig, ... );
diff --git a/JavaScriptCore/bindings/runtime.h b/JavaScriptCore/bindings/runtime.h
index d251f81..5263c16 100644
--- a/JavaScriptCore/bindings/runtime.h
+++ b/JavaScriptCore/bindings/runtime.h
@@ -106,6 +106,8 @@ public:
virtual Class *getClass() const = 0;
virtual KJS::Value getValueOfField (const Field *aField) const;
+
+ virtual KJS::Value invokeMethod (const Method *method, const KJS::List &args) = 0;
virtual ~Instance() {};
};
diff --git a/JavaScriptCore/bindings/runtime_method.cpp b/JavaScriptCore/bindings/runtime_method.cpp
new file mode 100644
index 0000000..5e187eb
--- /dev/null
+++ b/JavaScriptCore/bindings/runtime_method.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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.
+ */
+
+#include "context.h"
+#include "internal.h"
+#include "runtime_method.h"
+#include "runtime_object.h"
+
+using namespace Bindings;
+using namespace KJS;
+
+RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::Method *m) : FunctionImp (exec, ident)
+{
+ method = m;
+}
+
+RuntimeMethodImp::~RuntimeMethodImp()
+{
+}
+
+Value RuntimeMethodImp::get(ExecState *exec, const Identifier &propertyName) const
+{
+ fprintf(stderr,"%s: this=%p, %s\n", __PRETTY_FUNCTION__, this, propertyName.ascii());
+ // Find the arguments from the closest context.
+ if (propertyName == argumentsPropertyName) {
+ ContextImp *context = exec->_context;
+ while (context) {
+ if (context->function() == this)
+ return static_cast<ActivationImp *>
+ (context->activationObject())->get(exec, propertyName);
+ context = context->callingContext();
+ }
+ return Undefined();
+ }
+
+ // Compute length of parameters.
+ if (propertyName == lengthPropertyName) {
+ return Number(method->numParameters());
+ }
+
+ return FunctionImp::get(exec, propertyName);
+}
+
+bool RuntimeMethodImp::implementsCall() const
+{
+ return true;
+}
+
+Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args)
+{
+ fprintf(stderr,"%s: this=%p, %s, object = %p\n", __PRETTY_FUNCTION__, this, method->name(), &thisObj);
+
+ if (method) {
+ RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
+ if (imp) {
+ imp->getInternalInstance()->invokeMethod(method, args);
+ }
+ }
+
+ return Undefined();
+}
+
+CodeType RuntimeMethodImp::codeType() const
+{
+ fprintf(stderr,"%s: this=%p\n", __PRETTY_FUNCTION__, this);
+ // NOTE: What is this? I don't think this is ever called.
+ return FunctionCode;
+}
+
+
+Completion RuntimeMethodImp::execute(ExecState *exec)
+{
+ fprintf(stderr,"%s: this=%p\n", __PRETTY_FUNCTION__, this);
+ // NOTE: What is this? I don't think this is ever called.
+ return Completion(Normal, Undefined());
+}
+
diff --git a/WebCore/kwq/KWQGuardedPtr.h b/JavaScriptCore/bindings/runtime_method.h
similarity index 68%
copy from WebCore/kwq/KWQGuardedPtr.h
copy to JavaScriptCore/bindings/runtime_method.h
index c7bd5a1..c3615ad 100644
--- a/WebCore/kwq/KWQGuardedPtr.h
+++ b/JavaScriptCore/bindings/runtime_method.h
@@ -22,33 +22,35 @@
* (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 _RUNTIME_FUNCTION_H_
+#define _RUNTIME_FUNCTION_H_
-#ifndef QGUARDEDPTR_H_
-#define QGUARDEDPTR_H_
+#include <JavaScriptCore/runtime.h>
+#include <JavaScriptCore/object.h>
-#include "KWQPtrList.h"
+namespace KJS {
-class QObject;
-class KWQGuardedPtrBase {
+class RuntimeMethodImp : public FunctionImp
+{
public:
- KWQGuardedPtrBase(QObject* = 0);
+ RuntimeMethodImp(ExecState *exec, const Identifier &n = Identifier::null(), Bindings::Method *method = 0);
- QObject* pointer() const { return iterator.current(); }
- bool isNull() const { return pointer() == 0; }
+ virtual ~RuntimeMethodImp();
+
+ virtual Value get(ExecState *exec, const Identifier &propertyName) const;
+
+ virtual bool implementsCall() const;
+ virtual Value call(ExecState *exec, Object &thisObj, const List &args);
+
+ virtual CodeType codeType() const;
+ virtual Completion execute(ExecState *exec);
+
private:
- QPtrListIterator<QObject> iterator;
+ Bindings::Method *method;
};
-template <class T> class QGuardedPtr : public KWQGuardedPtrBase {
-public:
- QGuardedPtr() { }
- QGuardedPtr(T* p) : KWQGuardedPtrBase(p) { }
-
- T& operator*() const { return *(T*)pointer(); }
- operator T*() const { return (T*)pointer(); }
- T* operator->() const { return (T*)pointer(); }
};
-#endif
+#endif
\ No newline at end of file
diff --git a/JavaScriptCore/bindings/runtime_object.cpp b/JavaScriptCore/bindings/runtime_object.cpp
index 8a82aa6..564e863 100644
--- a/JavaScriptCore/bindings/runtime_object.cpp
+++ b/JavaScriptCore/bindings/runtime_object.cpp
@@ -23,15 +23,16 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "value.h"
-#include "object.h"
-#include "types.h"
+#include "error_object.h"
+#include "function.h"
#include "interpreter.h"
+#include "object.h"
#include "operations.h"
+#include "runtime_method.h"
#include "runtime_object.h"
-#include "error_object.h"
+#include "types.h"
+#include "value.h"
-#include "runtime_object.h"
#include <assert.h>
@@ -62,6 +63,9 @@ RuntimeObjectImp::RuntimeObjectImp(Bindings::Instance *i, bool oi) : ObjectImp (
{
ownsInstance = oi;
instance = i;
+ _classInfo.className = 0;
+ _classInfo.parentClass = 0;
+ _classInfo.propHashTable = 0;
_initializeClassInfoFromInstance();
}
@@ -78,6 +82,11 @@ Value RuntimeObjectImp::get(ExecState *exec, const Identifier &propertyName) con
// Now check if a method with specified name exists, if so return a function object for
// that method.
+ Method *aMethod = instance->getClass()->methodNamed(propertyName.ascii());
+ if (aMethod) {
+ printf ("%s: found %s(%p)\n", __PRETTY_FUNCTION__, propertyName.ascii(), aMethod);
+ return Object (new RuntimeMethodImp(exec, propertyName, aMethod));
+ }
return Undefined();
}
diff --git a/JavaScriptCore/bindings/runtime_object.h b/JavaScriptCore/bindings/runtime_object.h
index aa1a0b0..01725ae 100644
--- a/JavaScriptCore/bindings/runtime_object.h
+++ b/JavaScriptCore/bindings/runtime_object.h
@@ -27,8 +27,8 @@
#include <JavaVM/jni.h>
-#include "runtime.h"
-#include "object.h"
+#include <JavaScriptCore/runtime.h>
+#include <JavaScriptCore/object.h>
namespace KJS {
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index 19b6fd2..3e891e9 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -59,7 +59,6 @@ FunctionImp::FunctionImp(ExecState *exec, const Identifier &n)
static_cast<FunctionPrototypeImp*>(exec->interpreter()->builtinFunctionPrototype().imp())
), param(0L), ident(n)
{
- //fprintf(stderr,"FunctionImp::FunctionImp this=%p\n");
}
FunctionImp::~FunctionImp()
diff --git a/JavaScriptCore/kjs/interpreter.h b/JavaScriptCore/kjs/interpreter.h
index c589497..81b767c 100644
--- a/JavaScriptCore/kjs/interpreter.h
+++ b/JavaScriptCore/kjs/interpreter.h
@@ -386,6 +386,10 @@ namespace KJS {
class ExecState {
friend class InterpreterImp;
friend class FunctionImp;
+#if APPLE_CHANGES
+ friend class RuntimeMethodImp;
+#endif
+
friend class GlobalFuncImp;
public:
/**
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 617e06d..530ef24 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2003-12-02 Richard Williamson <rjw at apple.com>
+
+ Return a value that is backed by RuntimeObjectImpl, instead
+ of a DOM object for applet[0]. This is better than having
+ the DOM object redirect to the RuntimeObjectImpl.
+
+ Reviewed by Chris.
+
+ * khtml/ecma/kjs_html.cpp:
+ (KJS::HTMLCollection::tryGet):
+
2003-12-02 Maciej Stachowiak <mjs at apple.com>
Reviewed by John.
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index 0b50aca..bf292b0 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -2904,6 +2904,20 @@ Value KJS::HTMLCollection::tryGet(ExecState *exec, const Identifier &propertyNam
unsigned int u = propertyName.toULong(&ok);
if (ok) {
DOM::Node node = collection.item(u);
+
+#if APPLE_CHANGES
+ if (node.handle()->id() == ID_APPLET) {
+ DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node);
+ DOM::HTMLAppletElementImpl *appletElement = static_cast<DOM::HTMLAppletElementImpl *>(element.handle());
+
+ fprintf (stderr,"%s: need to return applet instance\n", __PRETTY_FUNCTION__);
+ if (appletElement->getAppletInstance()) {
+ // The instance is owned by the applet element.
+ RuntimeObjectImp *appletImp = new RuntimeObjectImp(appletElement->getAppletInstance(), false);
+ return Value(appletImp);
+ }
+ }
+#endif
return getDOMNode(exec,node);
}
else
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list