[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:39:11 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit ac76ed1cd92b5db792e27c3385a0911264312810
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed May 12 21:30:50 2004 +0000
Changes to plugin scripting extensions.`
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/bindings/npruntime.cpp b/JavaScriptCore/bindings/npruntime.cpp
index 6d3d488..362c12f 100644
--- a/JavaScriptCore/bindings/npruntime.cpp
+++ b/JavaScriptCore/bindings/npruntime.cpp
@@ -134,12 +134,12 @@ void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *iden
}
}
-const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier)
+NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier)
{
if (identifier == 0 || (uint32_t)identifier >= identifierCount)
return NULL;
- return (const NPUTF8 *)identifierNames[(uint32_t)identifier];
+ return (NPUTF8 *)identifierNames[(uint32_t)identifier];
}
NPBool NPN_VariantIsVoid (const NPVariant *variant)
@@ -512,7 +512,8 @@ NPArray *NPN_CreateArrayV (int32_t count, ...)
return (NPArray *)array;
}
-NPObject *NPN_ObjectAtIndex (NPArray *obj, int32_t index)
+/*
+NPVariant *NPN_ObjectAtIndex (NPArray *obj, int32_t index)
{
ArrayObject *array = (ArrayObject *)obj;
@@ -520,4 +521,4 @@ NPObject *NPN_ObjectAtIndex (NPArray *obj, int32_t index)
return NPN_RetainObject (array->objects[index]);
}
-
+*/
diff --git a/JavaScriptCore/bindings/npruntime.h b/JavaScriptCore/bindings/npruntime.h
index 440df3a..8fa2beb 100644
--- a/JavaScriptCore/bindings/npruntime.h
+++ b/JavaScriptCore/bindings/npruntime.h
@@ -1,27 +1,6 @@
/*
* 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.
- *
* Revision 1 (March 4, 2004):
* Initial proposal.
*
@@ -215,7 +194,7 @@ void NPN_InitializeVariantWithVariant (NPVariant *destination, const NPVariant *
*/
-typedef void *NPIdentifier;
+typedef const void *NPIdentifier;
/*
NPObjects have methods and properties. Methods and properties are named with NPIdentifiers.
@@ -228,9 +207,10 @@ NPIdentifier NPN_GetIdentifier (const NPUTF8 *name);
void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *identifiers);
/*
- The NPUTF8 returned from NPN_UTF8FromIdentifier should NOT be freed.
+ The NPUTF8 returned from NPN_UTF8FromIdentifier should be freed.
*/
-const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
+NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
+void NPN_ReleaseUTF8 (NPUTF8 *string);
/*
NPObject behavior is implemented using the following set of callback functions.
@@ -242,19 +222,20 @@ const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
typedef NPObject *(*NPAllocateFunctionPtr)();
typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
-typedef bool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef void (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result);
-typedef bool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef void (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
-typedef void (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
+typedef NPBool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPBool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, unsigned argCount, NPVariant *result);
+typedef NPBool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPBool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef NPBool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
/*
- NPObjects returned by create, retain, invoke, and getProperty
- pass a reference count to the caller. That is, the callee adds a reference
- count which passes to the caller. It is the caller's responsibility
+ NPObjects returned by create have a reference count of one. It is the caller's responsibility
to release the returned object.
- NPInvokeFunctionPtr function may return 0 to indicate a void result.
+ NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.
+
+ NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't
+ exist.
NPInvalidateFunctionPtr is called by the scripting environment when the native code is
shutdown. Any attempt to message a NPScriptObject instance after the invalidate
@@ -347,11 +328,13 @@ void NPN_SetPropertyAtIndex (NPScriptObject *obj, unsigned index, const NPVarian
NPArray *NPN_CreateArray (NPVariant **, int32_t count);
NPArray *NPN_CreateArrayV (int32_t count, ...);
+#if 0
/*
Objects returned by NPN_ObjectAtIndex pass a reference count
to the caller. The caller must release the object.
*/
-NPObject *NPN_ObjectAtIndex (NPArray *array, int32_t index);
+const NPVariant *NPN_ObjectAtIndex (NPArray *array, int32_t index);
+#endif
/*
Returns true if the object is a kind of class as specified by
@@ -361,169 +344,14 @@ bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass);
/*
NPN_SetException may be called to trigger a script exception upon return
- from entry points into NPObjects. A reference count of the message passes
- to the callee. Typical usage:
-
- NPString *message = NPN_CreateStringWithUTF8("invalid type", -1);
- NPN_SetException (obj, mesage);
- NPN_ReleaseObject (message);
-
- NPN_SetExceptionWithUTF8() take an UTF8 string and a length. -1 may be passed for
+ from entry points into NPObjects.
+
+ NPN_SetExceptionWithUTF8() takes an UTF8 string and a length. -1 may be passed for
the length if the string is null terminated.
*/
void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length);
void NPN_SetException (NPObject *obj, NPString *message);
-/*
- Example usage:
-
- typedef NPObject MyObject;
-
- typedef struct
- {
- NPObject object;
- // Properties needed by MyObject are added here.
- int numChapters;
- ...
- } MyObject
-
- void stop(MyObject *obj)
- {
- ...
- }
-
- void start(MyObject *obj)
- {
- ...
- }
-
- void setChapter(MyObject *obj, int chapter)
- {
- ...
- }
-
- int getChapter(MyObject *obj)
- {
- ...
- }
-
- static NPIdentifier stopIdentifier;
- static NPIdentifier startIdentifier;
- static NPIdentifier setChapterIdentifier;
- static NPIdentifier getChapterIdentifier;
- static NPIdentifier numChaptersIdentifier;
-
- static void initializeIdentifiers()
- {
- stopIdentifier = NPIdentifierFromUTF8 ("stop");
- startIdentifier = NPIdentifierFromUTF8 ("start");
- setChapterIdentifier = NPIdentifierFromUTF8 ("setChapter");
- getChapterIdentifier = NPIdentifierFromUTF8 ("getChapter");
- numChaptersIdentifier = NPIdentifierFromUTF8 ("numChapters");
- }
-
- bool myProperty (MyObject *obj, NPIdentifier name)
- {
- if (name == numChaptersIdentifier){
- return true;
- }
- return false;
- }
-
- bool myHasMethod (MyObject *obj, NPIdentifier name)
- {
- if (name == stopIdentifier ||
- name == startIdentifier ||
- name == setChapterIdentifier ||
- name == getChapterIdentifier) {
- return true;
- }
- return false;
- }
-
- NPObject *myGetProperty (MyObject *obj, NPIdentifier name)
- {
- if (name == numChaptersIdentifier){
- return NPN_CreateNumberWithInt(obj->numChapters);
- }
- return 0;
- }
-
- void mySetProperty (MyObject *obj, NPIdentifier name, NPObject *value)
- {
- if (name == numChaptersIdentifier){
- obj->numChapters = NPN_IntFromNumber(obj)
- }
- }
-
- NPObject *myInvoke (MyObject *obj, NPIdentifier name, NPObject **args, unsigned argCount)
- {
-
- if (name == stopIdentifier){
- stop(obj);
- }
- else if (name == startIdentifier){
- start(obj);
- }
- else if (name == setChapterIdentifier){
- if (NPN_IsKindOfClass (args[0], NPNumberClass)) {
- setChapter (obj, NPN_IntFromNumber(args[0]));
- }
- else {
- NPN_SetException (obj, NPN_CreateStringWithUTF8 ("invalid type"));
- }
- }
- else if (name == getChapterIdentifier){
- return NPN_CreateNumberWithInt (getChapter (obj));
- }
- return 0;
- }
-
- NPObject *myAllocate ()
- {
- MyFunctionPtrObject *newInstance = (MyFunctionPtrObject *)malloc (sizeof(MyFunctionPtrObject));
-
- if (stopIdentifier == 0)
- initializeIdentifiers();
-
- return (NPObject *)newInstance;
- }
-
- void myInvalidate ()
- {
- // Make sure we've released any remaining references to script
- // objects.
- }
-
- void myDeallocate (MyObject *obj)
- {
- free ((void *)obj);
- }
-
- static NPClass _myFunctionPtrs = {
- (NPAllocateFunctionPtr) myAllocate,
- (NPDeallocateFunctionPtr) myDeallocate,
- (NPInvalidateFunctionPtr) myInvalidate,
- (NPHasMethodFunctionPtr) myHasMethod,
- (NPInvokeFunctionPtr) myInvoke,
- (NPHasPropertyFunctionPtr) myHasProperty,
- (NPGetPropertyFunctionPtr) myGetProperty,
- (NPSetPropertyFunctionPtr) mySetProperty,
- };
- static NPClass *myFunctionPtrs = &_myFunctionPtrs;
-
- // myGetNativeObjectForScript would be set as the entry point for
- // the plugin's NPP_GetNativeObjectForScript function.
- // It is invoked by the plugin container, i.e. the browser.
- NPObject *myGetNativeObjectForScript(NPP instance)
- {
- NPObject *myObject = NPN_CreateObject (myFunctionPtrs);
- return myObject;
- }
-
-*/
-
-
#ifdef __cplusplus
}
#endif
diff --git a/WebKit/Plugins.subproj/WebScriptObject.h b/WebKit/Plugins.subproj/WebScriptObject.h
new file mode 100644
index 0000000..75fa392
--- /dev/null
+++ b/WebKit/Plugins.subproj/WebScriptObject.h
@@ -0,0 +1,328 @@
+/*
+ Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+
+ Public header file.
+ */
+#ifndef _WEB_SCRIPT_OBJECT_H_
+#define _WEB_SCRIPT_OBJECT_H_
+
+
+// NSObject (WebScriptMethods) -----------------------------------------------------
+
+/*
+ The methods in WebScriptMethods are optionally implemented by classes whose
+ interfaces are exported (wrapped) to a scripting environment in the context of WebKit.
+ The scripting environment currently supported by WebKit uses the JavaScript
+ language.
+
+ Instances automatically reflect their interfaces in the scripting environment. This
+ automatic reflection can be overriden using the class methods defined in the WebScriptMethods
+ informal protocol.
+
+ Instances may also intercept property set/get operations and method invocations that are
+ made by the scripting environment, but not reflected.
+
+ Not all methods are exposed. Only those methods whose parameters and return
+ type meets the export criteria will exposed. Valid types are ObjectiveC instances
+ and scalars. Other types are not allowed.
+
+ Types will be converted to appropriate types in the scripting environment.
+ Scalars and NSNumber will be converted to numbers. NSString will be converted
+ to strings. NSNull will be converted to null. WebUndefined will be converted
+ to undefined. WebScriptObjects will be unwrapped. Instances of other classes
+ will be wrapped when passed to the script environment and unwrapped when
+ returned to ObjectiveC. Similar conversion happens in the other direction.
+
+ If an instance variable of an object is set directly from a script, and it is
+ an object, the previous value will be released and the new value will be retained.
+*/
+ at interface NSObject (WebScriptMethods)
+
+/*!
+ @method scriptNameForSelector:
+ @param aSelector The selector that will be exposed to the script environment.
+ @discussion Use the returned string as the exported name for the selector
+ in the script environment. It is the responsibility of the class to ensure
+ uniqueness of the returned name. If nil is returned or this
+ method is not implemented the default name for the selector will
+ be used. The default name concatenates the components of the
+ ObjectiveC selector name and replaces ':' with '_'. '_' characters
+ are escaped with an additional '$', i.e. '_' becomes "$_". '$' are
+ also escaped, i.e.
+ ObjectiveC name Default script name
+ moveTo:: move__
+ moveTo_ moveTo$_
+ moveTo$_ moveTo$$$_
+ @result Returns the name to be used to represent the specificed selector in the
+ scripting environment.
+*/
++ (NSString *)scriptNameForSelector:(SEL)aSelector;
+
+/*!
+ @method isSelectorExcludedFromScript:
+ @param aSelect The selector the will be exposed to the script environment.
+ @discussion Return NO to prevent the selector appearing in the script
+ environment. Return YES to expose the selector in the script environment.
+ If this method is not implemented on the class all the selector that match
+ the export criteria will be exposed.
+ @result Returns NO to hide the selector, YES to expose the selector.
+*/
++ (BOOL)isSelectorExcludedFromScript:(SEL)aSelector;
+
+/*!
+ @method scriptNameForProperty:
+ @param name The name of the instance variable that will be exposed to the
+ script enviroment. Only that properties that meet the export criteria will
+ be exposed.
+ @discussion Provide an alternate name for a property.
+ @result Returns the name to be used to represent the specificed property in the
+ scripting environment.
+*/
++ (NSString *)scriptNameForProperty:(const char *)name;
+
+/*!
+ @method isPropertyExcludedFromScript:
+ @param name The name of the instance variable that will be exposed to the
+ scrip environment.
+ @discussion Return NO to exclude the property from visibility in the script environement.
+ Return YES to expose the instance varible to the script environment.
+ @result Returns NO to hide the property, YES to expose the property.
+*/
++ (BOOL)isPropertyExcludedFromScript:(const char *)name;
+
+/*!
+ @method setObject:forScriptProperty:exceptionMessage:
+ @param value The vale to be set for the property name.
+ @param name The name of the property being set.
+ @param exceptionMessage Set to the a message that will be used to contruct a script exception.
+ @discussion If a script attempts to set a property that is not an exposed
+ instance variable, setObject:forScriptProperty: will be called. Setting the
+ *exceptionMessage to a non-nil value will cause an exception to be raised in the script
+ environment.
+*/
+- (void)setObject:(id)value forScriptProperty:(NSString *)name exceptionMessage:(NSString **)exceptionMessage;
+
+/*!
+ @method objectForScriptProperty:exceptionMessage:
+ @param name
+ @param exceptionMessage Set to the a message that will be used to contruct a script exception.
+ @discussion If a script attempts to get a property that is not an exposed
+ instance variable, objectForScriptProperty: will be be called.
+ @result The value of the property. Setting the *exceptionMessage to a non-nil value will
+ cause an exception to be raised in the script environment. The return value will be
+ ignored if an exception message is set.
+*/
+- (id)objectForScriptProperty:(NSString *)name exceptionMessage:(NSString **)exceptionMessage;
+
+/*!
+ @method scriptInvocation:withArgs:exceptionMessage:
+ @param name The name of the method to invoke.
+ @param args The args to pass the method.
+ @param exceptionMessage Set to the a message that will be used to contruct a script exception.
+ @discussion If a script attempt to invoke a method that is not an exposed
+ method, scriptInvocation:withArgs: will be called.
+ @result The return value of the invocation. The value will be converted as appropriate
+ for the script environment. Setting the *exceptionMessage to a non-nil value will
+ cause an exception to be raised in the script environment. The return value will be
+ ignored if an exception message is set.
+*/
+- (id)scriptInvocation:(NSString *)name withArgs:(NSArray *)args exceptionMessage:(NSString **)exceptionMessage;
+
+/*!
+ @method finalizeForScript
+ @discussion finalizeForScript is called on objects exposed to the script
+ environment just before the script environment is reset. After calls to
+ finalizeForScript the object will no longer be referenced by the script environment.
+ Further any references to WebScriptObjects made by the exposed object will
+ be invalid and have undefined consequences.
+*/
+- (void)finalizeForScript;
+
+ at end
+
+
+
+// WebView (WebScriptMethods) ---------------------------------------
+
+ at interface WebView (WebScriptMethods)
+
+/*!
+ @method windowScriptObject
+ @discussion windowScriptObject return a WebScriptObject that represents the
+ window object from the script environment.
+ @result Returns the window object from the script environment.
+*/
+- (WebScriptObject *)windowScriptObject;
+ at end
+
+
+
+// WebScriptObject --------------------------------------------------
+
+ at class WebScriptObjectPrivate;
+
+/*!
+ @class WebScriptObject
+ @discussion WebScriptObjects are used to wrap script objects passed from
+ script environments to ObjectiveC. WebScriptObjects cannot be created
+ directly. In normal uses of WebKit, you gain access to the script
+ environment using the "windowScriptObject" method on WebView.
+*/
+ at interface WebScriptObject : NSObject
+{
+ WebScriptObjectPrivate *_private;
+}
+
+/*!
+ @method callScriptMethod:withArguments:
+ @param name The name of the method to call in the script environment.
+ @param args The arguments to pass to the script environment.
+ @discussion Calls the specified method in the script environment using the
+ specified arguments.
+ @result Returns the result of calling the script method.
+*/
+- (id)callScriptMethod:(NSString *)name withArguments:(NSArray *)args;
+
+/*!
+ @method evaluateScript:
+ @param script The script to execute in the target script environment.
+ @discussion The script will be executed in the target script environment. The format
+ of the script is dependent of the target script environment.
+ @result Returns the result of evaluating the script in the script environment.
+*/
+- (id)evaluateScript:(NSString *)script;
+
+/*!
+ @method objectForScriptProperty:
+ @param name The name of the property to return.
+ @discussion Returns the property of the object from the script environment.
+ @result Returns the property of the object from the script environment.
+*/
+- (id)objectForScriptProperty:(NSString *)name;
+
+/*!
+ @method setObject:forScriptProperty:
+ @param name The name of the property to set.
+ @param value The value of the property.
+ @discussion Set the property of the object in the script environment.
+*/
+- (void)setObject:(id)value forScriptProperty:(NSString *)name;
+
+/*!
+ @method removeScriptProperty:
+ @param name The name of the property to remove.
+ @discussion Removes the property from the object in the script environment.
+*/
+- (void)removeScriptProperty:(NSString *)name;
+
+/*!
+ @method toString
+ @discussion Converts the target object to a string representation. The coercion
+ of non string objects type is dependent on the script environment.
+ @result Returns the string representation of the object.
+*/
+- (NSString *)toString;
+
+/*!
+ @method propertyAtIndex:
+ @param index The index of the property to return. Index based access is dependent
+ @discussion Gets the value of the property at the specified index.
+ @result The value of the property.
+*/
+- (id)scriptPropertyAtIndex:(unsigned int)index;
+
+/*!
+ @method setPropertyAtIndex:value:
+ @param index The index of the property to set.
+ @param value The value of the property to set.
+ @discussion Sets the property value at the specified index.
+*/
+- (void)setScriptPropertyAtIndex:(unsigned int)index value:(id)value;
+
+/*!
+ @method setException:
+ @param description The description of the exception.
+ @discussion Raises an exception in the script environment.
+*/
+- (void)setException: (NSString *)description;
+
+ at end
+
+
+
+// WebUndefined --------------------------------------------------------------
+
+/*!
+ @class WebUndefined
+*/
+ at interface WebUndefined : NSObject <NSCoding, NSCopying>
+
+/*!
+ @method undefined
+ @result The WebUndefined shared instance.
+*/
++ (WebUndefined *)undefined;
+
+ at end
+
+
+ at interface NSObject (WebFrameLoadDelegate) ...
+/*!
+ @method webView:windowScriptObjectAvailable:
+ @abstract Notifies the delegate that the scripting object for a page is available. This is called
+ before the page is loaded. It may be useful to allow delegates to bind native objects to the window.
+ @param webView The webView sending the message.
+ @param windowScriptObject The WebScriptObject for the window in the scripting environment.
+*/
+- (void)webView:(WebView *)webView windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject;
+ at end
+
+
+// NSObject (WebScriptablePlugin) --------------------------------------------
+
+ at interface NSObject (WebPlugin) ...
+/*!
+ @method objectForScript
+ @discussion objectForScript is used to expose a plugin's API. The methods of the
+ object are exposed to the script environment. See the WebScriptMethod informal
+ protocol for more details.
+ @result Returns the object that exposes the plugin's interface. The class of this
+ object can implement methods from the WebScriptMethods informal protocol.
+*/
+- (id)objectForScript;
+ at end
+
+
+
+// NSObject (WebPluginContainer) ---------------------------------------------
+
+ at interface NSObject (WebPluginContainer) ...
+/*!
+ @method webFrame
+ @discussion The webFrame method allows the plugin to access the WebFrame that
+ contains the plugin. This method is optionally implemented on classes
+ that implement the WebPluginContainer protocol.
+ @result Return the WebFrame that contains the plugin.
+*/
+- (WebFrame *)webFrame;
+ at end
+
+
+
+// DOMObject ------------------------------------------------------------------
+// All DOM objects may be manipulated using the formal DOM API, or indirectly via
+// their scripting interface. This requires a change in DOMObject's inheritance.
+
+/*!
+ @class DOMObject
+ @discussion All DOM objects may be manipulated using the formal DOM API, or indirectly via
+ their scripting interface. This requires a change in DOMObject's inheritance.
+ ...
+*/
+ at interface DOMObject : WebScriptObject <NSCopying>
+{
+ DOMObjectInternal *_internal;
+}
+...
+ at end
+
diff --git a/WebKit/Plugins.subproj/npapi.h b/WebKit/Plugins.subproj/npapi.h
index 1ee9dac..64af9c7 100644
--- a/WebKit/Plugins.subproj/npapi.h
+++ b/WebKit/Plugins.subproj/npapi.h
@@ -15,33 +15,33 @@
#endif
#ifdef _WINDOWS
-# ifndef XP_WIN
-# define XP_WIN 1
-# endif /* XP_WIN */
+# ifndef XP_WIN
+# define XP_WIN 1
+# endif /* XP_WIN */
#endif /* _WINDOWS */
#ifdef __MWERKS__
-# define _declspec __declspec
-# ifdef macintosh
-# ifndef XP_MAC
-# define XP_MAC 1
-# endif /* XP_MAC */
-# endif /* macintosh */
-# ifdef __INTEL__
-# undef NULL
-# ifndef XP_WIN
-# define XP_WIN 1
-# endif /* __INTEL__ */
-# endif /* XP_PC */
+# define _declspec __declspec
+# ifdef macintosh
+# ifndef XP_MAC
+# define XP_MAC 1
+# endif /* XP_MAC */
+# endif /* macintosh */
+# ifdef __INTEL__
+# undef NULL
+# ifndef XP_WIN
+# define XP_WIN 1
+# endif /* __INTEL__ */
+# endif /* XP_PC */
#endif /* __MWERKS__ */
-#ifdef __APPLE_CC__
+#if defined(__APPLE_CC__) && !defined(__MACOS_CLASSIC__)
# define XP_MACOSX
#endif
#ifdef XP_MAC
- #include <Quickdraw.h>
- #include <Events.h>
+ #include <Quickdraw.h>
+ #include <Events.h>
#endif
#ifdef XP_MACOSX
@@ -49,13 +49,13 @@
#endif
#ifdef XP_UNIX
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
#endif
/*----------------------------------------------------------------------*/
-/* Plugin Version Constants */
+/* Plugin Version Constants */
/*----------------------------------------------------------------------*/
#define NP_VERSION_MAJOR 0
@@ -64,7 +64,7 @@
/*----------------------------------------------------------------------*/
-/* Definition of Basic Types */
+/* Definition of Basic Types */
/*----------------------------------------------------------------------*/
#ifndef _UINT16
@@ -98,15 +98,15 @@ typedef long int32;
#define NULL (0L)
#endif
-typedef unsigned char NPBool;
-typedef int16 NPError;
-typedef int16 NPReason;
-typedef char* NPMIMEType;
+typedef unsigned char NPBool;
+typedef int16 NPError;
+typedef int16 NPReason;
+typedef char* NPMIMEType;
/*----------------------------------------------------------------------*/
-/* Structures and definitions */
+/* Structures and definitions */
/*----------------------------------------------------------------------*/
#ifdef XP_MAC
@@ -118,45 +118,45 @@ typedef char* NPMIMEType;
*/
typedef struct _NPP
{
- void* pdata; /* plug-in private data */
- void* ndata; /* netscape private data */
+ void* pdata; /* plug-in private data */
+ void* ndata; /* netscape private data */
} NPP_t;
-typedef NPP_t* NPP;
+typedef NPP_t* NPP;
typedef struct _NPStream
{
- void* pdata; /* plug-in private data */
- void* ndata; /* netscape private data */
- const char* url;
- uint32 end;
- uint32 lastmodified;
- void* notifyData;
+ void* pdata; /* plug-in private data */
+ void* ndata; /* netscape private data */
+ const char* url;
+ uint32 end;
+ uint32 lastmodified;
+ void* notifyData;
} NPStream;
typedef struct _NPByteRange
{
- int32 offset; /* negative offset means from the end */
- uint32 length;
+ int32 offset; /* negative offset means from the end */
+ uint32 length;
struct _NPByteRange* next;
} NPByteRange;
typedef struct _NPSavedData
{
- int32 len;
- void* buf;
+ int32 len;
+ void* buf;
} NPSavedData;
typedef struct _NPRect
{
- uint16 top;
- uint16 left;
- uint16 bottom;
- uint16 right;
+ uint16 top;
+ uint16 left;
+ uint16 bottom;
+ uint16 right;
} NPRect;
@@ -171,28 +171,28 @@ typedef struct _NPRect
* These are used to pass additional platform specific information.
*/
enum {
- NP_SETWINDOW = 1,
- NP_PRINT
+ NP_SETWINDOW = 1,
+ NP_PRINT
};
typedef struct
{
- int32 type;
+ int32 type;
} NPAnyCallbackStruct;
typedef struct
{
- int32 type;
- Display* display;
- Visual* visual;
- Colormap colormap;
- unsigned int depth;
+ int32 type;
+ Display* display;
+ Visual* visual;
+ Colormap colormap;
+ unsigned int depth;
} NPSetWindowCallbackStruct;
typedef struct
{
- int32 type;
- FILE* fp;
+ int32 type;
+ FILE* fp;
} NPPrintCallbackStruct;
#endif /* XP_UNIX */
@@ -201,22 +201,22 @@ typedef struct
* List of variable names for which NPP_GetValue shall be implemented
*/
typedef enum {
- NPPVpluginNameString = 1,
- NPPVpluginDescriptionString,
- NPPVpluginWindowBool,
- NPPVpluginTransparentBool
+ NPPVpluginNameString = 1,
+ NPPVpluginDescriptionString,
+ NPPVpluginWindowBool,
+ NPPVpluginTransparentBool
} NPPVariable;
/*
* List of variable names for which NPN_GetValue is implemented by Mozilla
*/
typedef enum {
- NPNVxDisplay = 1,
- NPNVxtAppContext,
+ NPNVxDisplay = 1,
+ NPNVxtAppContext,
NPNVnetscapeWindow,
- NPNVjavascriptEnabledBool,
- NPNVasdEnabledBool,
- NPNVisOfflineBool
+ NPNVjavascriptEnabledBool,
+ NPNVasdEnabledBool,
+ NPNVisOfflineBool
} NPNVariable;
/*
@@ -230,47 +230,47 @@ typedef enum {
typedef struct _NPWindow
{
- void* window; /* Platform specific window handle */
- int32 x; /* Position of top left corner relative */
- int32 y; /* to a netscape page. */
- uint32 width; /* Maximum window size */
- uint32 height;
- NPRect clipRect; /* Clipping rectangle in port coordinates */
- /* Used by MAC only. */
+ void* window; /* Platform specific window handle */
+ int32 x; /* Position of top left corner relative */
+ int32 y; /* to a netscape page. */
+ uint32 width; /* Maximum window size */
+ uint32 height;
+ NPRect clipRect; /* Clipping rectangle in port coordinates */
+ /* Used by MAC only. */
#ifdef XP_UNIX
- void * ws_info; /* Platform-dependent additonal data */
+ void * ws_info; /* Platform-dependent additonal data */
#endif /* XP_UNIX */
- NPWindowType type; /* Is this a window or a drawable? */
+ NPWindowType type; /* Is this a window or a drawable? */
} NPWindow;
typedef struct _NPFullPrint
{
- NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen */
- /* printing */
- NPBool printOne; /* TRUE if plugin should print one copy */
- /* to default printer */
- void* platformPrint; /* Platform-specific printing info */
+ NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen */
+ /* printing */
+ NPBool printOne; /* TRUE if plugin should print one copy */
+ /* to default printer */
+ void* platformPrint; /* Platform-specific printing info */
} NPFullPrint;
typedef struct _NPEmbedPrint
{
- NPWindow window;
- void* platformPrint; /* Platform-specific printing info */
+ NPWindow window;
+ void* platformPrint; /* Platform-specific printing info */
} NPEmbedPrint;
typedef struct _NPPrint
{
- uint16 mode; /* NP_FULL or NP_EMBED */
+ uint16 mode; /* NP_FULL or NP_EMBED */
union
{
- NPFullPrint fullPrint; /* if mode is NP_FULL */
- NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
+ NPFullPrint fullPrint; /* if mode is NP_FULL */
+ NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
} print;
} NPPrint;
#if defined(XP_MAC) || defined(XP_MACOSX)
-typedef EventRecord NPEvent;
+typedef EventRecord NPEvent;
#elif defined(XP_WIN)
typedef struct _NPEvent
{
@@ -281,7 +281,7 @@ typedef struct _NPEvent
#elif defined (XP_UNIX)
typedef XEvent NPEvent;
#else
-typedef void* NPEvent;
+typedef void* NPEvent;
#endif /* XP_MAC */
#if defined(XP_MAC) || defined(XP_MACOSX)
@@ -301,16 +301,16 @@ typedef void *NPRegion;
typedef struct NP_Port
{
- CGrafPtr port; /* Grafport */
- int32 portx; /* position inside the topmost window */
- int32 porty;
+ CGrafPtr port; /* Grafport */
+ int32 portx; /* position inside the topmost window */
+ int32 porty;
} NP_Port;
/*
* Non-standard event types that can be passed to HandleEvent
*/
-#define getFocusEvent (osEvt + 16)
-#define loseFocusEvent (osEvt + 17)
+#define getFocusEvent (osEvt + 16)
+#define loseFocusEvent (osEvt + 17)
#define adjustCursorEvent (osEvt + 18)
#endif /* XP_MAC */
@@ -319,18 +319,18 @@ typedef struct NP_Port
/*
* Values for mode passed to NPP_New:
*/
-#define NP_EMBED 1
-#define NP_FULL 2
+#define NP_EMBED 1
+#define NP_FULL 2
/*
* Values for stream type passed to NPP_NewStream:
*/
-#define NP_NORMAL 1
-#define NP_SEEK 2
-#define NP_ASFILE 3
-#define NP_ASFILEONLY 4
+#define NP_NORMAL 1
+#define NP_SEEK 2
+#define NP_ASFILE 3
+#define NP_ASFILEONLY 4
-#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
+#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
#ifdef XP_MAC
#pragma options align=reset
@@ -338,35 +338,35 @@ typedef struct NP_Port
/*----------------------------------------------------------------------*/
-/* Error and Reason Code definitions */
+/* Error and Reason Code definitions */
/*----------------------------------------------------------------------*/
/*
- * Values of type NPError:
+ * Values of type NPError:
*/
-#define NPERR_BASE 0
-#define NPERR_NO_ERROR (NPERR_BASE + 0)
-#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
-#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
-#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
-#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
-#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
-#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
-#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
-#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
-#define NPERR_INVALID_PARAM (NPERR_BASE + 9)
-#define NPERR_INVALID_URL (NPERR_BASE + 10)
-#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
-#define NPERR_NO_DATA (NPERR_BASE + 12)
-#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
+#define NPERR_BASE 0
+#define NPERR_NO_ERROR (NPERR_BASE + 0)
+#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
+#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
+#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
+#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
+#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
+#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
+#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
+#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
+#define NPERR_INVALID_PARAM (NPERR_BASE + 9)
+#define NPERR_INVALID_URL (NPERR_BASE + 10)
+#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
+#define NPERR_NO_DATA (NPERR_BASE + 12)
+#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
/*
- * Values of type NPReason:
+ * Values of type NPReason:
*/
-#define NPRES_BASE 0
-#define NPRES_DONE (NPRES_BASE + 0)
-#define NPRES_NETWORK_ERR (NPRES_BASE + 1)
-#define NPRES_USER_BREAK (NPRES_BASE + 2)
+#define NPRES_BASE 0
+#define NPRES_DONE (NPRES_BASE + 0)
+#define NPRES_NETWORK_ERR (NPRES_BASE + 1)
+#define NPRES_USER_BREAK (NPRES_BASE + 2)
/*
* Don't use these obsolete error codes any more.
@@ -378,16 +378,16 @@ typedef struct NP_Port
/*
* Version feature information
*/
-#define NPVERS_HAS_STREAMOUTPUT 8
-#define NPVERS_HAS_NOTIFICATION 9
-#define NPVERS_HAS_LIVECONNECT 9
-#define NPVERS_WIN16_HAS_LIVECONNECT 9
-#define NPVERS_68K_HAS_LIVECONNECT 11
+#define NPVERS_HAS_STREAMOUTPUT 8
+#define NPVERS_HAS_NOTIFICATION 9
+#define NPVERS_HAS_LIVECONNECT 9
+#define NPVERS_WIN16_HAS_LIVECONNECT 9
+#define NPVERS_68K_HAS_LIVECONNECT 11
#define NPVERS_HAS_WINDOWLESS 11
/*----------------------------------------------------------------------*/
-/* Function Prototypes */
+/* Function Prototypes */
/*----------------------------------------------------------------------*/
#if defined(_WINDOWS) && !defined(WIN32)
@@ -405,75 +405,75 @@ extern "C" {
*/
#ifdef XP_UNIX
-char* NPP_GetMIMEDescription(void);
+char* NPP_GetMIMEDescription(void);
#endif /* XP_UNIX */
-NPError NPP_Initialize(void);
-void NPP_Shutdown(void);
-NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
- uint16 mode, int16 argc, char* argn[],
- char* argv[], NPSavedData* saved);
-NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
-NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
-NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
- NPStream* stream, NPBool seekable,
- uint16* stype);
-NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
- NPReason reason);
-int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
-int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
- int32 len, void* buffer);
-void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
- const char* fname);
-void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
-int16 NPP_HandleEvent(NPP instance, void* event);
-void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
- NPReason reason, void* notifyData);
-jref NP_LOADDS NPP_GetJavaClass(void);
-NPError NPP_GetValue(void *instance, NPPVariable variable,
- void *value);
-NPError NPP_SetValue(void *instance, NPNVariable variable,
- void *value);
+NPError NPP_Initialize(void);
+void NPP_Shutdown(void);
+NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
+ uint16 mode, int16 argc, char* argn[],
+ char* argv[], NPSavedData* saved);
+NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
+NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
+NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
+ NPStream* stream, NPBool seekable,
+ uint16* stype);
+NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
+ NPReason reason);
+int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
+int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer);
+void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
+ const char* fname);
+void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
+int16 NPP_HandleEvent(NPP instance, void* event);
+void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
+ NPReason reason, void* notifyData);
+jref NP_LOADDS NPP_GetJavaClass(void);
+NPError NPP_GetValue(void *instance, NPPVariable variable,
+ void *value);
+NPError NPP_SetValue(void *instance, NPNVariable variable,
+ void *value);
/*
* NPN_* functions are provided by the navigator and called by the plugin.
*/
-void NPN_Version(int* plugin_major, int* plugin_minor,
- int* netscape_major, int* netscape_minor);
-NPError NPN_GetURLNotify(NPP instance, const char* url,
- const char* target, void* notifyData);
-NPError NPN_GetURL(NPP instance, const char* url,
- const char* target);
-NPError NPN_PostURLNotify(NPP instance, const char* url,
- const char* target, uint32 len,
- const char* buf, NPBool file,
- void* notifyData);
-NPError NPN_PostURL(NPP instance, const char* url,
- const char* target, uint32 len,
- const char* buf, NPBool file);
-NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
-NPError NPN_NewStream(NPP instance, NPMIMEType type,
- const char* target, NPStream** stream);
-int32 NPN_Write(NPP instance, NPStream* stream, int32 len,
- void* buffer);
+void NPN_Version(int* plugin_major, int* plugin_minor,
+ int* netscape_major, int* netscape_minor);
+NPError NPN_GetURLNotify(NPP instance, const char* url,
+ const char* target, void* notifyData);
+NPError NPN_GetURL(NPP instance, const char* url,
+ const char* target);
+NPError NPN_PostURLNotify(NPP instance, const char* url,
+ const char* target, uint32 len,
+ const char* buf, NPBool file,
+ void* notifyData);
+NPError NPN_PostURL(NPP instance, const char* url,
+ const char* target, uint32 len,
+ const char* buf, NPBool file);
+NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
+NPError NPN_NewStream(NPP instance, NPMIMEType type,
+ const char* target, NPStream** stream);
+int32 NPN_Write(NPP instance, NPStream* stream, int32 len,
+ void* buffer);
NPError NPN_DestroyStream(NPP instance, NPStream* stream,
- NPReason reason);
-void NPN_Status(NPP instance, const char* message);
-const char* NPN_UserAgent(NPP instance);
-void* NPN_MemAlloc(uint32 size);
-void NPN_MemFree(void* ptr);
-uint32 NPN_MemFlush(uint32 size);
+ NPReason reason);
+void NPN_Status(NPP instance, const char* message);
+const char* NPN_UserAgent(NPP instance);
+void* NPN_MemAlloc(uint32 size);
+void NPN_MemFree(void* ptr);
+uint32 NPN_MemFlush(uint32 size);
void NPN_ReloadPlugins(NPBool reloadPages);
JRIEnv* NPN_GetJavaEnv(void);
jref NPN_GetJavaPeer(NPP instance);
NPError NPN_GetValue(NPP instance, NPNVariable variable,
- void *value);
+ void *value);
NPError NPN_SetValue(NPP instance, NPPVariable variable,
- void *value);
-void NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
-void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
-void NPN_ForceRedraw(NPP instance);
+ void *value);
+void NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
+void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
+void NPN_ForceRedraw(NPP instance);
#ifdef __cplusplus
} /* end extern "C" */
diff --git a/WebKit/Plugins.subproj/npruntime.h b/WebKit/Plugins.subproj/npruntime.h
index 440df3a..8fa2beb 100644
--- a/WebKit/Plugins.subproj/npruntime.h
+++ b/WebKit/Plugins.subproj/npruntime.h
@@ -1,27 +1,6 @@
/*
* 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.
- *
* Revision 1 (March 4, 2004):
* Initial proposal.
*
@@ -215,7 +194,7 @@ void NPN_InitializeVariantWithVariant (NPVariant *destination, const NPVariant *
*/
-typedef void *NPIdentifier;
+typedef const void *NPIdentifier;
/*
NPObjects have methods and properties. Methods and properties are named with NPIdentifiers.
@@ -228,9 +207,10 @@ NPIdentifier NPN_GetIdentifier (const NPUTF8 *name);
void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *identifiers);
/*
- The NPUTF8 returned from NPN_UTF8FromIdentifier should NOT be freed.
+ The NPUTF8 returned from NPN_UTF8FromIdentifier should be freed.
*/
-const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
+NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
+void NPN_ReleaseUTF8 (NPUTF8 *string);
/*
NPObject behavior is implemented using the following set of callback functions.
@@ -242,19 +222,20 @@ const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
typedef NPObject *(*NPAllocateFunctionPtr)();
typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
-typedef bool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef void (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result);
-typedef bool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef void (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
-typedef void (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
+typedef NPBool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPBool (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *args, unsigned argCount, NPVariant *result);
+typedef NPBool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPBool (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef NPBool (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
/*
- NPObjects returned by create, retain, invoke, and getProperty
- pass a reference count to the caller. That is, the callee adds a reference
- count which passes to the caller. It is the caller's responsibility
+ NPObjects returned by create have a reference count of one. It is the caller's responsibility
to release the returned object.
- NPInvokeFunctionPtr function may return 0 to indicate a void result.
+ NPInvokeFunctionPtr function may return false to indicate a the method could not be invoked.
+
+ NPGetPropertyFunctionPtr and NPSetPropertyFunctionPtr may return false to indicate a property doesn't
+ exist.
NPInvalidateFunctionPtr is called by the scripting environment when the native code is
shutdown. Any attempt to message a NPScriptObject instance after the invalidate
@@ -347,11 +328,13 @@ void NPN_SetPropertyAtIndex (NPScriptObject *obj, unsigned index, const NPVarian
NPArray *NPN_CreateArray (NPVariant **, int32_t count);
NPArray *NPN_CreateArrayV (int32_t count, ...);
+#if 0
/*
Objects returned by NPN_ObjectAtIndex pass a reference count
to the caller. The caller must release the object.
*/
-NPObject *NPN_ObjectAtIndex (NPArray *array, int32_t index);
+const NPVariant *NPN_ObjectAtIndex (NPArray *array, int32_t index);
+#endif
/*
Returns true if the object is a kind of class as specified by
@@ -361,169 +344,14 @@ bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass);
/*
NPN_SetException may be called to trigger a script exception upon return
- from entry points into NPObjects. A reference count of the message passes
- to the callee. Typical usage:
-
- NPString *message = NPN_CreateStringWithUTF8("invalid type", -1);
- NPN_SetException (obj, mesage);
- NPN_ReleaseObject (message);
-
- NPN_SetExceptionWithUTF8() take an UTF8 string and a length. -1 may be passed for
+ from entry points into NPObjects.
+
+ NPN_SetExceptionWithUTF8() takes an UTF8 string and a length. -1 may be passed for
the length if the string is null terminated.
*/
void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length);
void NPN_SetException (NPObject *obj, NPString *message);
-/*
- Example usage:
-
- typedef NPObject MyObject;
-
- typedef struct
- {
- NPObject object;
- // Properties needed by MyObject are added here.
- int numChapters;
- ...
- } MyObject
-
- void stop(MyObject *obj)
- {
- ...
- }
-
- void start(MyObject *obj)
- {
- ...
- }
-
- void setChapter(MyObject *obj, int chapter)
- {
- ...
- }
-
- int getChapter(MyObject *obj)
- {
- ...
- }
-
- static NPIdentifier stopIdentifier;
- static NPIdentifier startIdentifier;
- static NPIdentifier setChapterIdentifier;
- static NPIdentifier getChapterIdentifier;
- static NPIdentifier numChaptersIdentifier;
-
- static void initializeIdentifiers()
- {
- stopIdentifier = NPIdentifierFromUTF8 ("stop");
- startIdentifier = NPIdentifierFromUTF8 ("start");
- setChapterIdentifier = NPIdentifierFromUTF8 ("setChapter");
- getChapterIdentifier = NPIdentifierFromUTF8 ("getChapter");
- numChaptersIdentifier = NPIdentifierFromUTF8 ("numChapters");
- }
-
- bool myProperty (MyObject *obj, NPIdentifier name)
- {
- if (name == numChaptersIdentifier){
- return true;
- }
- return false;
- }
-
- bool myHasMethod (MyObject *obj, NPIdentifier name)
- {
- if (name == stopIdentifier ||
- name == startIdentifier ||
- name == setChapterIdentifier ||
- name == getChapterIdentifier) {
- return true;
- }
- return false;
- }
-
- NPObject *myGetProperty (MyObject *obj, NPIdentifier name)
- {
- if (name == numChaptersIdentifier){
- return NPN_CreateNumberWithInt(obj->numChapters);
- }
- return 0;
- }
-
- void mySetProperty (MyObject *obj, NPIdentifier name, NPObject *value)
- {
- if (name == numChaptersIdentifier){
- obj->numChapters = NPN_IntFromNumber(obj)
- }
- }
-
- NPObject *myInvoke (MyObject *obj, NPIdentifier name, NPObject **args, unsigned argCount)
- {
-
- if (name == stopIdentifier){
- stop(obj);
- }
- else if (name == startIdentifier){
- start(obj);
- }
- else if (name == setChapterIdentifier){
- if (NPN_IsKindOfClass (args[0], NPNumberClass)) {
- setChapter (obj, NPN_IntFromNumber(args[0]));
- }
- else {
- NPN_SetException (obj, NPN_CreateStringWithUTF8 ("invalid type"));
- }
- }
- else if (name == getChapterIdentifier){
- return NPN_CreateNumberWithInt (getChapter (obj));
- }
- return 0;
- }
-
- NPObject *myAllocate ()
- {
- MyFunctionPtrObject *newInstance = (MyFunctionPtrObject *)malloc (sizeof(MyFunctionPtrObject));
-
- if (stopIdentifier == 0)
- initializeIdentifiers();
-
- return (NPObject *)newInstance;
- }
-
- void myInvalidate ()
- {
- // Make sure we've released any remaining references to script
- // objects.
- }
-
- void myDeallocate (MyObject *obj)
- {
- free ((void *)obj);
- }
-
- static NPClass _myFunctionPtrs = {
- (NPAllocateFunctionPtr) myAllocate,
- (NPDeallocateFunctionPtr) myDeallocate,
- (NPInvalidateFunctionPtr) myInvalidate,
- (NPHasMethodFunctionPtr) myHasMethod,
- (NPInvokeFunctionPtr) myInvoke,
- (NPHasPropertyFunctionPtr) myHasProperty,
- (NPGetPropertyFunctionPtr) myGetProperty,
- (NPSetPropertyFunctionPtr) mySetProperty,
- };
- static NPClass *myFunctionPtrs = &_myFunctionPtrs;
-
- // myGetNativeObjectForScript would be set as the entry point for
- // the plugin's NPP_GetNativeObjectForScript function.
- // It is invoked by the plugin container, i.e. the browser.
- NPObject *myGetNativeObjectForScript(NPP instance)
- {
- NPObject *myObject = NPN_CreateObject (myFunctionPtrs);
- return myObject;
- }
-
-*/
-
-
#ifdef __cplusplus
}
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list