[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:28:36 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit c7ba08c1ec4affb23f67c4c78e131700252e9d39
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Mar 5 01:34:45 2004 +0000
Implementation of NP_JavaScriptObject. This is the 'C' class
that wraps a JavaScript object. Still have more stubs to
implement before this is complete.
Reviewed by Chris.
* JavaScriptCore.pbproj/project.pbxproj:
* bindings/NP_jsobject.cpp: Added.
(coerceValueToNPValueType):
(convertValueToNPValueType):
(convertNPValueTypeToValue):
(listFromNPArray):
(jsAllocate):
(jsDeallocate):
(identiferFromNPIdentifier):
(NP_Call):
(NP_Evaluate):
(NP_GetProperty):
(NP_SetProperty):
(NP_RemoveProperty):
(NP_ToString):
(NP_GetPropertyAtIndex):
(NP_SetPropertyAtIndex):
* bindings/NP_runtime.cpp:
(NP_ObjectAtIndex):
* bindings/NP_runtime.h:
* bindings/runtime_object.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 6d7bf2c..78fc6bd 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,34 @@
2004-03-04 Richard Williamson <rjw at apple.com>
+ Implementation of NP_JavaScriptObject. This is the 'C' class
+ that wraps a JavaScript object.
+
+ Reviewed by Chris.
+
+ * JavaScriptCore.pbproj/project.pbxproj:
+ * bindings/NP_jsobject.cpp: Added.
+ (coerceValueToNPValueType):
+ (convertValueToNPValueType):
+ (convertNPValueTypeToValue):
+ (listFromNPArray):
+ (jsAllocate):
+ (jsDeallocate):
+ (identiferFromNPIdentifier):
+ (NP_Call):
+ (NP_Evaluate):
+ (NP_GetProperty):
+ (NP_SetProperty):
+ (NP_RemoveProperty):
+ (NP_ToString):
+ (NP_GetPropertyAtIndex):
+ (NP_SetPropertyAtIndex):
+ * bindings/NP_runtime.cpp:
+ (NP_ObjectAtIndex):
+ * bindings/NP_runtime.h:
+ * bindings/runtime_object.h:
+
+2004-03-04 Richard Williamson <rjw at apple.com>
+
Added NP_Array implementation.
Changed NP_Boolean to just depend on two static instances, no
diff --git a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
index 50f6d3b..5f9af78 100644
--- a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
@@ -317,6 +317,7 @@
7084D9BA05DD6CF8007E4C0E,
5114F47D05E4426200D1BBBD,
515B879305F535B300EABBF9,
+ 51532CC805F7FD2C00EC779C,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -534,6 +535,21 @@
);
};
};
+ 51532CC705F7FD2C00EC779C = {
+ fileEncoding = 30;
+ isa = PBXFileReference;
+ lastKnownFileType = sourcecode.cpp.cpp;
+ name = NP_jsobject.cpp;
+ path = bindings/NP_jsobject.cpp;
+ refType = 4;
+ sourceTree = "<group>";
+ };
+ 51532CC805F7FD2C00EC779C = {
+ fileRef = 51532CC705F7FD2C00EC779C;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
515B876A05F532B900EABBF9 = {
fileEncoding = 30;
isa = PBXFileReference;
@@ -658,6 +674,7 @@
};
51856D950562EE9C008B9D83 = {
children = (
+ 51532CC705F7FD2C00EC779C,
515B876A05F532B900EABBF9,
515B879205F535B300EABBF9,
517D52DC056BF2F5003851BD,
diff --git a/JavaScriptCore/bindings/NP_jsobject.cpp b/JavaScriptCore/bindings/NP_jsobject.cpp
new file mode 100644
index 0000000..abcbbb2
--- /dev/null
+++ b/JavaScriptCore/bindings/NP_jsobject.cpp
@@ -0,0 +1,218 @@
+/*
+ * 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 <NP_runtime.h>
+
+#include <runtime.h>
+#include <runtime_object.h>
+#include <runtime_root.h>
+
+using namespace KJS;
+using namespace KJS::Bindings;
+
+typedef enum
+{
+ NP_NumberValueType,
+ NP_StringValueType,
+ NP_BooleanValueType,
+ NP_NullValueType,
+ NP_UndefinedValueType,
+ NP_ObjectValueType,
+ NP_InvalidValueType
+} NP_ValueType;
+
+NP_Object *coerceValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value, NP_ValueType type)
+{
+ return 0;
+}
+
+NP_Object *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value)
+{
+ return 0;
+}
+
+Value convertNPValueTypeToValue (KJS::ExecState *exec, const NP_Object *obj)
+{
+ return Undefined();
+}
+
+static KJS::List listFromNPArray(KJS::ExecState *exec, NP_Object **args, unsigned argCount)
+{
+ KJS::List aList;
+ return aList;
+}
+
+typedef struct
+{
+ NP_Object object;
+ KJS::ObjectImp *imp;
+ KJS::Bindings::RootObject *root;
+} JavaScriptObject;
+
+static NP_Object *jsAllocate()
+{
+ return (NP_Object *)malloc(sizeof(JavaScriptObject));
+}
+
+static void jsDeallocate (JavaScriptObject *obj)
+{
+ free (obj);
+}
+
+static NP_Class _javascriptClass = {
+ 1,
+ jsAllocate,
+ (NP_DeallocateInterface)jsDeallocate,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+static NP_Class *javascriptClass = &_javascriptClass;
+NP_Class *NP_JavaScriptObjectClass = javascriptClass;
+
+Identifier identiferFromNPIdentifier(NP_Identifier ident)
+{
+ NP_String *string = NP_CreateStringWithUTF8 (NP_UTF8FromIdentifier (ident));
+ NP_UTF16 methodName = NP_UTF16FromString (string);
+ int32_t length = NP_StringLength (string);
+ NP_ReleaseObject (string);
+ Identifier identifier ((const KJS::UChar*)methodName, length);
+ free (methodName);
+ return identifier;
+}
+
+NP_Object *NP_Call (NP_JavaScriptObject *o, NP_Identifier ident, NP_Object **args, unsigned argCount)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ // Lookup the function object.
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+
+ Value func = obj->imp->get (exec, identiferFromNPIdentifier(ident));
+ Interpreter::unlock();
+ if (func.isNull() || func.type() == UndefinedType) {
+ // Maybe throw an exception here?
+ return 0;
+ }
+
+ // Call the function object.
+ ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
+ Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
+ List argList = listFromNPArray(exec, args, argCount);
+ Interpreter::lock();
+ Value result = funcImp->call (exec, thisObj, argList);
+ Interpreter::unlock();
+
+ // Convert and return the result of the function call.
+ return convertValueToNPValueType(exec, result);
+}
+
+NP_Object *NP_Evaluate (NP_JavaScriptObject *o, NP_String *s)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
+ Interpreter::lock();
+ NP_UTF16 script = NP_UTF16FromString (s);
+ int32_t length = NP_StringLength (s);
+ KJS::Value result = obj->root->interpreter()->evaluate(UString((const UChar *)script,length)).value();
+ Interpreter::unlock();
+ free (script);
+ return convertValueToNPValueType(exec, result);
+}
+
+NP_Object *NP_GetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+ Value result = obj->imp->get (exec, identiferFromNPIdentifier(propertyName));
+ Interpreter::unlock();
+ return convertValueToNPValueType(exec, result);
+}
+
+void NP_SetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName, NP_Object *value)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+ obj->imp->put (exec, identiferFromNPIdentifier(propertyName), convertNPValueTypeToValue(exec, value));
+ Interpreter::unlock();
+}
+
+void NP_RemoveProperty (NP_JavaScriptObject *o, NP_Identifier propertyName)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+ obj->imp->deleteProperty (exec, identiferFromNPIdentifier(propertyName));
+ Interpreter::unlock();
+}
+
+NP_String *NP_ToString (NP_JavaScriptObject *o)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ Interpreter::lock();
+ Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
+ ExecState *exec = obj->root->interpreter()->globalExec();
+
+ NP_String *value = (NP_String *)coerceValueToNPValueType(exec, thisObj, NP_StringValueType);
+
+ Interpreter::unlock();
+
+ return value;
+}
+
+NP_Object *NP_GetPropertyAtIndex (NP_JavaScriptObject *o, int32_t index)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+ Value result = obj->imp->get (exec, (unsigned)index);
+ Interpreter::unlock();
+
+ return convertValueToNPValueType(exec, result);
+}
+
+void NP_SetPropertyAtIndex (NP_JavaScriptObject *o, unsigned index, NP_Object value)
+{
+ JavaScriptObject *obj = (JavaScriptObject *)o;
+
+ ExecState *exec = obj->root->interpreter()->globalExec();
+ Interpreter::lock();
+ obj->imp->put (exec, (unsigned)index, convertNPValueTypeToValue(exec, &value));
+ Interpreter::unlock();
+}
+
diff --git a/JavaScriptCore/bindings/npruntime.cpp b/JavaScriptCore/bindings/npruntime.cpp
index 5c3f9de..c59037c 100644
--- a/JavaScriptCore/bindings/npruntime.cpp
+++ b/JavaScriptCore/bindings/npruntime.cpp
@@ -167,46 +167,6 @@ void NP_SetException (NP_Object *obj, NP_String *message)
{
}
-// ---------------------------------- NP_JavaScriptObject ----------------------------------
-NP_Object *NP_Call (NP_JavaScriptObject *obj, NP_Identifier methodName, NP_Object **args, unsigned argCount)
-{
- return NULL;
-}
-
-NP_Object *NP_Evaluate (NP_JavaScriptObject *obj, NP_String *script)
-{
- return NULL;
-}
-
-NP_Object *NP_GetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName)
-{
- return NULL;
-}
-
-void NP_SetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName, NP_Object value)
-{
-}
-
-
-void NP_RemoveProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName)
-{
-}
-
-NP_UTF8 NP_ToString (NP_JavaScriptObject *obj)
-{
- return NULL;
-}
-
-NP_Object *NP_GetPropertyAtIndex (NP_JavaScriptObject *obj, unsigned int index)
-{
- return NULL;
-}
-
-void NP_SetPropertyAtIndex (NP_JavaScriptObject *obj, unsigned index, NP_Object value)
-{
-}
-
-
// ---------------------------------- Types ----------------------------------
// ---------------------------------- NP_Number ----------------------------------
@@ -634,6 +594,6 @@ NP_Object *NP_ObjectAtIndex (NP_Array *obj, int32_t index)
assert (index < array->count && array > 0);
- return array->objects[index];
+ return NP_RetainObject (array->objects[index]);
}
diff --git a/JavaScriptCore/bindings/npruntime.h b/JavaScriptCore/bindings/npruntime.h
index e2063b3..04be188 100644
--- a/JavaScriptCore/bindings/npruntime.h
+++ b/JavaScriptCore/bindings/npruntime.h
@@ -91,6 +91,10 @@ typedef int16_t *NP_UTF16;
*/
NP_Identifier NP_IdentifierFromUTF8 (NP_UTF8 name);
void NP_GetIdentifiers (NP_UTF8 *names, int nameCount, NP_Identifier *identifiers);
+
+/*
+ The returned NP_UTF8 should be freed.
+*/
NP_UTF8 NP_UTF8FromIdentifier (NP_Identifier identifier);
/*
@@ -173,7 +177,7 @@ extern NP_Class *NP_UndefinedClass;
extern NP_Class *NP_ArrayClass;
extern NP_Class *NP_NumberClass;
extern NP_Class *NP_StringClass;
-NP_Class *NP_JavaScriptObjectClass;
+extern NP_Class *NP_JavaScriptObjectClass;
typedef NP_Object NP_Boolean;
typedef NP_Object NP_Null;
@@ -188,11 +192,11 @@ typedef NP_Object NP_String;
NP_Object *NP_Call (NP_JavaScriptObject *obj, NP_Identifier methodName, NP_Object **args, unsigned argCount);
NP_Object *NP_Evaluate (NP_JavaScriptObject *obj, NP_String *script);
NP_Object *NP_GetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName);
-void NP_SetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName, NP_Object value);
+void NP_SetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName, NP_Object *value);
void NP_RemoveProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName);
-NP_UTF8 NP_ToString (NP_JavaScriptObject *obj);
+NP_String *NP_ToString (NP_JavaScriptObject *obj);
NP_Object *NP_GetPropertyAtIndex (NP_JavaScriptObject *obj, int32_t index);
-void NP_SetPropertyAtIndex (NP_JavaScriptObject *obj, unsigned index, NP_Object value);
+void NP_SetPropertyAtIndex (NP_JavaScriptObject *obj, unsigned index, NP_Object *value);
/*
Functions for dealing with data types.
@@ -240,10 +244,8 @@ NP_Array *NP_CreateArray (NP_Object **, int32_t count);
NP_Array *NP_CreateArrayV (int32_t count, ...);
/*
-
- Objects returned by NP_ObjectAtIndex do not have an implicit
- reference count. Callers must retain if they wish to keep
- a reference.
+ Objects returned by NP_ObjectAtIndex pass a reference count
+ to the caller. The caller must release the object.
*/
NP_Object *NP_ObjectAtIndex (NP_Array *array, int32_t index);
diff --git a/JavaScriptCore/bindings/runtime_object.h b/JavaScriptCore/bindings/runtime_object.h
index 503c247..9fdcd02 100644
--- a/JavaScriptCore/bindings/runtime_object.h
+++ b/JavaScriptCore/bindings/runtime_object.h
@@ -25,8 +25,6 @@
#ifndef _RUNTIME_OBJECT_H_
#define _RUNTIME_OBJECT_H_
-#include <JavaVM/jni.h>
-
#include <JavaScriptCore/runtime.h>
#include <JavaScriptCore/object.h>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list