[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:31:47 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit fa5e2b9f4c391a0c0edb4773136d46afdc2766a4
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Apr 1 00:43:52 2004 +0000
Tedious renames based on feedback from plugin-futures list.
NP_ functions are renamed with NPN_ prefix.
Types prefix renamed from NP_ to NP.
NPN_CreateStringWithUTF8 and NPN_SetExceptionWithUTF8 now take a length, optionally -1 if string is null terminated.
No review because this was just a renaming patch.
* bindings/NP_jsobject.cpp:
(listFromNPArray):
(jsAllocate):
(identiferFromNPIdentifier):
(NPN_Call):
(NPN_Evaluate):
(NPN_GetProperty):
(NPN_SetProperty):
(NPN_RemoveProperty):
(NPN_ToString):
(NPN_GetPropertyAtIndex):
(NPN_SetPropertyAtIndex):
* bindings/NP_jsobject.h:
* bindings/c/c_class.cpp:
(CClass::_commonInit):
(CClass::classForIsA):
(CClass::CClass):
(CClass::methodsNamed):
(CClass::fieldNamed):
* bindings/c/c_class.h:
* bindings/c/c_instance.cpp:
(CInstance::CInstance):
(CInstance::~CInstance):
(CInstance::operator=):
(CInstance::invokeMethod):
(CInstance::defaultValue):
* bindings/c/c_instance.h:
(KJS::Bindings::CInstance::getObject):
* bindings/c/c_runtime.cpp:
(CField::valueFromInstance):
(CField::setValueToInstance):
* bindings/c/c_runtime.h:
(KJS::Bindings::CField::CField):
(KJS::Bindings::CField::name):
(KJS::Bindings::CMethod::CMethod):
(KJS::Bindings::CMethod::name):
* bindings/c/c_utility.cpp:
(coerceValueToNPString):
(convertValueToNPValueType):
(convertNPValueTypeToValue):
* bindings/c/c_utility.h:
* bindings/npruntime.cpp:
(NPN_IdentifierFromUTF8):
(NPN_IsValidIdentifier):
(NPN_GetIdentifiers):
(NPN_UTF8FromIdentifier):
(NPN_CreateObject):
(NPN_RetainObject):
(NPN_ReleaseObject):
(NPN_IsKindOfClass):
(NPN_SetExceptionWithUTF8):
(NPN_SetException):
(numberAllocate):
(NPN_CreateNumberWithInt):
(NPN_CreateNumberWithFloat):
(NPN_CreateNumberWithDouble):
(NPN_IntFromNumber):
(NPN_FloatFromNumber):
(NPN_DoubleFromNumber):
(stringAllocate):
(NPN_CreateStringWithUTF8):
(NPN_CreateStringWithUTF16):
(NPN_DeallocateUTF8):
(NPN_UTF8FromString):
(NPN_UTF16FromString):
(NPN_StringLength):
(booleanAllocate):
(NPN_CreateBoolean):
(NPN_BoolFromBoolean):
(nullAllocate):
(NPN_GetNull):
(undefinedAllocate):
(NPN_GetUndefined):
(arrayAllocate):
(arrayDeallocate):
(NPN_CreateArray):
(NPN_CreateArrayV):
(NPN_ObjectAtIndex):
* bindings/npruntime.h:
* bindings/runtime.cpp:
(Instance::createBindingForLanguageInstance):
* bindings/testbindings.cpp:
(initializeIdentifiers):
(myHasProperty):
(myHasMethod):
(myGetProperty):
(mySetProperty):
(logMessage):
(setDoubleValue):
(setIntValue):
(setStringValue):
(setBooleanValue):
(getDoubleValue):
(getIntValue):
(getStringValue):
(getBooleanValue):
(myInvoke):
(myAllocate):
(myInvalidate):
(myDeallocate):
(main):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index e75a34c..7355a01 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,116 @@
2004-03-31 Richard Williamson <rjw at apple.com>
+ Tedious renames based on feedback from plugin-futures list.
+ NP_ functions are renamed with NPN_ prefix.
+ Types prefix renamed from NP_ to NP.
+ NPN_CreateStringWithUTF8 and NPN_SetExceptionWithUTF8 now take a length, optionally -1 if string is null terminated.
+
+ No review because this was just a renaming patch.
+
+ * bindings/NP_jsobject.cpp:
+ (listFromNPArray):
+ (jsAllocate):
+ (identiferFromNPIdentifier):
+ (NPN_Call):
+ (NPN_Evaluate):
+ (NPN_GetProperty):
+ (NPN_SetProperty):
+ (NPN_RemoveProperty):
+ (NPN_ToString):
+ (NPN_GetPropertyAtIndex):
+ (NPN_SetPropertyAtIndex):
+ * bindings/NP_jsobject.h:
+ * bindings/c/c_class.cpp:
+ (CClass::_commonInit):
+ (CClass::classForIsA):
+ (CClass::CClass):
+ (CClass::methodsNamed):
+ (CClass::fieldNamed):
+ * bindings/c/c_class.h:
+ * bindings/c/c_instance.cpp:
+ (CInstance::CInstance):
+ (CInstance::~CInstance):
+ (CInstance::operator=):
+ (CInstance::invokeMethod):
+ (CInstance::defaultValue):
+ * bindings/c/c_instance.h:
+ (KJS::Bindings::CInstance::getObject):
+ * bindings/c/c_runtime.cpp:
+ (CField::valueFromInstance):
+ (CField::setValueToInstance):
+ * bindings/c/c_runtime.h:
+ (KJS::Bindings::CField::CField):
+ (KJS::Bindings::CField::name):
+ (KJS::Bindings::CMethod::CMethod):
+ (KJS::Bindings::CMethod::name):
+ * bindings/c/c_utility.cpp:
+ (coerceValueToNPString):
+ (convertValueToNPValueType):
+ (convertNPValueTypeToValue):
+ * bindings/c/c_utility.h:
+ * bindings/npruntime.cpp:
+ (NPN_IdentifierFromUTF8):
+ (NPN_IsValidIdentifier):
+ (NPN_GetIdentifiers):
+ (NPN_UTF8FromIdentifier):
+ (NPN_CreateObject):
+ (NPN_RetainObject):
+ (NPN_ReleaseObject):
+ (NPN_IsKindOfClass):
+ (NPN_SetExceptionWithUTF8):
+ (NPN_SetException):
+ (numberAllocate):
+ (NPN_CreateNumberWithInt):
+ (NPN_CreateNumberWithFloat):
+ (NPN_CreateNumberWithDouble):
+ (NPN_IntFromNumber):
+ (NPN_FloatFromNumber):
+ (NPN_DoubleFromNumber):
+ (stringAllocate):
+ (NPN_CreateStringWithUTF8):
+ (NPN_CreateStringWithUTF16):
+ (NPN_DeallocateUTF8):
+ (NPN_UTF8FromString):
+ (NPN_UTF16FromString):
+ (NPN_StringLength):
+ (booleanAllocate):
+ (NPN_CreateBoolean):
+ (NPN_BoolFromBoolean):
+ (nullAllocate):
+ (NPN_GetNull):
+ (undefinedAllocate):
+ (NPN_GetUndefined):
+ (arrayAllocate):
+ (arrayDeallocate):
+ (NPN_CreateArray):
+ (NPN_CreateArrayV):
+ (NPN_ObjectAtIndex):
+ * bindings/npruntime.h:
+ * bindings/runtime.cpp:
+ (Instance::createBindingForLanguageInstance):
+ * bindings/testbindings.cpp:
+ (initializeIdentifiers):
+ (myHasProperty):
+ (myHasMethod):
+ (myGetProperty):
+ (mySetProperty):
+ (logMessage):
+ (setDoubleValue):
+ (setIntValue):
+ (setStringValue):
+ (setBooleanValue):
+ (getDoubleValue):
+ (getIntValue):
+ (getStringValue):
+ (getBooleanValue):
+ (myInvoke):
+ (myAllocate):
+ (myInvalidate):
+ (myDeallocate):
+ (main):
+
+2004-03-31 Richard Williamson <rjw at apple.com>
+
Changed references to NP_runtime.h to npruntime.h
* JavaScriptCore.pbproj/project.pbxproj:
diff --git a/JavaScriptCore/bindings/NP_jsobject.cpp b/JavaScriptCore/bindings/NP_jsobject.cpp
index c2192a7..1784820 100644
--- a/JavaScriptCore/bindings/NP_jsobject.cpp
+++ b/JavaScriptCore/bindings/NP_jsobject.cpp
@@ -27,15 +27,16 @@
using namespace KJS;
using namespace KJS::Bindings;
-static KJS::List listFromNPArray(KJS::ExecState *exec, NP_Object **args, unsigned argCount)
+
+static KJS::List listFromNPArray(KJS::ExecState *exec, NPObject **args, unsigned argCount)
{
KJS::List aList;
return aList;
}
-static NP_Object *jsAllocate()
+static NPObject *jsAllocate()
{
- return (NP_Object *)malloc(sizeof(JavaScriptObject));
+ return (NPObject *)malloc(sizeof(JavaScriptObject));
}
static void jsDeallocate (JavaScriptObject *obj)
@@ -43,10 +44,10 @@ static void jsDeallocate (JavaScriptObject *obj)
free (obj);
}
-static NP_Class _javascriptClass = {
+static NPClass _javascriptClass = {
1,
jsAllocate,
- (NP_DeallocateInterface)jsDeallocate,
+ (NPDeallocateFunctionPtr)jsDeallocate,
0,
0,
0,
@@ -55,21 +56,22 @@ static NP_Class _javascriptClass = {
0,
};
-static NP_Class *javascriptClass = &_javascriptClass;
-NP_Class *NP_JavaScriptObjectClass = javascriptClass;
+static NPClass *javascriptClass = &_javascriptClass;
+NPClass *NPScriptObjectClass = javascriptClass;
-Identifier identiferFromNPIdentifier(NP_Identifier ident)
+Identifier identiferFromNPIdentifier(NPIdentifier ident)
{
- NP_String *string = NP_CreateStringWithUTF8 (NP_UTF8FromIdentifier (ident));
- NP_UTF16 *methodName = NP_UTF16FromString (string);
- int32_t length = NP_StringLength (string);
- NP_ReleaseObject (string);
+ const NPUTF8 *name = NPN_UTF8FromIdentifier (ident);
+ NPString *string = NPN_CreateStringWithUTF8 (name, strlen(name));
+ NPUTF16 *methodName = NPN_UTF16FromString (string);
+ int32_t length = NPN_StringLength (string);
+ NPN_ReleaseObject (string);
Identifier identifier ((const KJS::UChar*)methodName, length);
free ((void *)methodName);
return identifier;
}
-void NP_Call (NP_JavaScriptObject *o, NP_Identifier ident, NP_Object **args, unsigned argCount, NP_JavaScriptResultInterface resultCallback, void *resultContext)
+void NPN_Call (NPScriptObject *o, NPIdentifier ident, NPObject **args, unsigned argCount, NPScriptResultFunctionPtr resultCallback, void *resultContext)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -80,11 +82,11 @@ void NP_Call (NP_JavaScriptObject *o, NP_Identifier ident, NP_Object **args, uns
Value func = obj->imp->get (exec, identiferFromNPIdentifier(ident));
Interpreter::unlock();
if (func.isNull()) {
- resultCallback (NP_GetNull(), resultContext);
+ resultCallback (NPN_GetNull(), resultContext);
return;
}
else if ( func.type() == UndefinedType) {
- resultCallback (NP_GetUndefined(), resultContext);
+ resultCallback (NPN_GetUndefined(), resultContext);
return;
}
@@ -97,30 +99,30 @@ void NP_Call (NP_JavaScriptObject *o, NP_Identifier ident, NP_Object **args, uns
Interpreter::unlock();
// Convert and return the result of the function call.
- NP_Object *npresult = convertValueToNPValueType(exec, result);
+ NPObject *npresult = convertValueToNPValueType(exec, result);
resultCallback (npresult, resultContext);
}
-void NP_Evaluate (NP_JavaScriptObject *o, NP_String *s, NP_JavaScriptResultInterface resultCallback, void *resultContext)
+void NPN_Evaluate (NPScriptObject *o, NPString *s, NPScriptResultFunctionPtr resultCallback, void *resultContext)
{
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);
+ NPUTF16 *script = NPN_UTF16FromString (s);
+ int32_t length = NPN_StringLength (s);
KJS::Value result = obj->root->interpreter()->evaluate(UString((const UChar *)script,length)).value();
Interpreter::unlock();
free ((void *)script);
- NP_Object *npresult = convertValueToNPValueType(exec, result);
+ NPObject *npresult = convertValueToNPValueType(exec, result);
resultCallback (npresult, resultContext);
}
-void NP_GetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName, NP_JavaScriptResultInterface resultCallback, void *resultContext)
+void NPN_GetProperty (NPScriptObject *o, NPIdentifier propertyName, NPScriptResultFunctionPtr resultCallback, void *resultContext)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -129,12 +131,12 @@ void NP_GetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName, NP_Java
Value result = obj->imp->get (exec, identiferFromNPIdentifier(propertyName));
Interpreter::unlock();
- NP_Object *npresult = convertValueToNPValueType(exec, result);
+ NPObject *npresult = convertValueToNPValueType(exec, result);
resultCallback (npresult, resultContext);
}
-void NP_SetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName, NP_Object *value)
+void NPN_SetProperty (NPScriptObject *o, NPIdentifier propertyName, NPObject *value)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -144,7 +146,7 @@ void NP_SetProperty (NP_JavaScriptObject *o, NP_Identifier propertyName, NP_Obje
Interpreter::unlock();
}
-void NP_RemoveProperty (NP_JavaScriptObject *o, NP_Identifier propertyName)
+void NPN_RemoveProperty (NPScriptObject *o, NPIdentifier propertyName)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -154,7 +156,7 @@ void NP_RemoveProperty (NP_JavaScriptObject *o, NP_Identifier propertyName)
Interpreter::unlock();
}
-void NP_ToString (NP_JavaScriptObject *o, NP_JavaScriptResultInterface resultCallback, void *resultContext)
+void NPN_ToString (NPScriptObject *o, NPScriptResultFunctionPtr resultCallback, void *resultContext)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -162,14 +164,14 @@ void NP_ToString (NP_JavaScriptObject *o, NP_JavaScriptResultInterface resultCal
Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
ExecState *exec = obj->root->interpreter()->globalExec();
- NP_String *value = (NP_String *)coerceValueToNPString(exec, thisObj);
+ NPString *value = (NPString *)coerceValueToNPString(exec, thisObj);
Interpreter::unlock();
resultCallback (value, resultContext);
}
-void NP_GetPropertyAtIndex (NP_JavaScriptObject *o, int32_t index, NP_JavaScriptResultInterface resultCallback, void *resultContext)
+void NPN_GetPropertyAtIndex (NPScriptObject *o, int32_t index, NPScriptResultFunctionPtr resultCallback, void *resultContext)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
@@ -178,12 +180,12 @@ void NP_GetPropertyAtIndex (NP_JavaScriptObject *o, int32_t index, NP_JavaScript
Value result = obj->imp->get (exec, (unsigned)index);
Interpreter::unlock();
- NP_Object *npresult = convertValueToNPValueType(exec, result);
+ NPObject *npresult = convertValueToNPValueType(exec, result);
resultCallback (npresult, resultContext);
}
-void NP_SetPropertyAtIndex (NP_JavaScriptObject *o, unsigned index, NP_Object value)
+void NPN_SetPropertyAtIndex (NPScriptObject *o, unsigned index, NPObject value)
{
JavaScriptObject *obj = (JavaScriptObject *)o;
diff --git a/JavaScriptCore/bindings/NP_jsobject.h b/JavaScriptCore/bindings/NP_jsobject.h
index b2351df..f5662de 100644
--- a/JavaScriptCore/bindings/NP_jsobject.h
+++ b/JavaScriptCore/bindings/NP_jsobject.h
@@ -32,7 +32,7 @@
typedef struct
{
- NP_Object object;
+ NPObject object;
KJS::ObjectImp *imp;
KJS::Bindings::RootObject *root;
} JavaScriptObject;
diff --git a/JavaScriptCore/bindings/c/c_class.cpp b/JavaScriptCore/bindings/c/c_class.cpp
index aba7d0f..9a33055 100644
--- a/JavaScriptCore/bindings/c/c_class.cpp
+++ b/JavaScriptCore/bindings/c/c_class.cpp
@@ -39,7 +39,7 @@ void CClass::_commonCopy(const CClass &other) {
}
-void CClass::_commonInit (NP_Class *aClass)
+void CClass::_commonInit (NPClass *aClass)
{
_isa = aClass;
_methods = CFDictionaryCreateMutable(NULL, 16, &kCFTypeDictionaryKeyCallBacks, NULL);
@@ -55,7 +55,7 @@ static void _createClassesByIsAIfNecessary()
classesByIsA = CFDictionaryCreateMutable (NULL, 0, NULL, NULL);
}
-CClass *CClass::classForIsA (NP_Class *isa)
+CClass *CClass::classForIsA (NPClass *isa)
{
_createClassesByIsAIfNecessary();
@@ -69,7 +69,7 @@ CClass *CClass::classForIsA (NP_Class *isa)
}
-CClass::CClass (NP_Class *isa)
+CClass::CClass (NPClass *isa)
{
_commonInit (isa);
}
@@ -91,8 +91,8 @@ MethodList CClass::methodsNamed(const char *_name) const
return methodList;
}
- if (NP_IsValidIdentifier (_name)) {
- NP_Identifier ident = NP_IdentifierFromUTF8 (_name);
+ if (NPN_IsValidIdentifier (_name)) {
+ NPIdentifier ident = NPN_IdentifierFromUTF8 (_name);
if (_isa->hasMethod && _isa->hasMethod (_isa, ident)){
Method *aMethod = new CMethod (ident);
CFDictionaryAddValue ((CFMutableDictionaryRef)_methods, methodName, aMethod);
@@ -115,8 +115,8 @@ Field *CClass::fieldNamed(const char *name) const
return aField;
}
- if (NP_IsValidIdentifier (name)) {
- NP_Identifier ident = NP_IdentifierFromUTF8 (name);
+ if (NPN_IsValidIdentifier (name)) {
+ NPIdentifier ident = NPN_IdentifierFromUTF8 (name);
if (_isa->hasProperty && _isa->hasProperty (_isa, ident)){
aField = new CField (ident);
CFDictionaryAddValue ((CFMutableDictionaryRef)_fields, fieldName, aField);
diff --git a/JavaScriptCore/bindings/c/c_class.h b/JavaScriptCore/bindings/c/c_class.h
index e4fb57c..5031d20 100644
--- a/JavaScriptCore/bindings/c/c_class.h
+++ b/JavaScriptCore/bindings/c/c_class.h
@@ -41,16 +41,16 @@ class CClass : public KJS::Bindings::Class
// Use the public static factory methods to get instances of JavaClass.
protected:
- void _commonInit (NP_Class *aClass);
+ void _commonInit (NPClass *aClass);
void _commonCopy(const CClass &other);
void _commonDelete();
public:
- CClass (NP_Class *aClass);
+ CClass (NPClass *aClass);
// Return the cached ObjC of the specified name.
//static CClass *classForName (const char *name);
- static CClass *classForIsA (NP_Class *aClass);
+ static CClass *classForIsA (NPClass *aClass);
~CClass () {
_commonDelete();
@@ -84,7 +84,7 @@ public:
virtual long numConstructors() const { return 0; };
private:
- NP_Class *_isa;
+ NPClass *_isa;
CFDictionaryRef _methods;
CFDictionaryRef _fields;
};
diff --git a/JavaScriptCore/bindings/c/c_instance.cpp b/JavaScriptCore/bindings/c/c_instance.cpp
index 1576b89..0fd61af 100644
--- a/JavaScriptCore/bindings/c/c_instance.cpp
+++ b/JavaScriptCore/bindings/c/c_instance.cpp
@@ -39,30 +39,30 @@
using namespace KJS::Bindings;
using namespace KJS;
-CInstance::CInstance (NP_Object *o)
+CInstance::CInstance (NPObject *o)
{
- _object = NP_RetainObject (o);
+ _object = NPN_RetainObject (o);
};
CInstance::~CInstance ()
{
- NP_ReleaseObject (_object);
+ NPN_ReleaseObject (_object);
delete _class;
}
CInstance::CInstance (const CInstance &other) : Instance()
{
- _object = NP_RetainObject (other._object);
+ _object = NPN_RetainObject (other._object);
};
CInstance &CInstance::operator=(const CInstance &other){
if (this == &other)
return *this;
- NP_Object *_oldObject = _object;
- _object= NP_RetainObject (other._object);
- NP_ReleaseObject (_oldObject);
+ NPObject *_oldObject = _object;
+ _object= NPN_RetainObject (other._object);
+ NPN_ReleaseObject (_oldObject);
return *this;
};
@@ -90,22 +90,22 @@ Value CInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodLis
{
Value resultValue;
- // Overloading methods are not allowed by NP_Objects. Should only be one
+ // Overloading methods are not allowed by NPObjects. Should only be one
// name match for a particular method.
assert (methodList.length() == 1);
CMethod *method = 0;
method = static_cast<CMethod*>(methodList.methodAt(0));
- NP_Identifier ident = NP_IdentifierFromUTF8 (method->name());
+ NPIdentifier ident = NPN_IdentifierFromUTF8 (method->name());
if (!_object->_class->hasMethod (_object->_class, ident))
return Undefined();
unsigned i, count = args.size();
- NP_Object **cArgs;
- NP_Object *localBuffer[128];
+ NPObject **cArgs;
+ NPObject *localBuffer[128];
if (count > 128)
- cArgs = (NP_Object **)malloc (sizeof(NP_Object *)*count);
+ cArgs = (NPObject **)malloc (sizeof(NPObject *)*count);
else
cArgs = localBuffer;
@@ -114,14 +114,14 @@ Value CInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodLis
}
// Invoke the 'C' method.
- NP_Object *result = _object->_class->invoke (_object, ident, cArgs, count);
+ NPObject *result = _object->_class->invoke (_object, ident, cArgs, count);
if (result) {
resultValue = convertNPValueTypeToValue (exec, result);
if (cArgs != localBuffer)
free ((void *)cArgs);
- NP_ReleaseObject (result);
+ NPN_ReleaseObject (result);
return resultValue;
}
@@ -142,19 +142,19 @@ KJS::Value CInstance::defaultValue (KJS::Type hint) const
return booleanValue();
}
else if (hint == KJS::UnspecifiedType) {
- if (NP_IsKindOfClass (_object, NP_StringClass)) {
+ if (NPN_IsKindOfClass (_object, NPStringClass)) {
return stringValue();
}
- else if (NP_IsKindOfClass (_object, NP_NumberClass)) {
+ else if (NPN_IsKindOfClass (_object, NPNumberClass)) {
return numberValue();
}
- else if (NP_IsKindOfClass (_object, NP_BooleanClass)) {
+ else if (NPN_IsKindOfClass (_object, NPBooleanClass)) {
return booleanValue();
}
- else if (NP_IsKindOfClass (_object, NP_NullClass)) {
+ else if (NPN_IsKindOfClass (_object, NPNullClass)) {
return Null();
}
- else if (NP_IsKindOfClass (_object, NP_UndefinedClass)) {
+ else if (NPN_IsKindOfClass (_object, NPUndefinedClass)) {
return Undefined();
}
}
diff --git a/JavaScriptCore/bindings/c/c_instance.h b/JavaScriptCore/bindings/c/c_instance.h
index 1dd7912..0111364 100644
--- a/JavaScriptCore/bindings/c/c_instance.h
+++ b/JavaScriptCore/bindings/c/c_instance.h
@@ -38,7 +38,7 @@ class CClass;
class CInstance : public Instance
{
public:
- CInstance (NP_Object *instance);
+ CInstance (NPObject *instance);
~CInstance ();
@@ -60,11 +60,11 @@ public:
KJS::Value numberValue() const;
KJS::Value booleanValue() const;
- NP_Object *getObject() const { return _object; }
+ NPObject *getObject() const { return _object; }
private:
mutable CClass *_class;
- NP_Object *_object;
+ NPObject *_object;
};
} // namespace Bindings
diff --git a/JavaScriptCore/bindings/c/c_runtime.cpp b/JavaScriptCore/bindings/c/c_runtime.cpp
index d98fa3a..f49724e 100644
--- a/JavaScriptCore/bindings/c/c_runtime.cpp
+++ b/JavaScriptCore/bindings/c/c_runtime.cpp
@@ -44,8 +44,8 @@ using namespace KJS::Bindings;
Value CField::valueFromInstance(KJS::ExecState *exec, const Instance *inst) const
{
const CInstance *instance = static_cast<const CInstance*>(inst);
- NP_Object *obj = instance->getObject();
- NP_Object *property = obj->_class->getProperty (obj, _fieldIdentifier);
+ NPObject *obj = instance->getObject();
+ NPObject *property = obj->_class->getProperty (obj, _fieldIdentifier);
Value aValue = convertNPValueTypeToValue (exec, property);
return aValue;
}
@@ -53,8 +53,8 @@ Value CField::valueFromInstance(KJS::ExecState *exec, const Instance *inst) cons
void CField::setValueToInstance(KJS::ExecState *exec, const Instance *inst, const KJS::Value &aValue) const
{
const CInstance *instance = static_cast<const CInstance*>(inst);
- NP_Object *obj = instance->getObject();
- NP_Object *value = convertValueToNPValueType (exec, aValue);
+ NPObject *obj = instance->getObject();
+ NPObject *value = convertValueToNPValueType (exec, aValue);
obj->_class->setProperty (obj, _fieldIdentifier, value);
}
diff --git a/JavaScriptCore/bindings/c/c_runtime.h b/JavaScriptCore/bindings/c/c_runtime.h
index 018dedb..6c0912e 100644
--- a/JavaScriptCore/bindings/c/c_runtime.h
+++ b/JavaScriptCore/bindings/c/c_runtime.h
@@ -42,18 +42,18 @@ namespace Bindings
class CField : public Field
{
public:
- CField(NP_Identifier ident) : Field() {
+ CField(NPIdentifier ident) : Field() {
_fieldIdentifier = ident;
};
virtual KJS::Value valueFromInstance(KJS::ExecState *exec, const Instance *instance) const;
virtual void setValueToInstance(KJS::ExecState *exec, const Instance *instance, const KJS::Value &aValue) const;
- virtual const char *name() const { return NP_UTF8FromIdentifier(_fieldIdentifier); }
+ virtual const char *name() const { return NPN_UTF8FromIdentifier(_fieldIdentifier); }
virtual RuntimeType type() const { return ""; }
private:
- NP_Identifier _fieldIdentifier;
+ NPIdentifier _fieldIdentifier;
};
@@ -62,14 +62,14 @@ class CMethod : public Method
public:
CMethod() : Method(), _methodIdentifier(0) {};
- CMethod(NP_Identifier ident) : Method(), _methodIdentifier(ident) {};
+ CMethod(NPIdentifier ident) : Method(), _methodIdentifier(ident) {};
- virtual const char *name() const { return NP_UTF8FromIdentifier(_methodIdentifier); };
+ virtual const char *name() const { return NPN_UTF8FromIdentifier(_methodIdentifier); };
virtual long numParameters() const { return 0; };
private:
- NP_Identifier _methodIdentifier;
+ NPIdentifier _methodIdentifier;
};
#if 0
diff --git a/JavaScriptCore/bindings/c/c_utility.cpp b/JavaScriptCore/bindings/c/c_utility.cpp
index 8c9166d..ccd9e5d 100644
--- a/JavaScriptCore/bindings/c/c_utility.cpp
+++ b/JavaScriptCore/bindings/c/c_utility.cpp
@@ -34,31 +34,33 @@
using namespace KJS;
using namespace KJS::Bindings;
-NP_Object *coerceValueToNPString (KJS::ExecState *exec, const KJS::Value &value)
+NPObject *coerceValueToNPString (KJS::ExecState *exec, const KJS::Value &value)
{
UString ustring = value.toString(exec);
- return NP_CreateStringWithUTF8 (ustring.UTF8String().c_str());
+ CString cstring = ustring.UTF8String();
+ return NPN_CreateStringWithUTF8 (cstring.c_str(), cstring.size());
}
-NP_Object *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value)
+NPObject *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value)
{
Type type = value.type();
if (type == StringType) {
UString ustring = value.toString(exec);
- return NP_CreateStringWithUTF8 (ustring.UTF8String().c_str());
+ CString cstring = ustring.UTF8String();
+ return NPN_CreateStringWithUTF8 (cstring.c_str(), cstring.size());
}
else if (type == NumberType) {
- return NP_CreateNumberWithDouble (value.toNumber(exec));
+ return NPN_CreateNumberWithDouble (value.toNumber(exec));
}
else if (type == BooleanType) {
- return NP_CreateBoolean (value.toBoolean(exec));
+ return NPN_CreateBoolean (value.toBoolean(exec));
}
else if (type == UnspecifiedType) {
- return NP_GetUndefined();
+ return NPN_GetUndefined();
}
else if (type == NullType) {
- return NP_GetNull();
+ return NPN_GetNull();
}
else if (type == ObjectType) {
KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
@@ -72,33 +74,33 @@ NP_Object *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &va
return 0;
}
-Value convertNPValueTypeToValue (KJS::ExecState *exec, const NP_Object *obj)
+Value convertNPValueTypeToValue (KJS::ExecState *exec, const NPObject *obj)
{
- if (NP_IsKindOfClass (obj, NP_BooleanClass)) {
- if (NP_BoolFromBoolean ((NP_Boolean *)obj))
+ if (NPN_IsKindOfClass (obj, NPBooleanClass)) {
+ if (NPN_BoolFromBoolean ((NPBoolean *)obj))
return KJS::Boolean (true);
return KJS::Boolean (false);
}
- else if (NP_IsKindOfClass (obj, NP_NullClass)) {
+ else if (NPN_IsKindOfClass (obj, NPNullClass)) {
return Null();
}
- else if (NP_IsKindOfClass (obj, NP_UndefinedClass)) {
+ else if (NPN_IsKindOfClass (obj, NPUndefinedClass)) {
return Undefined();
}
- else if (NP_IsKindOfClass (obj, NP_ArrayClass)) {
+ else if (NPN_IsKindOfClass (obj, NPArrayClass)) {
// FIXME: Need to implement
}
- else if (NP_IsKindOfClass (obj, NP_NumberClass)) {
- return Number (NP_DoubleFromNumber((NP_Number *)obj));
+ else if (NPN_IsKindOfClass (obj, NPNumberClass)) {
+ return Number (NPN_DoubleFromNumber((NPNumber *)obj));
}
- else if (NP_IsKindOfClass (obj, NP_StringClass)) {
+ else if (NPN_IsKindOfClass (obj, NPStringClass)) {
- NP_UTF8 *utf8String = NP_UTF8FromString((NP_String *)obj);
+ NPUTF8 *utf8String = NPN_UTF8FromString((NPString *)obj);
CFStringRef stringRef = CFStringCreateWithCString (NULL, utf8String, kCFStringEncodingUTF8);
- NP_DeallocateUTF8 (utf8String);
+ NPN_DeallocateUTF8 (utf8String);
int length = CFStringGetLength (stringRef);
- NP_UTF16 *buffer = (NP_UTF16 *)malloc(sizeof(NP_UTF16)*length);
+ NPUTF16 *buffer = (NPUTF16 *)malloc(sizeof(NPUTF16)*length);
// Convert the string to UTF16.
CFRange range = { 0, length };
@@ -110,13 +112,13 @@ Value convertNPValueTypeToValue (KJS::ExecState *exec, const NP_Object *obj)
return resultString;
}
- else if (NP_IsKindOfClass (obj, NP_JavaScriptObjectClass)) {
+ else if (NPN_IsKindOfClass (obj, NPScriptObjectClass)) {
// Get ObjectImp from NP_JavaScriptObject.
JavaScriptObject *o = (JavaScriptObject *)obj;
return Object(const_cast<ObjectImp*>(o->imp));
}
else {
- // Wrap NP_Object in a CInstance.
+ // Wrap NPObject in a CInstance.
return Instance::createRuntimeObject(Instance::CLanguage, (void *)obj);
}
diff --git a/JavaScriptCore/bindings/c/c_utility.h b/JavaScriptCore/bindings/c/c_utility.h
index 3d0597e..5f704ef 100644
--- a/JavaScriptCore/bindings/c/c_utility.h
+++ b/JavaScriptCore/bindings/c/c_utility.h
@@ -31,6 +31,10 @@
#include <runtime_object.h>
#include <runtime_root.h>
+typedef uint16_t NPUTF16;
+NPUTF16 *NPN_UTF16FromString (NPString *obj);
+NPUTF16 *NPN_UTF16FromString (NPString *obj);
+
typedef enum
{
NP_NumberValueType,
@@ -43,8 +47,8 @@ typedef enum
} NP_ValueType;
-extern NP_Object *coerceValueToNPString (KJS::ExecState *exec, const KJS::Value &value);
-extern NP_Object *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value);
-extern KJS::Value convertNPValueTypeToValue (KJS::ExecState *exec, const NP_Object *obj);
+extern NPObject *coerceValueToNPString (KJS::ExecState *exec, const KJS::Value &value);
+extern NPObject *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value);
+extern KJS::Value convertNPValueTypeToValue (KJS::ExecState *exec, const NPObject *obj);
#endif
diff --git a/JavaScriptCore/bindings/npruntime.cpp b/JavaScriptCore/bindings/npruntime.cpp
index f338903..8159a62 100644
--- a/JavaScriptCore/bindings/npruntime.cpp
+++ b/JavaScriptCore/bindings/npruntime.cpp
@@ -25,7 +25,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <npruntime.h>
-
+#include <c_utility.h>
static Boolean identifierEqual(const void *value1, const void *value2)
{
@@ -74,16 +74,16 @@ static CFMutableDictionaryRef getIdentifierDictionary()
static const char **identifierNames = 0;
static unsigned int maxIdentifierNames;
-static NP_Identifier identifierCount = 1;
+static NPIdentifier identifierCount = 1;
-NP_Identifier NP_IdentifierFromUTF8 (const NP_UTF8 *name)
+NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name)
{
assert (name);
if (name) {
- NP_Identifier identifier = 0;
+ NPIdentifier identifier = 0;
- identifier = (NP_Identifier)CFDictionaryGetValue (getIdentifierDictionary(), (const void *)name);
+ identifier = (NPIdentifier)CFDictionaryGetValue (getIdentifierDictionary(), (const void *)name);
if (identifier == 0) {
identifier = identifierCount++;
// We never release identifier names, so this dictionary will grow, as will
@@ -110,7 +110,7 @@ NP_Identifier NP_IdentifierFromUTF8 (const NP_UTF8 *name)
return 0;
}
-bool NP_IsValidIdentifier (const NP_UTF8 *name)
+bool NPN_IsValidIdentifier (const NPUTF8 *name)
{
assert (name);
@@ -120,7 +120,7 @@ bool NP_IsValidIdentifier (const NP_UTF8 *name)
return false;
}
-void NP_GetIdentifiers (const NP_UTF8 **names, int nameCount, NP_Identifier *identifiers)
+void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *identifiers)
{
assert (names);
assert (identifiers);
@@ -129,30 +129,30 @@ void NP_GetIdentifiers (const NP_UTF8 **names, int nameCount, NP_Identifier *ide
int i;
for (i = 0; i < nameCount; i++) {
- identifiers[i] = NP_IdentifierFromUTF8 (names[i]);
+ identifiers[i] = NPN_IdentifierFromUTF8 (names[i]);
}
}
}
-const NP_UTF8 *NP_UTF8FromIdentifier (NP_Identifier identifier)
+const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier)
{
if (identifier == 0 || identifier >= identifierCount)
return NULL;
- return (const NP_UTF8 *)identifierNames[identifier];
+ return (const NPUTF8 *)identifierNames[identifier];
}
-NP_Object *NP_CreateObject (NP_Class *aClass)
+NPObject *NPN_CreateObject (NPClass *aClass)
{
assert (aClass);
if (aClass) {
- NP_Object *obj;
+ NPObject *obj;
if (aClass->allocate != NULL)
obj = aClass->allocate ();
else
- obj = (NP_Object *)malloc (sizeof(NP_Object));
+ obj = (NPObject *)malloc (sizeof(NPObject));
obj->_class = aClass;
obj->referenceCount = 1;
@@ -164,7 +164,7 @@ NP_Object *NP_CreateObject (NP_Class *aClass)
}
-NP_Object *NP_RetainObject (NP_Object *obj)
+NPObject *NPN_RetainObject (NPObject *obj)
{
assert (obj);
@@ -175,7 +175,7 @@ NP_Object *NP_RetainObject (NP_Object *obj)
}
-void NP_ReleaseObject (NP_Object *obj)
+void NPN_ReleaseObject (NPObject *obj)
{
assert (obj);
assert (obj->referenceCount >= 1);
@@ -192,7 +192,7 @@ void NP_ReleaseObject (NP_Object *obj)
}
}
-bool NP_IsKindOfClass (const NP_Object *obj, const NP_Class *aClass)
+bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass)
{
assert (obj);
assert (aClass);
@@ -206,43 +206,43 @@ bool NP_IsKindOfClass (const NP_Object *obj, const NP_Class *aClass)
}
-void NP_SetExceptionWithUTF8 (NP_Object *obj, const NP_UTF8 *message)
+void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length)
{
assert (obj);
assert (message);
if (obj && message) {
- NP_String *m = NP_CreateStringWithUTF8(message);
- NP_SetException (obj, m);
- NP_ReleaseObject (m);
+ NPString *m = NPN_CreateStringWithUTF8(message, length);
+ NPN_SetException (obj, m);
+ NPN_ReleaseObject (m);
}
}
-void NP_SetException (NP_Object *obj, NP_String *message)
+void NPN_SetException (NPObject *obj, NPString *message)
{
// FIX ME. Need to implement.
}
// ---------------------------------- Types ----------------------------------
-// ---------------------------------- NP_Number ----------------------------------
+// ---------------------------------- NPNumber ----------------------------------
typedef struct
{
- NP_Object object;
+ NPObject object;
double number;
} NumberObject;
-static NP_Object *numberAllocate()
+static NPObject *numberAllocate()
{
- return (NP_Object *)malloc(sizeof(NumberObject));
+ return (NPObject *)malloc(sizeof(NumberObject));
}
-static NP_Class _numberClass = {
+static NPClass _numberClass = {
1,
numberAllocate,
- (NP_DeallocateInterface)free,
+ (NPDeallocateFunctionPtr)free,
0,
0,
0,
@@ -251,35 +251,35 @@ static NP_Class _numberClass = {
0,
};
-static NP_Class *numberClass = &_numberClass;
-NP_Class *NP_NumberClass = numberClass;
+static NPClass *numberClass = &_numberClass;
+NPClass *NPNumberClass = numberClass;
-NP_Number *NP_CreateNumberWithInt (int i)
+NPNumber *NPN_CreateNumberWithInt (int i)
{
- NumberObject *number = (NumberObject *)NP_CreateObject (numberClass);
+ NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
number->number = i;
- return (NP_Number *)number;
+ return (NPNumber *)number;
}
-NP_Number *NP_CreateNumberWithFloat (float f)
+NPNumber *NPN_CreateNumberWithFloat (float f)
{
- NumberObject *number = (NumberObject *)NP_CreateObject (numberClass);
+ NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
number->number = f;
- return (NP_Number *)number;
+ return (NPNumber *)number;
}
-NP_Number *NP_CreateNumberWithDouble (double d)
+NPNumber *NPN_CreateNumberWithDouble (double d)
{
- NumberObject *number = (NumberObject *)NP_CreateObject (numberClass);
+ NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
number->number = d;
- return (NP_Number *)number;
+ return (NPNumber *)number;
}
-int NP_IntFromNumber (NP_Number *obj)
+int NPN_IntFromNumber (NPNumber *obj)
{
- assert (obj && NP_IsKindOfClass (obj, numberClass));
+ assert (obj && NPN_IsKindOfClass (obj, numberClass));
- if (obj && NP_IsKindOfClass (obj, numberClass)) {
+ if (obj && NPN_IsKindOfClass (obj, numberClass)) {
NumberObject *number = (NumberObject *)obj;
return (int)number->number;
}
@@ -287,11 +287,11 @@ int NP_IntFromNumber (NP_Number *obj)
return 0;
}
-float NP_FloatFromNumber (NP_Number *obj)
+float NPN_FloatFromNumber (NPNumber *obj)
{
- assert (obj && NP_IsKindOfClass (obj, numberClass));
+ assert (obj && NPN_IsKindOfClass (obj, numberClass));
- if (obj && NP_IsKindOfClass (obj, numberClass)) {
+ if (obj && NPN_IsKindOfClass (obj, numberClass)) {
NumberObject *number = (NumberObject *)obj;
return (float)number->number;
}
@@ -299,11 +299,11 @@ float NP_FloatFromNumber (NP_Number *obj)
return 0.;
}
-double NP_DoubleFromNumber (NP_Number *obj)
+double NPN_DoubleFromNumber (NPNumber *obj)
{
- assert (obj && NP_IsKindOfClass (obj, numberClass));
+ assert (obj && NPN_IsKindOfClass (obj, numberClass));
- if (obj && NP_IsKindOfClass (obj, numberClass)) {
+ if (obj && NPN_IsKindOfClass (obj, numberClass)) {
NumberObject *number = (NumberObject *)obj;
return number->number;
}
@@ -312,18 +312,18 @@ double NP_DoubleFromNumber (NP_Number *obj)
}
-// ---------------------------------- NP_String ----------------------------------
+// ---------------------------------- NPString ----------------------------------
typedef struct
{
- NP_Object object;
- NP_UTF16 *string;
+ NPObject object;
+ NPUTF16 *string;
int32_t length;
} StringObject;
-static NP_Object *stringAllocate()
+static NPObject *stringAllocate()
{
- return (NP_Object *)malloc(sizeof(StringObject));
+ return (NPObject *)malloc(sizeof(StringObject));
}
void stringDeallocate (StringObject *string)
@@ -332,10 +332,10 @@ void stringDeallocate (StringObject *string)
free (string);
}
-static NP_Class _stringClass = {
+static NPClass _stringClass = {
1,
stringAllocate,
- (NP_DeallocateInterface)stringDeallocate,
+ (NPDeallocateFunctionPtr)stringDeallocate,
0,
0,
0,
@@ -344,62 +344,65 @@ static NP_Class _stringClass = {
0,
};
-static NP_Class *stringClass = &_stringClass;
-NP_Class *NP_StringClass = stringClass;
+static NPClass *stringClass = &_stringClass;
+NPClass *NPStringClass = stringClass;
#define LOCAL_CONVERSION_BUFFER_SIZE 4096
-NP_String *NP_CreateStringWithUTF8 (const NP_UTF8 *utf8String)
+NPString *NPN_CreateStringWithUTF8 (const NPUTF8 *utf8String, int32_t length)
{
assert (utf8String);
if (utf8String) {
- StringObject *string = (StringObject *)NP_CreateObject (stringClass);
+ if (length == -1)
+ length = strlen(utf8String);
+
+ StringObject *string = (StringObject *)NPN_CreateObject (stringClass);
- CFStringRef stringRef = CFStringCreateWithCString (NULL, utf8String, kCFStringEncodingUTF8);
+ CFStringRef stringRef = CFStringCreateWithBytes (NULL, (const UInt8*)utf8String, (CFIndex)length, kCFStringEncodingUTF8, false);
string->length = CFStringGetLength (stringRef);
- string->string = (NP_UTF16 *)malloc(sizeof(NP_UTF16)*string->length);
+ string->string = (NPUTF16 *)malloc(sizeof(NPUTF16)*string->length);
// Convert the string to UTF16.
CFRange range = { 0, string->length };
CFStringGetCharacters (stringRef, range, (UniChar *)string->string);
CFRelease (stringRef);
- return (NP_String *)string;
+ return (NPString *)string;
}
return 0;
}
-NP_String *NP_CreateStringWithUTF16 (const NP_UTF16 *utf16String, int32_t len)
+NPString *NPN_CreateStringWithUTF16 (const NPUTF16 *utf16String, int32_t len)
{
assert (utf16String);
if (utf16String) {
- StringObject *string = (StringObject *)NP_CreateObject (stringClass);
+ StringObject *string = (StringObject *)NPN_CreateObject (stringClass);
string->length = len;
- string->string = (NP_UTF16 *)malloc(sizeof(NP_UTF16)*string->length);
- memcpy ((void *)string->string, utf16String, sizeof(NP_UTF16)*string->length);
+ string->string = (NPUTF16 *)malloc(sizeof(NPUTF16)*string->length);
+ memcpy ((void *)string->string, utf16String, sizeof(NPUTF16)*string->length);
- return (NP_String *)string;
+ return (NPString *)string;
}
return 0;
}
-void NP_DeallocateUTF8 (NP_UTF8 *UTF8Buffer)
+void NPN_DeallocateUTF8 (NPUTF8 *UTF8Buffer)
{
free (UTF8Buffer);
}
-NP_UTF8 *NP_UTF8FromString (NP_String *obj)
+NPUTF8 *NPN_UTF8FromString (NPString *obj)
{
- assert (obj && NP_IsKindOfClass (obj, stringClass));
+ assert (obj && NPN_IsKindOfClass (obj, stringClass));
- if (obj && NP_IsKindOfClass (obj, stringClass)) {
+ if (obj && NPN_IsKindOfClass (obj, stringClass)) {
StringObject *string = (StringObject *)obj;
// Allow for max conversion factor.
@@ -422,7 +425,7 @@ NP_UTF8 *NP_UTF8FromString (NP_String *obj)
CFRange range = { 0, string->length };
CFStringGetBytes (stringRef, range, kCFStringEncodingUTF8, 0, false, buffer, maxBufferLength, &usedBufferLength);
- NP_UTF8 *resultString = (NP_UTF8 *)malloc (usedBufferLength+1);
+ NPUTF8 *resultString = (NPUTF8 *)malloc (usedBufferLength+1);
strncpy ((char *)resultString, (const char *)buffer, usedBufferLength);
char *cp = (char *)resultString;
cp[usedBufferLength] = 0;
@@ -437,14 +440,14 @@ NP_UTF8 *NP_UTF8FromString (NP_String *obj)
return 0;
}
-NP_UTF16 *NP_UTF16FromString (NP_String *obj)
+NPUTF16 *NPN_UTF16FromString (NPString *obj)
{
- assert (obj && NP_IsKindOfClass (obj, stringClass));
+ assert (obj && NPN_IsKindOfClass (obj, stringClass));
- if (obj && NP_IsKindOfClass (obj, stringClass)) {
+ if (obj && NPN_IsKindOfClass (obj, stringClass)) {
StringObject *string = (StringObject *)obj;
- NP_UTF16 *resultString = (NP_UTF16*)malloc(sizeof(int16_t)*string->length);
+ NPUTF16 *resultString = (NPUTF16*)malloc(sizeof(int16_t)*string->length);
memcpy ((void *)resultString, string->string, sizeof(int16_t)*string->length);
return resultString;
@@ -453,11 +456,11 @@ NP_UTF16 *NP_UTF16FromString (NP_String *obj)
return 0;
}
-int32_t NP_StringLength (NP_String *obj)
+int32_t NPN_StringLength (NPString *obj)
{
- assert (obj && NP_IsKindOfClass (obj, stringClass));
+ assert (obj && NPN_IsKindOfClass (obj, stringClass));
- if (obj && NP_IsKindOfClass (obj, stringClass)) {
+ if (obj && NPN_IsKindOfClass (obj, stringClass)) {
StringObject *string = (StringObject *)obj;
return string->length;
}
@@ -469,12 +472,12 @@ int32_t NP_StringLength (NP_String *obj)
typedef struct
{
- NP_Object object;
+ NPObject object;
} BooleanObject;
-static NP_Object *booleanAllocate()
+static NPObject *booleanAllocate()
{
- return (NP_Object *)malloc(sizeof(BooleanObject));
+ return (NPObject *)malloc(sizeof(BooleanObject));
}
static void booleanDeallocate (BooleanObject *string)
@@ -482,10 +485,10 @@ static void booleanDeallocate (BooleanObject *string)
// Do nothing, single true and false instances.
}
-static NP_Class _booleanClass = {
+static NPClass _booleanClass = {
1,
booleanAllocate,
- (NP_DeallocateInterface)booleanDeallocate,
+ (NPDeallocateFunctionPtr)booleanDeallocate,
0,
0,
0,
@@ -497,31 +500,31 @@ static NP_Class _booleanClass = {
static BooleanObject *theTrueObject = 0;
static BooleanObject *theFalseObject = 0;
-static NP_Class *booleanClass = &_booleanClass;
-NP_Class *NP_BooleanClass = booleanClass;
+static NPClass *booleanClass = &_booleanClass;
+NPClass *NPBooleanClass = booleanClass;
-NP_Boolean *NP_CreateBoolean (bool f)
+NPBoolean *NPN_CreateBoolean (bool f)
{
if (f) {
if (!theTrueObject) {
- theTrueObject = (BooleanObject *)NP_CreateObject (booleanClass);
+ theTrueObject = (BooleanObject *)NPN_CreateObject (booleanClass);
}
- return (NP_Boolean *)theTrueObject;
+ return (NPBoolean *)theTrueObject;
}
// False
if (!theFalseObject) {
- theFalseObject = (BooleanObject *)NP_CreateObject (booleanClass);
+ theFalseObject = (BooleanObject *)NPN_CreateObject (booleanClass);
}
- return (NP_Boolean *)theFalseObject;
+ return (NPBoolean *)theFalseObject;
}
-bool NP_BoolFromBoolean (NP_Boolean *obj)
+bool NPN_BoolFromBoolean (NPBoolean *obj)
{
- assert (obj && NP_IsKindOfClass (obj, booleanClass)
+ assert (obj && NPN_IsKindOfClass (obj, booleanClass)
&& ((BooleanObject *)obj == theTrueObject || (BooleanObject *)obj == theFalseObject));
- if (obj && NP_IsKindOfClass (obj, booleanClass)
+ if (obj && NPN_IsKindOfClass (obj, booleanClass)
&& ((BooleanObject *)obj == theTrueObject || (BooleanObject *)obj == theFalseObject)) {
BooleanObject *booleanObj = (BooleanObject *)obj;
if (booleanObj == theTrueObject)
@@ -535,12 +538,12 @@ bool NP_BoolFromBoolean (NP_Boolean *obj)
typedef struct
{
- NP_Object object;
+ NPObject object;
} NullObject;
-static NP_Object *nullAllocate()
+static NPObject *nullAllocate()
{
- return (NP_Object *)malloc(sizeof(NullObject));
+ return (NPObject *)malloc(sizeof(NullObject));
}
static void nullDeallocate (StringObject *string)
@@ -551,10 +554,10 @@ static void nullDeallocate (StringObject *string)
static NullObject *theNullObject = 0;
-static NP_Class _nullClass = {
+static NPClass _nullClass = {
1,
nullAllocate,
- (NP_DeallocateInterface)nullDeallocate,
+ (NPDeallocateFunctionPtr)nullDeallocate,
0,
0,
0,
@@ -563,14 +566,14 @@ static NP_Class _nullClass = {
0,
};
-static NP_Class *nullClass = &_nullClass;
-NP_Class *NP_NullClass = nullClass;
+static NPClass *nullClass = &_nullClass;
+NPClass *NPNullClass = nullClass;
-NP_Null *NP_GetNull()
+NPNull *NPN_GetNull()
{
if (!theNullObject)
- theNullObject = (NullObject *)NP_CreateObject(nullClass);
- return (NP_Null *)theNullObject;
+ theNullObject = (NullObject *)NPN_CreateObject(nullClass);
+ return (NPNull *)theNullObject;
}
@@ -578,12 +581,12 @@ NP_Null *NP_GetNull()
typedef struct
{
- NP_Object object;
+ NPObject object;
} UndefinedObject;
-static NP_Object *undefinedAllocate()
+static NPObject *undefinedAllocate()
{
- return (NP_Object *)malloc(sizeof(UndefinedObject));
+ return (NPObject *)malloc(sizeof(UndefinedObject));
}
static void undefinedDeallocate (StringObject *string)
@@ -594,10 +597,10 @@ static void undefinedDeallocate (StringObject *string)
static NullObject *theUndefinedObject = 0;
-static NP_Class _undefinedClass = {
+static NPClass _undefinedClass = {
1,
undefinedAllocate,
- (NP_DeallocateInterface)undefinedDeallocate,
+ (NPDeallocateFunctionPtr)undefinedDeallocate,
0,
0,
0,
@@ -606,28 +609,28 @@ static NP_Class _undefinedClass = {
0,
};
-static NP_Class *undefinedClass = &_undefinedClass;
-NP_Class *NP_UndefinedClass = undefinedClass;
+static NPClass *undefinedClass = &_undefinedClass;
+NPClass *NPUndefinedClass = undefinedClass;
-NP_Undefined *NP_GetUndefined()
+NPUndefined *NPN_GetUndefined()
{
if (!theUndefinedObject)
- theUndefinedObject = (NullObject *)NP_CreateObject(undefinedClass);
- return (NP_Undefined *)theUndefinedObject;
+ theUndefinedObject = (NullObject *)NPN_CreateObject(undefinedClass);
+ return (NPUndefined *)theUndefinedObject;
}
// ---------------------------------- NP_Array ----------------------------------
typedef struct
{
- NP_Object object;
- NP_Object **objects;
+ NPObject object;
+ NPObject **objects;
int32_t count;
} ArrayObject;
-static NP_Object *arrayAllocate()
+static NPObject *arrayAllocate()
{
- return (NP_Object *)malloc(sizeof(ArrayObject));
+ return (NPObject *)malloc(sizeof(ArrayObject));
}
static void arrayDeallocate (ArrayObject *array)
@@ -635,17 +638,17 @@ static void arrayDeallocate (ArrayObject *array)
int32_t i;
for (i = 0; i < array->count; i++) {
- NP_ReleaseObject(array->objects[i]);
+ NPN_ReleaseObject(array->objects[i]);
}
free (array->objects);
free (array);
}
-static NP_Class _arrayClass = {
+static NPClass _arrayClass = {
1,
arrayAllocate,
- (NP_DeallocateInterface)arrayDeallocate,
+ (NPDeallocateFunctionPtr)arrayDeallocate,
0,
0,
0,
@@ -654,52 +657,52 @@ static NP_Class _arrayClass = {
0,
};
-static NP_Class *arrayClass = &_arrayClass;
-NP_Class *NP_ArrayClass = arrayClass;
+static NPClass *arrayClass = &_arrayClass;
+NPClass *NPArrayClass = arrayClass;
-NP_Array *NP_CreateArray (NP_Object **objects, int32_t count)
+NPArray *NPN_CreateArray (NPObject **objects, int32_t count)
{
int32_t i;
assert (count >= 0);
- ArrayObject *array = (ArrayObject *)NP_CreateObject(arrayClass);
- array->objects = (NP_Object **)malloc (sizeof(NP_Object *)*count);
+ ArrayObject *array = (ArrayObject *)NPN_CreateObject(arrayClass);
+ array->objects = (NPObject **)malloc (sizeof(NPObject *)*count);
for (i = 0; i < count; i++) {
- array->objects[i] = NP_RetainObject (objects[i]);
+ array->objects[i] = NPN_RetainObject (objects[i]);
}
- return (NP_Array *)array;
+ return (NPArray *)array;
}
-NP_Array *NP_CreateArrayV (int32_t count, ...)
+NPArray *NPN_CreateArrayV (int32_t count, ...)
{
va_list args;
assert (count >= 0);
- ArrayObject *array = (ArrayObject *)NP_CreateObject(arrayClass);
- array->objects = (NP_Object **)malloc (sizeof(NP_Object *)*count);
+ ArrayObject *array = (ArrayObject *)NPN_CreateObject(arrayClass);
+ array->objects = (NPObject **)malloc (sizeof(NPObject *)*count);
va_start (args, count);
int32_t i;
for (i = 0; i < count; i++) {
- NP_Object *obj = va_arg (args, NP_Object *);
- array->objects[i] = NP_RetainObject (obj);
+ NPObject *obj = va_arg (args, NPObject *);
+ array->objects[i] = NPN_RetainObject (obj);
}
va_end (args);
- return (NP_Array *)array;
+ return (NPArray *)array;
}
-NP_Object *NP_ObjectAtIndex (NP_Array *obj, int32_t index)
+NPObject *NPN_ObjectAtIndex (NPArray *obj, int32_t index)
{
ArrayObject *array = (ArrayObject *)obj;
assert (index < array->count && array > 0);
- return NP_RetainObject (array->objects[index]);
+ return NPN_RetainObject (array->objects[index]);
}
diff --git a/JavaScriptCore/bindings/npruntime.h b/JavaScriptCore/bindings/npruntime.h
index abf0103..58f1816 100644
--- a/JavaScriptCore/bindings/npruntime.h
+++ b/JavaScriptCore/bindings/npruntime.h
@@ -27,19 +27,25 @@
*
* Revision 2 (March 10, 2004):
* All calls into JavaScript were made asynchronous. Results are
- * provided via the NP_JavaScriptResultInterface callback.
+ * provided via the NP_JavaScriptResultFunctionPtr callback.
*
* Revision 3 (March 10, 2004):
- * Corrected comments to not refer to class retain/release interfaces.
+ * Corrected comments to not refer to class retain/release FunctionPtrs.
*
* Revision 4 (March 11, 2004):
- * Added additional convenience NP_SetExceptionWithUTF8().
- * Changed NP_HasPropertyInterface and NP_HasMethodInterface to take NP_Class
- * pointers instead of NP_Object pointers.
+ * Added additional convenience NPN_SetExceptionWithUTF8().
+ * Changed NP_HasPropertyFunctionPtr and NP_HasMethodFunctionPtr to take NPClass
+ * pointers instead of NPObject pointers.
* Added NP_IsValidIdentifier().
*
* Revision 5 (March 17, 2004):
* Added context parameter to result callbacks from JavaScriptObject functions.
+ *
+ * Revision 6 (March 29, 2004):
+ * Renamed functions implemented by user agent to NPN_*. Removed _ from
+ * type names.
+ * Renamed "JavaScript" types to "Script".
+ *
*/
#ifndef _NP_RUNTIME_H_
#define _NP_RUNTIME_H_
@@ -57,306 +63,309 @@ extern "C" {
The following NP-SAP entry points were added to the Netscape plugin API:
- typedef NP_Object *(*NPP_GetNativeObjectForJavaScript) (NPP instance);
- typedef NP_JavaScriptObject *(*NPN_GetWindowJavaScriptObject) (NPP instance);
- typedef NP_JavaScriptObject *(*NPN_GetInstanceJavaScriptObject) (NPP instance);
+ typedef NPObject *(*NPP_GetNativeObjectForJavaScript) (NPP instance);
+ typedef NPScriptObject *(*NPN_GetWindowJavaScriptObject) (NPP instance);
+ typedef NPScriptObject *(*NPN_GetInstanceJavaScriptObject) (NPP instance);
- See NP_SAP.h for more details regarding the above Interfaces.
+ See NP_SAP.h for more details regarding the above FunctionPtrs.
*/
/*
- Data passed between 'C' and JavaScript is always wrapped in an NP_Object.
- The interface on an NP_Object is described by an NP_Class.
+ Data passed between 'C' and JavaScript is always wrapped in an NPObject.
+ The FunctionPtr on an NPObject is described by an NPClass.
*/
-typedef struct NP_Object NP_Object;
-typedef struct NP_Class NP_Class;
+typedef struct NPObject NPObject;
+typedef struct NPClass NPClass;
/*
- A NP_JavaScriptObject wraps a JavaScript Object in an NP_Object.
+ A NPScriptObject wraps a JavaScript Object in an NPObject.
*/
-typedef NP_Object NP_JavaScriptObject;
+typedef NPObject NPScriptObject;
/*
Type mappings:
JavaScript to C
- Boolean NP_Boolean
- Number NP_Number
- String NP_String
- Undefined NP_Undefined
- Null NP_Null
- Object (including Array) NP_JavaScriptObject
- Object wrapper NP_Object
+ Boolean NPBoolean
+ Number NPNumber
+ String NPString
+ Undefined NPUndefined
+ Null NPNull
+ Object (including Array) NPScriptObject
+ Object wrapper NPObject
C to JavaScript
- NP_Boolean Boolean
- NP_Number Number
- NP_String String
- NP_Undefined Undefined
- NP_Null Null
- NP_Array Array (restricted)
- NP_JavaScriptObject Object
- other NP_Object Object wrapper
+ NPBoolean Boolean
+ NPNumber Number
+ NPString String
+ NPUndefined Undefined
+ NPNull Null
+ NPArray Array (restricted)
+ NPScriptObject Object
+ other NPObject Object wrapper
*/
-typedef uint32_t NP_Identifier;
+typedef uint32_t NPIdentifier;
/*
- NP_UTF8 strings are null terminated.
+ NPUTF8 strings are null terminated.
*/
-typedef char NP_UTF8;
-
-typedef uint16_t NP_UTF16;
+typedef char NPUTF8;
/*
- NP_Objects have methods and properties. Methods and properties are named with NP_Identifiers.
- These identifiers may be reflected in JavaScript. NP_Identifiers can be compared using ==.
+ NPObjects have methods and properties. Methods and properties are named with NPIdentifiers.
+ These identifiers may be reflected in JavaScript. NPIdentifiers can be compared using ==.
NP_IsValidIdentifier will return true if an identifier for the name has already been
- assigned with either NP_IdentifierFromUTF8() or NP_GetIdentifiers();
+ assigned with either NPIdentifierFromUTF8() or NP_GetIdentifiers();
*/
-NP_Identifier NP_IdentifierFromUTF8 (const NP_UTF8 *name);
-bool NP_IsValidIdentifier (const NP_UTF8 *name);
-void NP_GetIdentifiers (const NP_UTF8 **names, int nameCount, NP_Identifier *identifiers);
+NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name);
+bool NPN_IsValidIdentifier (const NPUTF8 *name);
+void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *identifiers);
/*
- The returned NP_UTF8 should NOT be freed.
+ The returned NPUTF8 should NOT be freed.
*/
-const NP_UTF8 *NP_UTF8FromIdentifier (NP_Identifier identifier);
+const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
/*
- NP_Object behavior is implemented using the following set of callback interfaces.
+ NPObject behavior is implemented using the following set of callback FunctionPtrs.
*/
-typedef NP_Object *(*NP_AllocateInterface)();
-typedef void (*NP_DeallocateInterface)(NP_Object *obj);
-typedef void (*NP_InvalidateInterface)();
-typedef bool (*NP_HasMethodInterface)(NP_Class *theClass, NP_Identifier name);
-typedef NP_Object *(*NP_InvokeInterface)(NP_Object *obj, NP_Identifier name, NP_Object **args, unsigned argCount);
-typedef bool (*NP_HasPropertyInterface)(NP_Class *theClass, NP_Identifier name);
-typedef NP_Object *(*NP_GetPropertyInterface)(NP_Object *obj, NP_Identifier name);
-typedef void (*NP_SetPropertyInterface)(NP_Object *obj, NP_Identifier name, NP_Object *value);
+typedef NPObject *(*NPAllocateFunctionPtr)();
+typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
+typedef void (*NPInvalidateFunctionPtr)();
+typedef bool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPObject *(*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, NPObject **args, unsigned argCount);
+typedef bool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
+typedef NPObject *(*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);
+typedef void (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPObject *value);
/*
- NP_Objects returned by create, retain, invoke, and getProperty
+ 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
to release the returned object.
- NP_InvokeInterface Interfaces may return 0 to indicate a void result.
+ NPInvokeFunctionPtr FunctionPtrs may return 0 to indicate a void result.
- NP_InvalidateInterface is called by the plugin container when the plugin is
- shutdown. Any attempt to message a NP_JavaScriptObject instance after the invalidate
- interface has been called will result in undefined behavior, even if the
- plugin is still retaining those NP_JavaScriptObject instances.
+ NPInvalidateFunctionPtr is called by the plugin container when the plugin is
+ shutdown. Any attempt to message a NPScriptObject instance after the invalidate
+ FunctionPtr has been called will result in undefined behavior, even if the
+ plugin is still retaining those NPScriptObject instances.
(The runtime will typically return immediately, with 0 or NULL, from an attempt to
- dispatch to a NP_JavaScriptObject, but this behavior should not be depended upon.)
+ dispatch to a NPScriptObject, but this behavior should not be depended upon.)
*/
-struct NP_Class
+struct NPClass
{
- int32_t structVersion;
- NP_AllocateInterface allocate;
- NP_DeallocateInterface deallocate;
- NP_InvalidateInterface invalidate;
- NP_HasMethodInterface hasMethod;
- NP_InvokeInterface invoke;
- NP_HasPropertyInterface hasProperty;
- NP_GetPropertyInterface getProperty;
- NP_SetPropertyInterface setProperty;
+ uint32_t structVersion;
+ NPAllocateFunctionPtr allocate;
+ NPDeallocateFunctionPtr deallocate;
+ NPInvalidateFunctionPtr invalidate;
+ NPHasMethodFunctionPtr hasMethod;
+ NPInvokeFunctionPtr invoke;
+ NPHasPropertyFunctionPtr hasProperty;
+ NPGetPropertyFunctionPtr getProperty;
+ NPSetPropertyFunctionPtr setProperty;
};
-typedef struct NP_Class NP_Class;
+typedef struct NPClass NPClass;
-#define kNP_ClassStructVersion1 1
-#define kNP_ClassStructVersionCurrent kNP_ClassStructVersion1
+#define kNPClassStructVersion1 1
+#define kNPClassStructVersionCurrent kNPClassStructVersion1
-struct NP_Object {
- NP_Class *_class;
+struct NPObject {
+ NPClass *_class;
uint32_t referenceCount;
- // Additional space may be allocated here by types of NP_Objects
+ // Additional space may be allocated here by types of NPObjects
};
/*
- If the class has an allocate interface this function invokes that interface,
- otherwise a NP_Object is allocated and returned. If a class has an allocate
- interface it is the responsibility of that interface to set the initial retain
+ If the class has an allocate FunctionPtr this function invokes that FunctionPtr,
+ otherwise a NPObject is allocated and returned. If a class has an allocate
+ FunctionPtr it is the responsibility of that FunctionPtr to set the initial retain
count to 1.
*/
-NP_Object *NP_CreateObject (NP_Class *aClass);
+NPObject *NPN_CreateObject (NPClass *aClass);
/*
- Increment the NP_Object's reference count.
+ Increment the NPObject's reference count.
*/
-NP_Object *NP_RetainObject (NP_Object *obj);
+NPObject *NPN_RetainObject (NPObject *obj);
/*
- Decremented the NP_Object's reference count. If the reference
- count goes to zero, the class's destroy interface is invoke if
+ Decremented the NPObject's reference count. If the reference
+ count goes to zero, the class's destroy FunctionPtr is invoke if
specified, otherwise the object is free()ed directly.
*/
-void NP_ReleaseObject (NP_Object *obj);
+void NPN_ReleaseObject (NPObject *obj);
/*
- Built-in data types. These classes can be passed to NP_IsKindOfClass().
+ Built-in data types. These classes can be passed to NPN_IsKindOfClass().
*/
-extern NP_Class *NP_BooleanClass;
-extern NP_Class *NP_NullClass;
-extern NP_Class *NP_UndefinedClass;
-extern NP_Class *NP_ArrayClass;
-extern NP_Class *NP_NumberClass;
-extern NP_Class *NP_StringClass;
-extern NP_Class *NP_JavaScriptObjectClass;
-
-typedef NP_Object NP_Boolean;
-typedef NP_Object NP_Null;
-typedef NP_Object NP_Undefined;
-typedef NP_Object NP_Array;
-typedef NP_Object NP_Number;
-typedef NP_Object NP_String;
+extern NPClass *NPBooleanClass;
+extern NPClass *NPNullClass;
+extern NPClass *NPUndefinedClass;
+extern NPClass *NPArrayClass;
+extern NPClass *NPNumberClass;
+extern NPClass *NPStringClass;
+extern NPClass *NPScriptObjectClass;
+
+typedef NPObject NPBoolean;
+typedef NPObject NPNull;
+typedef NPObject NPUndefined;
+typedef NPObject NPArray;
+typedef NPObject NPNumber;
+typedef NPObject NPString;
/*
- Functions to access JavaScript Objects represented by NP_JavaScriptObject.
+ Functions to access JavaScript Objects represented by NPScriptObject.
Calls to JavaScript objects are asynchronous. If a function returns a value, it
- will be supplied via the NP_JavaScriptResultInterface callback.
+ will be supplied via the NP_JavaScriptResultFunctionPtr callback.
Calls made from plugin code to JavaScript may be made from any thread.
Calls made from JavaScript to the plugin will always be made on the main
- user agent thread, this include calls to NP_JavaScriptResultInterface callbacks.
+ user agent thread, this include calls to NP_JavaScriptResultFunctionPtr callbacks.
*/
-typedef void (*NP_JavaScriptResultInterface)(NP_Object *obj, void *resultContext);
+typedef void (*NPScriptResultFunctionPtr)(NPObject *obj, void *resultContext);
-void NP_Call (NP_JavaScriptObject *obj, NP_Identifier methodName, NP_Object **args, unsigned argCount, NP_JavaScriptResultInterface resultCallback);
-void NP_Evaluate (NP_JavaScriptObject *obj, NP_String *script, NP_JavaScriptResultInterface resultCallback, void *resultContext);
-void NP_GetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName, NP_JavaScriptResultInterface resultCallback, void *resultContext);
-void NP_SetProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName, NP_Object *value);
-void NP_RemoveProperty (NP_JavaScriptObject *obj, NP_Identifier propertyName);
-void NP_ToString (NP_JavaScriptObject *obj, NP_JavaScriptResultInterface result, void *resultContext);
-void NP_GetPropertyAtIndex (NP_JavaScriptObject *obj, int32_t index, NP_JavaScriptResultInterface resultCallback, void *resultContext);
-void NP_SetPropertyAtIndex (NP_JavaScriptObject *obj, unsigned index, NP_Object *value);
+void NPN_Call (NPScriptObject *obj, NPIdentifier methodName, NPObject **args, unsigned argCount, NPScriptResultFunctionPtr resultCallback);
+void NPN_Evaluate (NPScriptObject *obj, NPString *script, NPScriptResultFunctionPtr resultCallback, void *resultContext);
+void NPN_GetProperty (NPScriptObject *obj, NPIdentifier propertyName, NPScriptResultFunctionPtr resultCallback, void *resultContext);
+void NPN_SetProperty (NPScriptObject *obj, NPIdentifier propertyName, NPObject *value);
+void NPN_RemoveProperty (NPScriptObject *obj, NPIdentifier propertyName);
+void NPN_ToString (NPScriptObject *obj, NPScriptResultFunctionPtr result, void *resultContext);
+void NPN_GetPropertyAtIndex (NPScriptObject *obj, int32_t index, NPScriptResultFunctionPtr resultCallback, void *resultContext);
+void NPN_SetPropertyAtIndex (NPScriptObject *obj, unsigned index, NPObject *value);
/*
Functions for dealing with data types.
*/
-NP_Number *NP_CreateNumberWithInt (int i);
-NP_Number *NP_CreateNumberWithFloat (float f);
-NP_Number *NP_CreateNumberWithDouble (double d);
-int NP_IntFromNumber (NP_Number *obj);
-float NP_FloatFromNumber (NP_Number *obj);
-double NP_DoubleFromNumber (NP_Number *obj);
+NPNumber *NPN_CreateNumberWithInt (int i);
+NPNumber *NPN_CreateNumberWithFloat (float f);
+NPNumber *NPN_CreateNumberWithDouble (double d);
+int NPN_IntFromNumber (NPNumber *obj);
+float NPN_FloatFromNumber (NPNumber *obj);
+double NPN_DoubleFromNumber (NPNumber *obj);
-NP_String *NP_CreateStringWithUTF8 (const NP_UTF8 *utf8String);
-NP_String *NP_CreateStringWithUTF16 (const NP_UTF16 *utf16String, unsigned int len);
+/*
+ NPN_CreateStringWithUTF8() takes a UTF8 string and length. -1 may be passed for the
+ length if the string is null terminated.
+*/
+NPString *NPN_CreateStringWithUTF8 (const NPUTF8 *utf8String, int32_t length);
/*
- Memory returned from NP_UTF8FromString must be deallocated
+ Memory returned from NPUTF8FromString must be deallocated
by calling NP_DeallocateUTF8.
*/
-NP_UTF8 *NP_UTF8FromString (NP_String *obj);
-void NP_DeallocateUTF8 (NP_UTF8 *UTF8Buffer);
-NP_UTF16 *NP_UTF16FromString (NP_String *obj);
-int32_t NP_StringLength (NP_String *obj);
+NPUTF8 *NPN_UTF8FromString (NPString *obj);
+void NPN_DeallocateUTF8 (NPUTF8 *UTF8Buffer);
+int32_t NPN_StringLength (NPString *obj);
-NP_Boolean *NP_CreateBoolean (bool f);
-bool NP_BoolFromBoolean (NP_Boolean *aBool);
+NPBoolean *NPN_CreateBoolean (bool f);
+bool NPN_BoolFromBoolean (NPBoolean *aBool);
/*
- NP_Null returns a NP_Null singleton.
+ NPNull returns a NPNull singleton.
*/
-NP_Null *NP_GetNull();
+NPNull *NPN_GetNull();
/*
- NP_Undefined returns a NP_Undefined singleton.
+ NPUndefined returns a NPUndefined singleton.
*/
-NP_Undefined *NP_GetUndefined();
+NPUndefined *NPN_GetUndefined ();
/*
- NP_Arrays are immutable. They are used to pass arguments to
- JavaScription Interfaces that expect arrays, or to export
- arrays of properties. NP_Array is represented in JavaScript
+ NPArrays are immutable. They are used to pass arguments to
+ JavaScription FunctionPtrs that expect arrays, or to export
+ arrays of properties. NPArray is represented in JavaScript
by a restricted Array. The Array in JavaScript is read-only,
only has index accessors, and may not be resized.
Objects added to arrays are retained by the array.
*/
-NP_Array *NP_CreateArray (NP_Object **, int32_t count);
-NP_Array *NP_CreateArrayV (int32_t count, ...);
+NPArray *NPN_CreateArray (NPObject **, int32_t count);
+NPArray *NPN_CreateArrayV (int32_t count, ...);
/*
- Objects returned by NP_ObjectAtIndex pass a reference count
+ Objects returned by NPN_ObjectAtIndex pass a reference count
to the caller. The caller must release the object.
*/
-NP_Object *NP_ObjectAtIndex (NP_Array *array, int32_t index);
+NPObject *NPN_ObjectAtIndex (NPArray *array, int32_t index);
/*
Returns true if the object is a kind of class as specified by
aClass.
*/
-bool NP_IsKindOfClass (const NP_Object *obj, const NP_Class *aClass);
+bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass);
/*
- NP_SetException may be called to trigger a JavaScript exception upon return
- from entry points into NP_Objects. A reference count of the message passes
+ NPN_SetException may be called to trigger a JavaScript exception upon return
+ from entry points into NPObjects. A reference count of the message passes
to the callee. Typical usage:
- NP_String *message = NP_CreateStringWithUTF8("invalid type");
- NP_SetException (obj, mesage);
+ NPString *message = NP_CreateStringWithUTF8("invalid type");
+ NPN_SetException (obj, mesage);
NP_ReleaseObject (message);
+
+ NPN_SetExceptionWithUTF8() take an UTF8 string and a length. -1 may be passed for
+ the length if the string is null terminated.
*/
-void NP_SetExceptionWithUTF8 (NP_Object *obj, const NP_UTF8 *message);
-void NP_SetException (NP_Object *obj, NP_String *message);
+void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length);
+void NPN_SetException (NPObject *obj, NPString *message);
/*
Example usage:
- typedef NP_Object MyInterfaceObject;
+ typedef NPObject MyFunctionPtrObject;
typedef struct
{
- NP_Object object;
- // Properties needed by MyInterfaceObject are added here.
+ NPObject object;
+ // Properties needed by MyFunctionPtrObject are added here.
int numChapters;
...
- } MyInterfaceObject
+ } MyFunctionPtrObject
- void stop(MyInterfaceObject *obj)
+ void stop(MyFunctionPtrObject *obj)
{
...
}
- void start(MyInterfaceObject *obj)
+ void start(MyFunctionPtrObject *obj)
{
...
}
- void setChapter(MyInterfaceObject *obj, int chapter)
+ void setChapter(MyFunctionPtrObject *obj, int chapter)
{
...
}
- int getChapter(MyInterfaceObject *obj)
+ int getChapter(MyFunctionPtrObject *obj)
{
...
}
- static NP_Identifier stopIdentifier;
- static NP_Identifier startIdentifier;
- static NP_Identifier setChapterIdentifier;
- static NP_Identifier getChapterIdentifier;
- static NP_Identifier numChaptersIdentifier;
+ static NPIdentifier stopIdentifier;
+ static NPIdentifier startIdentifier;
+ static NPIdentifier setChapterIdentifier;
+ static NPIdentifier getChapterIdentifier;
+ static NPIdentifier numChaptersIdentifier;
static void initializeIdentifiers()
{
- stopIdentifier = NP_IdentifierFromUTF8 ("stop");
- startIdentifier = NP_IdentifierFromUTF8 ("start");
- setChapterIdentifier = NP_IdentifierFromUTF8 ("setChapter");
- getChapterIdentifier = NP_IdentifierFromUTF8 ("getChapter");
- numChaptersIdentifier = NP_IdentifierFromUTF8 ("numChapters");
+ stopIdentifier = NPIdentifierFromUTF8 ("stop");
+ startIdentifier = NPIdentifierFromUTF8 ("start");
+ setChapterIdentifier = NPIdentifierFromUTF8 ("setChapter");
+ getChapterIdentifier = NPIdentifierFromUTF8 ("getChapter");
+ numChaptersIdentifier = NPIdentifierFromUTF8 ("numChapters");
}
- bool myInterfaceHasProperty (MyInterfaceObject *obj, NP_Identifier name)
+ bool myFunctionPtrHasProperty (MyFunctionPtrObject *obj, NPIdentifier name)
{
if (name == numChaptersIdentifier){
return true;
@@ -364,7 +373,7 @@ void NP_SetException (NP_Object *obj, NP_String *message);
return false;
}
- bool myInterfaceHasMethod (MyInterfaceObject *obj, NP_Identifier name)
+ bool myFunctionPtrHasMethod (MyFunctionPtrObject *obj, NPIdentifier name)
{
if (name == stopIdentifier ||
name == startIdentifier ||
@@ -375,22 +384,22 @@ void NP_SetException (NP_Object *obj, NP_String *message);
return false;
}
- NP_Object *myInterfaceGetProperty (MyInterfaceObject *obj, NP_Identifier name)
+ NPObject *myFunctionPtrGetProperty (MyFunctionPtrObject *obj, NPIdentifier name)
{
if (name == numChaptersIdentifier){
- return NP_CreateNumberWithInt(obj->numChapters);
+ return NPN_CreateNumberWithInt(obj->numChapters);
}
return 0;
}
- void myInterfaceSetProperty (MyInterfaceObject *obj, NP_Identifier name, NP_Object *value)
+ void myFunctionPtrSetProperty (MyFunctionPtrObject *obj, NPIdentifier name, NPObject *value)
{
if (name == numChaptersIdentifier){
- obj->numChapters = NP_IntFromNumber(obj)
+ obj->numChapters = NPN_IntFromNumber(obj)
}
}
- NP_Object *myInterfaceInvoke (MyInterfaceObject *obj, NP_Identifier name, NP_Object **args, unsigned argCount)
+ NPObject *myFunctionPtrInvoke (MyFunctionPtrObject *obj, NPIdentifier name, NPObject **args, unsigned argCount)
{
if (name == stopIdentifier){
@@ -400,59 +409,59 @@ void NP_SetException (NP_Object *obj, NP_String *message);
start(obj);
}
else if (name == setChapterIdentifier){
- if (NP_IsKindOfClass (args[0], NP_NumberClass)) {
- setChapter (obj, NP_IntFromNumber(args[0]));
+ if (NPN_IsKindOfClass (args[0], NPNumberClass)) {
+ setChapter (obj, NPN_IntFromNumber(args[0]));
}
else {
- NP_SetException (obj, NP_CreateStringWithUTF8 ("invalid type"));
+ NPN_SetException (obj, NP_CreateStringWithUTF8 ("invalid type"));
}
}
else if (name == getChapterIdentifier){
- return NP_CreateNumberWithInt (getChapter (obj));
+ return NPN_CreateNumberWithInt (getChapter (obj));
}
return 0;
}
- NP_Object *myInterfaceAllocate ()
+ NPObject *myFunctionPtrAllocate ()
{
- MyInterfaceObject *newInstance = (MyInterfaceObject *)malloc (sizeof(MyInterfaceObject));
+ MyFunctionPtrObject *newInstance = (MyFunctionPtrObject *)malloc (sizeof(MyFunctionPtrObject));
if (stopIdentifier == 0)
initializeIdentifiers();
- return (NP_Object *)newInstance;
+ return (NPObject *)newInstance;
}
- void myInterfaceInvalidate ()
+ void myFunctionPtrInvalidate ()
{
// Make sure we've released any remainging references to JavaScript
// objects.
}
- void myInterfaceDeallocate (MyInterfaceObject *obj)
+ void myFunctionPtrDeallocate (MyFunctionPtrObject *obj)
{
free ((void *)obj);
}
- static NP_Class _myInterface = {
- (NP_AllocateInterface) myInterfaceAllocate,
- (NP_DeallocateInterface) myInterfaceDeallocate,
- (NP_InvalidateInterface) myInterfaceInvalidate,
- (NP_HasMethodInterface) myInterfaceHasMethod,
- (NP_InvokeInterface) myInterfaceInvoke,
- (NP_HasPropertyInterface) myInterfaceHasProperty,
- (NP_GetPropertyInterface) myInterfaceGetProperty,
- (NP_SetPropertyInterface) myInterfaceSetProperty,
+ static NPClass _myFunctionPtr = {
+ (NPAllocateFunctionPtr) myFunctionPtrAllocate,
+ (NPDeallocateFunctionPtr) myFunctionPtrDeallocate,
+ (NPInvalidateFunctionPtr) myFunctionPtrInvalidate,
+ (NPHasMethodFunctionPtr) myFunctionPtrHasMethod,
+ (NPInvokeFunctionPtr) myFunctionPtrInvoke,
+ (NPHasPropertyFunctionPtr) myFunctionPtrHasProperty,
+ (NPGetPropertyFunctionPtr) myFunctionPtrGetProperty,
+ (NPSetPropertyFunctionPtr) myFunctionPtrSetProperty,
};
- static NP_Class *myInterface = &_myInterface;
+ static NPClass *myFunctionPtr = &_myFunctionPtr;
// myGetNativeObjectForJavaScript would be set as the entry point for
// the plugin's NPP_GetNativeObjectForJavaScript function.
// It is invoked by the plugin container, i.e. the browser.
- NP_Object *myGetNativeObjectForJavaScript(NPP_Instance instance)
+ NPObject *myGetNativeObjectForJavaScript(NPP instance)
{
- NP_Object *myInterfaceObject = NP_CreateObject (myInterface);
- return myInterfaceObject;
+ NPObject *myFunctionPtrObject = NPN_CreateObject (myFunctionPtr);
+ return myFunctionPtrObject;
}
*/
diff --git a/JavaScriptCore/bindings/runtime.cpp b/JavaScriptCore/bindings/runtime.cpp
index 73994ff..961418e 100644
--- a/JavaScriptCore/bindings/runtime.cpp
+++ b/JavaScriptCore/bindings/runtime.cpp
@@ -99,7 +99,7 @@ Instance *Instance::createBindingForLanguageInstance (BindingLanguage language,
return new Bindings::ObjcInstance ((struct objc_object *)instance);
else if (language == Instance::CLanguage)
- return new Bindings::CInstance ((NP_Object *)instance);
+ return new Bindings::CInstance ((NPObject *)instance);
return 0;
}
diff --git a/JavaScriptCore/bindings/testbindings.cpp b/JavaScriptCore/bindings/testbindings.cpp
index 14a01ad..6b6128f 100644
--- a/JavaScriptCore/bindings/testbindings.cpp
+++ b/JavaScriptCore/bindings/testbindings.cpp
@@ -28,7 +28,7 @@
#include "types.h"
#include "interpreter.h"
-#include "NP_runtime.h"
+#include "npruntime.h"
#include "runtime.h"
#include "runtime_object.h"
@@ -43,12 +43,12 @@
// ------------------ NP Interface definition --------------------
typedef struct
{
- NP_Object object;
+ NPObject object;
double doubleValue;
int intValue;
const char *stringValue;
bool boolValue;
-} MyInterfaceObject;
+} MyObject;
static bool identifiersInitialized = false;
@@ -61,8 +61,8 @@ static bool identifiersInitialized = false;
#define ID_UNDEFINED_VALUE 5
#define NUM_PROPERTY_IDENTIFIERS 6
-static NP_Identifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
-static const NP_UTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
+static NPIdentifier myPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
+static const NPUTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
"doubleValue",
"intValue",
"stringValue",
@@ -82,8 +82,8 @@ static const NP_UTF8 *myPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
#define ID_GET_BOOLEAN_VALUE 8
#define NUM_METHOD_IDENTIFIERS 9
-static NP_Identifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
-static const NP_UTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
+static NPIdentifier myMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
+static const NPUTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
"logMessage",
"setDoubleValue",
"setIntValue",
@@ -97,11 +97,11 @@ static const NP_UTF8 *myMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
static void initializeIdentifiers()
{
- NP_GetIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers);
- NP_GetIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers);
+ NPN_GetIdentifiers (myPropertyIdentifierNames, NUM_PROPERTY_IDENTIFIERS, myPropertyIdentifiers);
+ NPN_GetIdentifiers (myMethodIdentifierNames, NUM_METHOD_IDENTIFIERS, myMethodIdentifiers);
};
-bool myInterfaceHasProperty (NP_Class *theClass, NP_Identifier name)
+bool myHasProperty (NPClass *theClass, NPIdentifier name)
{
int i;
for (i = 0; i < NUM_PROPERTY_IDENTIFIERS; i++) {
@@ -112,7 +112,7 @@ bool myInterfaceHasProperty (NP_Class *theClass, NP_Identifier name)
return false;
}
-bool myInterfaceHasMethod (NP_Class *theClass, NP_Identifier name)
+bool myHasMethod (NPClass *theClass, NPIdentifier name)
{
int i;
for (i = 0; i < NUM_METHOD_IDENTIFIERS; i++) {
@@ -123,64 +123,64 @@ bool myInterfaceHasMethod (NP_Class *theClass, NP_Identifier name)
return false;
}
-NP_Object *myInterfaceGetProperty (MyInterfaceObject *obj, NP_Identifier name)
+NPObject *myGetProperty (MyObject *obj, NPIdentifier name)
{
if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
- return NP_CreateNumberWithDouble (obj->doubleValue);
+ return NPN_CreateNumberWithDouble (obj->doubleValue);
}
else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
- return NP_CreateNumberWithInt (obj->intValue);
+ return NPN_CreateNumberWithInt (obj->intValue);
}
else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
- return NP_CreateStringWithUTF8 (obj->stringValue);
+ return NPN_CreateStringWithUTF8 (obj->stringValue, -1);
}
else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
- return NP_CreateBoolean (obj->boolValue);
+ return NPN_CreateBoolean (obj->boolValue);
}
else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
- return NP_GetNull ();
+ return NPN_GetNull ();
}
else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
- return NP_GetUndefined ();
+ return NPN_GetUndefined ();
}
- return NP_GetUndefined();
+ return NPN_GetUndefined();
}
-void myInterfaceSetProperty (MyInterfaceObject *obj, NP_Identifier name, NP_Object *value)
+void mySetProperty (MyObject *obj, NPIdentifier name, NPObject *value)
{
if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
- if (NP_IsKindOfClass (value, NP_NumberClass)) {
- obj->doubleValue = NP_DoubleFromNumber (value);
+ if (NPN_IsKindOfClass (value, NPNumberClass)) {
+ obj->doubleValue = NPN_DoubleFromNumber (value);
}
else {
- NP_SetExceptionWithUTF8 ((NP_Object *)obj, "Attempt to set a double value with a non-number type.");
+ NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a double value with a non-number type.", -1);
}
}
else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
- if (NP_IsKindOfClass (value, NP_NumberClass)) {
- obj->intValue = NP_IntFromNumber (value);
+ if (NPN_IsKindOfClass (value, NPNumberClass)) {
+ obj->intValue = NPN_IntFromNumber (value);
}
else {
- NP_SetExceptionWithUTF8 ((NP_Object *)obj, "Attempt to set a int value with a non-number type.");
+ NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a int value with a non-number type.", -1);
}
}
else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
- if (NP_IsKindOfClass (value, NP_StringClass)) {
+ if (NPN_IsKindOfClass (value, NPStringClass)) {
if (obj->stringValue)
free((void *)obj->stringValue);
- obj->stringValue = NP_UTF8FromString (value);
+ obj->stringValue = NPN_UTF8FromString (value);
}
else {
- NP_SetExceptionWithUTF8 ((NP_Object *)obj, "Attempt to set a string value with a non-string type.");
+ NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a string value with a non-string type.", -1);
}
}
else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
- if (NP_IsKindOfClass (value, NP_StringClass)) {
- obj->boolValue = NP_BoolFromBoolean (value);
+ if (NPN_IsKindOfClass (value, NPStringClass)) {
+ obj->boolValue = NPN_BoolFromBoolean (value);
}
else {
- NP_SetExceptionWithUTF8 ((NP_Object *)obj, "Attempt to set a bool value with a non-boolean type.");
+ NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a bool value with a non-boolean type.", -1);
}
}
else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
@@ -191,77 +191,77 @@ void myInterfaceSetProperty (MyInterfaceObject *obj, NP_Identifier name, NP_Obje
}
}
-void logMessage (NP_String *message)
+void logMessage (NPString *message)
{
- printf ("%s\n", NP_UTF8FromString (message));
+ printf ("%s\n", NPN_UTF8FromString (message));
}
-void setDoubleValue (MyInterfaceObject *obj, NP_Number *number)
+void setDoubleValue (MyObject *obj, NPNumber *number)
{
- obj->doubleValue = NP_DoubleFromNumber (number);
+ obj->doubleValue = NPN_DoubleFromNumber (number);
}
-void setIntValue (MyInterfaceObject *obj, NP_Number *number)
+void setIntValue (MyObject *obj, NPNumber *number)
{
- obj->intValue = NP_IntFromNumber (number);
+ obj->intValue = NPN_IntFromNumber (number);
}
-void setStringValue (MyInterfaceObject *obj, NP_String *string)
+void setStringValue (MyObject *obj, NPString *string)
{
- NP_DeallocateUTF8 ((NP_UTF8 *)obj->stringValue);
- obj->stringValue = NP_UTF8FromString (string);
+ NPN_DeallocateUTF8 ((NPUTF8 *)obj->stringValue);
+ obj->stringValue = NPN_UTF8FromString (string);
}
-void setBooleanValue (MyInterfaceObject *obj, NP_Boolean *boolean)
+void setBooleanValue (MyObject *obj, NPBoolean *boolean)
{
- obj->boolValue = NP_BoolFromBoolean (boolean);
+ obj->boolValue = NPN_BoolFromBoolean (boolean);
}
-NP_Number *getDoubleValue (MyInterfaceObject *obj)
+NPNumber *getDoubleValue (MyObject *obj)
{
- return NP_CreateNumberWithDouble (obj->doubleValue);
+ return NPN_CreateNumberWithDouble (obj->doubleValue);
}
-NP_Number *getIntValue (MyInterfaceObject *obj)
+NPNumber *getIntValue (MyObject *obj)
{
- return NP_CreateNumberWithInt (obj->intValue);
+ return NPN_CreateNumberWithInt (obj->intValue);
}
-NP_String *getStringValue (MyInterfaceObject *obj)
+NPString *getStringValue (MyObject *obj)
{
- return NP_CreateStringWithUTF8 (obj->stringValue);
+ return NPN_CreateStringWithUTF8 (obj->stringValue, -1);
}
-NP_Boolean *getBooleanValue (MyInterfaceObject *obj)
+NPBoolean *getBooleanValue (MyObject *obj)
{
- return NP_CreateBoolean (obj->boolValue);
+ return NPN_CreateBoolean (obj->boolValue);
}
-NP_Object *myInterfaceInvoke (MyInterfaceObject *obj, NP_Identifier name, NP_Object **args, unsigned argCount)
+NPObject *myInvoke (MyObject *obj, NPIdentifier name, NPObject **args, unsigned argCount)
{
if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) {
- if (argCount == 1 && NP_IsKindOfClass (args[0], NP_StringClass))
- logMessage ((NP_String *)args[0]);
+ if (argCount == 1 && NPN_IsKindOfClass (args[0], NPStringClass))
+ logMessage ((NPString *)args[0]);
return 0;
}
else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) {
- if (argCount == 1 && NP_IsKindOfClass (args[0], NP_NumberClass))
- setDoubleValue (obj, (NP_Number *)args[0]);
+ if (argCount == 1 && NPN_IsKindOfClass (args[0], NPNumberClass))
+ setDoubleValue (obj, (NPNumber *)args[0]);
return 0;
}
else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) {
- if (argCount == 1 && NP_IsKindOfClass (args[0], NP_NumberClass))
- setIntValue (obj, (NP_Number *)args[0]);
+ if (argCount == 1 && NPN_IsKindOfClass (args[0], NPNumberClass))
+ setIntValue (obj, (NPNumber *)args[0]);
return 0;
}
else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) {
- if (argCount == 1 && NP_IsKindOfClass (args[0], NP_StringClass))
- setStringValue (obj, (NP_String *)args[0]);
+ if (argCount == 1 && NPN_IsKindOfClass (args[0], NPStringClass))
+ setStringValue (obj, (NPString *)args[0]);
return 0;
}
else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) {
- if (argCount == 1 && NP_IsKindOfClass (args[0], NP_BooleanClass))
- setBooleanValue (obj, (NP_Boolean *)args[0]);
+ if (argCount == 1 && NPN_IsKindOfClass (args[0], NPBooleanClass))
+ setBooleanValue (obj, (NPBoolean *)args[0]);
return 0;
}
else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) {
@@ -276,12 +276,12 @@ NP_Object *myInterfaceInvoke (MyInterfaceObject *obj, NP_Identifier name, NP_Obj
else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) {
return getBooleanValue (obj);
}
- return NP_GetUndefined();
+ return NPN_GetUndefined();
}
-NP_Object *myInterfaceAllocate ()
+NPObject *myAllocate ()
{
- MyInterfaceObject *newInstance = (MyInterfaceObject *)malloc (sizeof(MyInterfaceObject));
+ MyObject *newInstance = (MyObject *)malloc (sizeof(MyObject));
if (!identifiersInitialized) {
identifiersInitialized = true;
@@ -294,32 +294,32 @@ NP_Object *myInterfaceAllocate ()
newInstance->boolValue = true;
newInstance->stringValue = strdup("Hello world");
- return (NP_Object *)newInstance;
+ return (NPObject *)newInstance;
}
-void myInterfaceInvalidate ()
+void myInvalidate ()
{
// Make sure we've released any remainging references to JavaScript
// objects.
}
-void myInterfaceDeallocate (MyInterfaceObject *obj)
+void myDeallocate (MyObject *obj)
{
free ((void *)obj);
}
-static NP_Class _myInterface = {
- kNP_ClassStructVersionCurrent,
- (NP_AllocateInterface) myInterfaceAllocate,
- (NP_DeallocateInterface) myInterfaceDeallocate,
- (NP_InvalidateInterface) myInterfaceInvalidate,
- (NP_HasMethodInterface) myInterfaceHasMethod,
- (NP_InvokeInterface) myInterfaceInvoke,
- (NP_HasPropertyInterface) myInterfaceHasProperty,
- (NP_GetPropertyInterface) myInterfaceGetProperty,
- (NP_SetPropertyInterface) myInterfaceSetProperty,
+static NPClass _myFunctionPtrs = {
+ kNPClassStructVersionCurrent,
+ (NPAllocateFunctionPtr) myAllocate,
+ (NPDeallocateFunctionPtr) myDeallocate,
+ (NPInvalidateFunctionPtr) myInvalidate,
+ (NPHasMethodFunctionPtr) myHasMethod,
+ (NPInvokeFunctionPtr) myInvoke,
+ (NPHasPropertyFunctionPtr) myHasProperty,
+ (NPGetPropertyFunctionPtr) myGetProperty,
+ (NPSetPropertyFunctionPtr) mySetProperty,
};
-static NP_Class *myInterface = &_myInterface;
+static NPClass *myFunctionPtrs = &_myFunctionPtrs;
// --------------------------------------------------------
@@ -369,9 +369,9 @@ int main(int argc, char **argv)
Interpreter interp(global);
ExecState *exec = interp.globalExec();
- MyInterfaceObject *myInterfaceObject = (MyInterfaceObject *)NP_CreateObject (myInterface);
+ MyObject *myObject = (MyObject *)NPN_CreateObject (myFunctionPtrs);
- global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::CLanguage, (void *)myInterfaceObject));
+ global.put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::CLanguage, (void *)myObject));
for (int i = 1; i < argc; i++) {
const char *code = readJavaScriptFromFile(argv[i]);
@@ -402,7 +402,7 @@ int main(int argc, char **argv)
}
}
- NP_ReleaseObject ((NP_Object *)myInterfaceObject);
+ NPN_ReleaseObject ((NPObject *)myObject);
Interpreter::unlock();
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list