Updated plugin binding API to reflect latest revision from
authorrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Apr 2004 21:38:25 +0000 (21:38 +0000)
committerrjw <rjw@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Apr 2004 21:38:25 +0000 (21:38 +0000)
working group.

Biggest change is the introduction of NPVariant used to represent
value types.  NPVariant replaces the use of NPObject for the
exchange of values between scripting environment and native code.

        Reviewed by John.

        * JavaScriptCore.pbproj/project.pbxproj:
        * bindings/NP_jsobject.cpp:
        (identiferFromNPIdentifier):
        (NPN_Call):
        (NPN_Evaluate):
        (NPN_GetProperty):
        (NPN_SetProperty):
        (NPN_ToString):
        (NPN_GetPropertyAtIndex):
        (NPN_SetPropertyAtIndex):
        * bindings/c/c_class.cpp:
        (CClass::methodsNamed):
        (CClass::fieldNamed):
        * bindings/c/c_instance.cpp:
        (CInstance::invokeMethod):
        (CInstance::defaultValue):
        * bindings/c/c_runtime.cpp:
        (CField::valueFromInstance):
        (CField::setValueToInstance):
        * bindings/c/c_utility.cpp:
        (convertNPStringToUTF16):
        (convertUTF8ToUTF16):
        (coerceValueToNPVariantStringType):
        (convertValueToNPVariant):
        (convertNPVariantToValue):
        * bindings/c/c_utility.h:
        * bindings/npruntime.cpp:
        (NPN_GetIdentifier):
        (NPN_GetIdentifiers):
        (NPN_UTF8FromIdentifier):
        (NPN_VariantIsVoid):
        (NPN_VariantIsNull):
        (NPN_VariantIsUndefined):
        (NPN_VariantIsBool):
        (NPN_VariantIsInt32):
        (NPN_VariantIsDouble):
        (NPN_VariantIsString):
        (NPN_VariantIsObject):
        (NPN_VariantToBool):
        (NPN_VariantToString):
        (NPN_VariantToInt32):
        (NPN_VariantToDouble):
        (NPN_VariantToObject):
        (NPN_InitializeVariantAsVoid):
        (NPN_InitializeVariantAsNull):
        (NPN_InitializeVariantAsUndefined):
        (NPN_InitializeVariantWithBool):
        (NPN_InitializeVariantWithInt32):
        (NPN_InitializeVariantWithDouble):
        (NPN_InitializeVariantWithString):
        (NPN_InitializeVariantWithStringCopy):
        (NPN_InitializeVariantWithObject):
        (NPN_InitializeVariantWithVariant):
        (NPN_ReleaseVariantValue):
        (NPN_CreateObject):
        (NPN_RetainObject):
        (NPN_ReleaseObject):
        (NPN_IsKindOfClass):
        (NPN_SetExceptionWithUTF8):
        (NPN_SetException):
        * bindings/npruntime.h:
        (_NPString::):
        (_NPString::_NPVariant::):
        * bindings/testbindings.cpp:
        (logMessage):
        (setDoubleValue):
        (setIntValue):
        (setStringValue):
        (setBooleanValue):
        (getDoubleValue):
        (getIntValue):
        (getStringValue):
        (getBooleanValue):
        (myGetProperty):
        (mySetProperty):
        (myInvoke):
        (myAllocate):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6457 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
JavaScriptCore/bindings/NP_jsobject.cpp
JavaScriptCore/bindings/c/c_class.cpp
JavaScriptCore/bindings/c/c_instance.cpp
JavaScriptCore/bindings/c/c_runtime.cpp
JavaScriptCore/bindings/c/c_utility.cpp
JavaScriptCore/bindings/c/c_utility.h
JavaScriptCore/bindings/npruntime.cpp
JavaScriptCore/bindings/npruntime.h
JavaScriptCore/bindings/testbindings.cpp

index ad330c350e0fe742ab6c18acb951494ec5934377..6961f873c05cd9ddd68085f22545b5c2bf0aa4c2 100644 (file)
@@ -1,3 +1,92 @@
+2004-04-22  Richard Williamson   <rjw@apple.com>
+
+       Updated plugin binding API to reflect latest revision from
+       working group.
+       
+       Biggest change is the introduction of NPVariant used to represent
+       value types.  NPVariant replaces the use of NPObject for the
+       exchange of values between scripting environment and native code.
+
+        Reviewed by John.
+
+        * JavaScriptCore.pbproj/project.pbxproj:
+        * bindings/NP_jsobject.cpp:
+        (identiferFromNPIdentifier):
+        (NPN_Call):
+        (NPN_Evaluate):
+        (NPN_GetProperty):
+        (NPN_SetProperty):
+        (NPN_ToString):
+        (NPN_GetPropertyAtIndex):
+        (NPN_SetPropertyAtIndex):
+        * bindings/c/c_class.cpp:
+        (CClass::methodsNamed):
+        (CClass::fieldNamed):
+        * bindings/c/c_instance.cpp:
+        (CInstance::invokeMethod):
+        (CInstance::defaultValue):
+        * bindings/c/c_runtime.cpp:
+        (CField::valueFromInstance):
+        (CField::setValueToInstance):
+        * bindings/c/c_utility.cpp:
+        (convertNPStringToUTF16):
+        (convertUTF8ToUTF16):
+        (coerceValueToNPVariantStringType):
+        (convertValueToNPVariant):
+        (convertNPVariantToValue):
+        * bindings/c/c_utility.h:
+        * bindings/npruntime.cpp:
+        (NPN_GetIdentifier):
+        (NPN_GetIdentifiers):
+        (NPN_UTF8FromIdentifier):
+        (NPN_VariantIsVoid):
+        (NPN_VariantIsNull):
+        (NPN_VariantIsUndefined):
+        (NPN_VariantIsBool):
+        (NPN_VariantIsInt32):
+        (NPN_VariantIsDouble):
+        (NPN_VariantIsString):
+        (NPN_VariantIsObject):
+        (NPN_VariantToBool):
+        (NPN_VariantToString):
+        (NPN_VariantToInt32):
+        (NPN_VariantToDouble):
+        (NPN_VariantToObject):
+        (NPN_InitializeVariantAsVoid):
+        (NPN_InitializeVariantAsNull):
+        (NPN_InitializeVariantAsUndefined):
+        (NPN_InitializeVariantWithBool):
+        (NPN_InitializeVariantWithInt32):
+        (NPN_InitializeVariantWithDouble):
+        (NPN_InitializeVariantWithString):
+        (NPN_InitializeVariantWithStringCopy):
+        (NPN_InitializeVariantWithObject):
+        (NPN_InitializeVariantWithVariant):
+        (NPN_ReleaseVariantValue):
+        (NPN_CreateObject):
+        (NPN_RetainObject):
+        (NPN_ReleaseObject):
+        (NPN_IsKindOfClass):
+        (NPN_SetExceptionWithUTF8):
+        (NPN_SetException):
+        * bindings/npruntime.h:
+        (_NPString::):
+        (_NPString::_NPVariant::):
+        * bindings/testbindings.cpp:
+        (logMessage):
+        (setDoubleValue):
+        (setIntValue):
+        (setStringValue):
+        (setBooleanValue):
+        (getDoubleValue):
+        (getIntValue):
+        (getStringValue):
+        (getBooleanValue):
+        (myGetProperty):
+        (mySetProperty):
+        (myInvoke):
+        (myAllocate):
+
 2004-04-22  Darin Adler  <darin@apple.com>
 
         Reviewed by Maciej.
index 3540f6f19c256c660583f543ff34230d8a9ab493..d6db286ebf6a96ae55dfa858b39eb4c545dbd1f2 100644 (file)
@@ -3,7 +3,7 @@
        archiveVersion = 1;
        classes = {
        };
-       objectVersion = 38;
+       objectVersion = 39;
        objects = {
                014CEA440018CDF011CA2923 = {
                        buildRules = (
                        );
                        buildSettings = {
                                COPY_PHASE_STRIP = YES;
+                               GCC_ENABLE_FIX_AND_CONTINUE = NO;
                                INSTALL_PATH = "@executable_path/../Frameworks";
                                SECTORDER_FLAGS = "";
                                STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
+                               ZERO_LINK = NO;
                        };
                        isa = PBXBuildStyle;
                        name = Deployment;
                        isa = PBXGroup;
                        name = Products;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                034768E0FF38A50411DB9C8B = {
+                       explicitFileType = wrapper.framework;
+                       fallbackIsa = PBXFileReference;
                        isa = PBXFrameworkReference;
                        path = JavaScriptCore.framework;
                        refType = 3;
+                       sourceTree = BUILT_PRODUCTS_DIR;
                };
 //030
 //031
@@ -69,6 +75,8 @@
 //083
 //084
                0867D690FE84028FC02AAC07 = {
+                       buildSettings = {
+                       };
                        buildStyles = (
                                014CEA440018CDF011CA2923,
                                014CEA450018CDF011CA2923,
                        isa = PBXGroup;
                        name = JavaScriptCore;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                0867D69AFE84028FC02AAC07 = {
                        children = (
                        isa = PBXGroup;
                        name = Frameworks;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                0867D69CFE84028FC02AAC07 = {
                        buildPhases = (
                        name = Classes;
                        path = "";
                        refType = 4;
+                       sourceTree = "<group>";
                };
 //080
 //081
                5114F47B05E4426200D1BBBD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = runtime_root.cpp;
                        path = bindings/runtime_root.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5114F47C05E4426200D1BBBD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = runtime_root.h;
                        path = bindings/runtime_root.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5114F47D05E4426200D1BBBD = {
                        fileRef = 5114F47B05E4426200D1BBBD;
                511B0870056468730080E486 = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = runtime.h;
                        path = bindings/runtime.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                511B0871056468730080E486 = {
                        fileRef = 511B0870056468730080E486;
                511B0876056468BB0080E486 = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = jni_runtime.h;
                        path = bindings/jni/jni_runtime.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                511B0877056468BB0080E486 = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = jni_runtime.cpp;
                        path = bindings/jni/jni_runtime.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                511B0878056468BB0080E486 = {
                        fileRef = 511B0876056468BB0080E486;
                513DF74005C0861F00F89391 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = jni_jsobject.cpp;
                        path = bindings/jni/jni_jsobject.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                513DF74105C0861F00F89391 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = jni_jsobject.h;
                        path = bindings/jni/jni_jsobject.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                513DF74205C0861F00F89391 = {
                        fileRef = 513DF74005C0861F00F89391;
                51532CC705F7FD2C00EC779C = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = NP_jsobject.cpp;
                        path = bindings/NP_jsobject.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51532CC805F7FD2C00EC779C = {
                        fileRef = 51532CC705F7FD2C00EC779C;
                517BE7F40610E39600221947 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = NP_jsobject.h;
                        path = bindings/NP_jsobject.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                517BE7F50610E39600221947 = {
                        fileRef = 517BE7F40610E39600221947;
                517D52DC056BF2F5003851BD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = jni_class.cpp;
                        path = bindings/jni/jni_class.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                517D52DD056BF2F6003851BD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = jni_class.h;
                        path = bindings/jni/jni_class.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                517D52DE056BF2F6003851BD = {
                        fileRef = 517D52DC056BF2F5003851BD;
                517D5347056BFB5D003851BD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = jni_instance.cpp;
                        path = bindings/jni/jni_instance.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                517D5348056BFB5D003851BD = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = jni_instance.h;
                        path = bindings/jni/jni_instance.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                517D5349056BFB5D003851BD = {
                        fileRef = 517D5347056BFB5D003851BD;
                5182A45605FFCF4B00CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = c_instance.cpp;
                        path = bindings/c/c_instance.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A45705FFCF4B00CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = c_instance.h;
                        path = bindings/c/c_instance.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A45A05FFCF4B00CBD2F2 = {
                        fileRef = 5182A45605FFCF4B00CBD2F2;
                5182A47005FFD45000CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = c_utility.h;
                        path = bindings/c/c_utility.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A47105FFD45000CBD2F2 = {
                        fileRef = 5182A47005FFD45000CBD2F2;
                5182A48B05FFFDC400CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = c_runtime.cpp;
                        path = bindings/c/c_runtime.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A48C05FFFDC400CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = c_runtime.h;
                        path = bindings/c/c_runtime.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A48D05FFFDC500CBD2F2 = {
                        fileRef = 5182A48B05FFFDC400CBD2F2;
                5182A4FB06010F8200CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = c_utility.cpp;
                        path = bindings/c/c_utility.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A4FC06010F8200CBD2F2 = {
                        fileRef = 5182A4FB06010F8200CBD2F2;
                5182A53A06012C3000CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = c_class.cpp;
                        path = bindings/c/c_class.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A53B06012C3000CBD2F2 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = c_class.h;
                        path = bindings/c/c_class.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5182A53C06012C3000CBD2F2 = {
                        fileRef = 5182A53A06012C3000CBD2F2;
                51856D8F0562EE95008B9D83 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = jni_utility.cpp;
                        path = bindings/jni/jni_utility.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51856D900562EE95008B9D83 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = jni_utility.h;
                        path = bindings/jni/jni_utility.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51856D910562EE95008B9D83 = {
                        fileRef = 51856D8F0562EE95008B9D83;
                        isa = PBXGroup;
                        name = bindings;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51856D980562F158008B9D83 = {
                        isa = PBXFileReference;
+                       lastKnownFileType = wrapper.framework;
                        name = JavaVM.framework;
                        path = /System/Library/Frameworks/JavaVM.framework;
                        refType = 0;
+                       sourceTree = "<absolute>";
                };
                51856D990562F158008B9D83 = {
                        fileRef = 51856D980562F158008B9D83;
                518CF93605C72271003CF905 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_class.h;
                        path = bindings/objc/objc_class.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                518CF93705C72271003CF905 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
                        name = objc_class.mm;
                        path = bindings/objc/objc_class.mm;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                518CF93805C72271003CF905 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
                        name = objc_runtime.mm;
                        path = bindings/objc/objc_runtime.mm;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                518CF93905C72271003CF905 = {
                        fileRef = 518CF93605C72271003CF905;
                5199B1BD061B65BC0070C006 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = npruntime.cpp;
                        path = bindings/npruntime.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5199B1BE061B65BC0070C006 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = npruntime.h;
                        path = bindings/npruntime.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5199B1BF061B65BC0070C006 = {
                        fileRef = 5199B1BD061B65BC0070C006;
                5199B265061BB1300070C006 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = npsap.h;
                        path = bindings/npsap.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                5199B266061BB1300070C006 = {
                        fileRef = 5199B265061BB1300070C006;
                51A58A8D057D3A6A00A3E942 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = runtime_method.cpp;
                        path = bindings/runtime_method.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51A58A8E057D3A6A00A3E942 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = runtime_method.h;
                        path = bindings/runtime_method.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51A58A8F057D3A6A00A3E942 = {
                        fileRef = 51A58A8D057D3A6A00A3E942;
                51C4974105C0A5D4006FBFF5 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_runtime.h;
                        path = bindings/objc/objc_runtime.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51C4974205C0A5D4006FBFF5 = {
                        fileRef = 51C4974105C0A5D4006FBFF5;
                51F0EB0005C85A6300E6DF1B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_instance.h;
                        path = bindings/objc/objc_instance.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51F0EB0205C85A6300E6DF1B = {
                        fileRef = 51F0EB0005C85A6300E6DF1B;
                51F0EB0505C85A9000E6DF1B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
                        name = objc_instance.mm;
                        path = bindings/objc/objc_instance.mm;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51F0EB0605C85A9000E6DF1B = {
                        fileRef = 51F0EB0505C85A9000E6DF1B;
                };
                51F0EB6105C86C6B00E6DF1B = {
                        isa = PBXFileReference;
+                       lastKnownFileType = wrapper.framework;
                        name = Foundation.framework;
                        path = /System/Library/Frameworks/Foundation.framework;
                        refType = 0;
+                       sourceTree = "<absolute>";
                };
                51F0EB6205C86C6B00E6DF1B = {
                        fileRef = 51F0EB6105C86C6B00E6DF1B;
                };
                51F0EC0705C86C9A00E6DF1B = {
                        isa = PBXFileReference;
+                       lastKnownFileType = "compiled.mach-o.dylib";
                        name = libobjc.dylib;
                        path = /usr/lib/libobjc.dylib;
                        refType = 0;
+                       sourceTree = "<absolute>";
                };
                51F0EC0805C86C9A00E6DF1B = {
                        fileRef = 51F0EC0705C86C9A00E6DF1B;
                51F0EC1005C86F3500E6DF1B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_header.h;
                        path = bindings/objc/objc_header.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51F0EC1105C86F3500E6DF1B = {
                        fileRef = 51F0EC1005C86F3500E6DF1B;
                51F0EC9605C88DC700E6DF1B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_utility.h;
                        path = bindings/objc/objc_utility.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51F0EC9705C88DC700E6DF1B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
                        name = objc_utility.mm;
                        path = bindings/objc/objc_utility.mm;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                51F0EC9805C88DC700E6DF1B = {
                        fileRef = 51F0EC9605C88DC700E6DF1B;
                651F6412039D5B5F0078395C = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = dtoa.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                651F6413039D5B5F0078395C = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = dtoa.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                651F6414039D5B5F0078395C = {
                        fileRef = 651F6412039D5B5F0078395C;
                        isa = PBXGroup;
                        path = kjs;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417203039E01F90058BFEB = {
                        children = (
                        isa = PBXGroup;
                        name = pcre;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417204039E02E70058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = chartables.c;
                        path = pcre/chartables.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417205039E02E70058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = get.c;
                        path = pcre/get.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417206039E02E70058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = maketables.c;
                        path = pcre/maketables.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417207039E02E70058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = pcre.c;
                        path = pcre/pcre.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417208039E02E70058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = study.c;
                        path = pcre/study.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                6541720A039E02E70058BFEB = {
                        fileRef = 65417205039E02E70058BFEB;
                6541720E039E08B90058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.c;
                        name = dftables.c;
                        path = pcre/dftables.c;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                6541720F039E08B90058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = pcre.h;
                        path = pcre/pcre.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417211039E08B90058BFEB = {
                        fileRef = 6541720F039E08B90058BFEB;
                65417217039E0B280058BFEB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = "pcre-config.h";
                        path = "pcre/pcre-config.h";
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65417219039E0B390058BFEB = {
                        fileRef = 65417217039E0B280058BFEB;
                };
                6560A4CF04B3B3E7008AE952 = {
                        isa = PBXFileReference;
+                       lastKnownFileType = wrapper.framework;
                        name = CoreFoundation.framework;
                        path = /System/Library/Frameworks/CoreFoundation.framework;
                        refType = 0;
+                       sourceTree = "<absolute>";
                };
                6560A4D004B3B3E7008AE952 = {
                        fileRef = 6560A4CF04B3B3E7008AE952;
                };
                6560A63D04B3B69F008AE952 = {
                        isa = PBXFileReference;
+                       lastKnownFileType = wrapper.framework;
                        name = CoreServices.framework;
                        path = /System/Library/Frameworks/CoreServices.framework;
                        refType = 0;
+                       sourceTree = "<absolute>";
                };
                6560A63E04B3B69F008AE952 = {
                        fileRef = 6560A63D04B3B69F008AE952;
                65AB004806261CBA0076DE63 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = interpreter_map.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65AB004906261CBA0076DE63 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = interpreter_map.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65AB004A06261CBA0076DE63 = {
                        fileRef = 65AB004806261CBA0076DE63;
                65C02FBB0637462A003E7EE6 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = protect.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                65C02FBC0637462A003E7EE6 = {
                        fileRef = 65C02FBB0637462A003E7EE6;
                704FD35305697E6D003DBED9 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = bool_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                704FD35405697E6D003DBED9 = {
                        fileRef = 704FD35305697E6D003DBED9;
                704FD44505698F17003DBED9 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = runtime.cpp;
                        path = bindings/runtime.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                704FD44605698F17003DBED9 = {
                        fileRef = 704FD44505698F17003DBED9;
                7073BE3C0581291E005EE2C9 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = runtime_array.cpp;
                        path = bindings/runtime_array.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                7073BE3D0581291E005EE2C9 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = runtime_array.h;
                        path = bindings/runtime_array.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                7073BE3E0581291E005EE2C9 = {
                        fileRef = 7073BE3C0581291E005EE2C9;
                7084D99405DD6211007E4C0E = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = objc_jsobject.h;
                        path = bindings/objc/objc_jsobject.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                7084D99505DD6211007E4C0E = {
                        fileRef = 7084D99405DD6211007E4C0E;
                7084D9B905DD6CF8007E4C0E = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.objcpp;
                        name = objc_jsobject.mm;
                        path = bindings/objc/objc_jsobject.mm;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                7084D9BA05DD6CF8007E4C0E = {
                        fileRef = 7084D9B905DD6CF8007E4C0E;
                70B16A260569A10900DB756D = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        name = runtime_object.cpp;
                        path = bindings/runtime_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                70B16A270569A10900DB756D = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = runtime_object.h;
                        path = bindings/runtime_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                70B16A280569A10A00DB756D = {
                        fileRef = 70B16A260569A10900DB756D;
                931C6CEF038EE8DE008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = list.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                931C6CF0038EE8DE008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = list.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                931C6CF1038EE8DE008635CE = {
                        fileRef = 931C6CEF038EE8DE008635CE;
                933A3499038AE7C6008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.yacc;
                        path = grammar.y;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                933A349A038AE7C6008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = identifier.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                933A349C038AE7C6008635CE = {
                        fileRef = 933A349A038AE7C6008635CE;
                933A349D038AE80F008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = identifier.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                933A349E038AE80F008635CE = {
                        fileRef = 933A349D038AE80F008635CE;
                9364B273045B7D6C00A9CAC1 = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = fpconst.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                9364B274045B7D6C00A9CAC1 = {
                        fileRef = 9364B273045B7D6C00A9CAC1;
                9373524E038DA8C2008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = context.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                9373524F038DA8C2008635CE = {
                        fileRef = 9373524E038DA8C2008635CE;
                9374D3A7038D9D74008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = scope_chain.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                9374D3A8038D9D74008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = scope_chain.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                9374D3A9038D9D74008635CE = {
                        fileRef = 9374D3A7038D9D74008635CE;
                937F4F24048E5B9900CA2AC4 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = internal.h;
                        path = pcre/internal.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                937F4F25048E5B9900CA2AC4 = {
                        fileRef = 937F4F24048E5B9900CA2AC4;
                938772E5038BFE19008635CE = {
                        fileEncoding = 4;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = array_instance.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                938772E6038BFE19008635CE = {
                        fileRef = 938772E5038BFE19008635CE;
                F50888B6030BB74C012A967E = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = simple_number.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F50888B7030BB74C012A967E = {
                        fileRef = F50888B6030BB74C012A967E;
                F5341390030CEEB1018BE7F3 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = reference.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5341391030CEEB1018BE7F3 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = reference.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5341392030CEEB1018BE7F3 = {
                        fileRef = F5341390030CEEB1018BE7F3;
                F5341394030CF5F8018BE7F3 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = reference_list.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5341395030CF5F8018BE7F3 = {
                        fileRef = F5341394030CF5F8018BE7F3;
                F54F0800030CD22001B5C2EB = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = reference_list.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F54F0801030CD22001B5C2EB = {
                        fileRef = F54F0800030CD22001B5C2EB;
                F5BB2BC5030F772101FCFE1D = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = completion.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5BB2BC7030F772101FCFE1D = {
                        fileRef = F5BB2BC5030F772101FCFE1D;
                        name = "Other Sources";
                        path = "";
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5C290E60284F98E018635CA = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        name = JavaScriptCorePrefix.h;
                        path = ../JavaScriptCorePrefix.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5C290E70284F98E018635CA = {
                        fileRef = F5C290E60284F98E018635CA;
                F5FFE656026B47A6018635CA = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = nodes2string.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F5FFE657026B47A6018635CA = {
                        fileRef = F5FFE656026B47A6018635CA;
                F68EBB8C0255D4C601FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = config.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F68EBB8E0255D4C601FF60F7 = {
                        fileRef = F68EBB8C0255D4C601FF60F7;
                F692A84D0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = array_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A84E0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = array_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A84F0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = array_object.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8500255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = bool_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8520255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = collector.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8530255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = collector.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8540255597D01FF60F7 = {
+                       fallbackIsa = PBXFileReference;
                        fileEncoding = 30;
                        isa = PBXExecutableFileReference;
+                       lastKnownFileType = text.script.perl;
                        path = create_hash_table;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8550255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = date_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8560255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = date_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8570255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = date_object.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8580255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = debugger.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8590255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = debugger.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85A0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = error_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85B0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = error_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85C0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = function_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85D0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = function_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85E0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = function.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A85F0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = function.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8610255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = internal.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8620255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = internal.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8630255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = interpreter.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8640255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = interpreter.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8650255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = lexer.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8660255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = lexer.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8670255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = lexer.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8680255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = lookup.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8690255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = lookup.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A86A0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = math_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A86B0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = math_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A86C0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = math_object.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A86D0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = nodes.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A86E0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = nodes.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8700255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = number_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8710255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = number_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8720255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = number_object.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8730255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = object_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8740255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = object_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8750255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8760255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8770255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = operations.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8780255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = operations.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8790255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = property_map.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87A0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = property_map.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87B0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = regexp_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87C0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = regexp_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87D0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = regexp.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87E0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = regexp.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A87F0255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = string_object.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8800255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = string_object.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8810255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = string_object.lut.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8840255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = types.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8850255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = ustring.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8860255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = ustring.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8870255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = value.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8880255597D01FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = value.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8890255597D01FF60F7 = {
                        fileRef = F692A84D0255597D01FF60F7;
                F692A8C802555BA201FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.cpp.cpp;
                        path = grammar.cpp;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8C902555BA201FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = grammar.cpp.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8CA02555BA201FF60F7 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
                        path = grammar.h;
                        refType = 4;
+                       sourceTree = "<group>";
                };
                F692A8CB02555BA201FF60F7 = {
                        fileRef = F692A8C802555BA201FF60F7;
index 178482039edd25673b5d829a0dfff5920d7bad1d..0baf622672e53d7f14b17848cfceb65f0bade0cc 100644 (file)
@@ -62,87 +62,99 @@ NPClass *NPScriptObjectClass = javascriptClass;
 Identifier identiferFromNPIdentifier(NPIdentifier ident)
 {
     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);
+    NPUTF16 *methodName;
+    unsigned int UTF16Length;
+    
+    convertUTF8ToUTF16 (name, -1, &methodName, &UTF16Length); // requires free() of returned memory.
+    Identifier identifier ((const KJS::UChar*)methodName, UTF16Length);
     free ((void *)methodName);
+    
     return identifier;
 }
 
 void NPN_Call (NPScriptObject *o, NPIdentifier ident, NPObject **args, unsigned argCount, NPScriptResultFunctionPtr resultCallback, void *resultContext)
 {
     JavaScriptObject *obj = (JavaScriptObject *)o; 
-
+    NPVariant resultVariant;
+    
     // Lookup the function object.
     ExecState *exec = obj->root->interpreter()->globalExec();
     Interpreter::lock();
-    
     Value func = obj->imp->get (exec, identiferFromNPIdentifier(ident));
     Interpreter::unlock();
+
     if (func.isNull()) {
-        resultCallback (NPN_GetNull(), resultContext);
-        return;
+        NPN_InitializeVariantAsNull(&resultVariant);
     }
     else if ( func.type() == UndefinedType) {
-        resultCallback (NPN_GetUndefined(), resultContext);
-        return;
+        NPN_InitializeVariantAsUndefined(&resultVariant);
     }
-
-    // Call the function object.
-    ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
-    Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
-    List argList = listFromNPArray(exec, args, argCount);
-    Interpreter::lock();
-    Value result = funcImp->call (exec, thisObj, argList);
-    Interpreter::unlock();
-
-    // Convert and return the result of the function call.
-    NPObject *npresult = convertValueToNPValueType(exec, result);
-
-    resultCallback (npresult, resultContext);
+    else {
+        // Call the function object.
+        ObjectImp *funcImp = static_cast<ObjectImp*>(func.imp());
+        Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
+        List argList = listFromNPArray(exec, args, argCount);
+        Interpreter::lock();
+        Value result = funcImp->call (exec, thisObj, argList);
+        Interpreter::unlock();
+
+        // Convert and return the result of the function call.
+        convertValueToNPVariant(exec, result, &resultVariant);
+    }
+    
+    resultCallback (&resultVariant, resultContext);
+    
+    NPN_ReleaseVariantValue (&resultVariant);
 }
 
 void NPN_Evaluate (NPScriptObject *o, NPString *s, NPScriptResultFunctionPtr resultCallback, void *resultContext)
 {
     JavaScriptObject *obj = (JavaScriptObject *)o; 
+    NPVariant resultVariant;
 
     ExecState *exec = obj->root->interpreter()->globalExec();
     Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
+    
     Interpreter::lock();
-    NPUTF16 *script = NPN_UTF16FromString (s);
-    int32_t length = NPN_StringLength (s);
-    KJS::Value result = obj->root->interpreter()->evaluate(UString((const UChar *)script,length)).value();
+    NPUTF16 *scriptString;
+    unsigned int UTF16Length;
+    convertNPStringToUTF16 (s, &scriptString, &UTF16Length);    // requires free() of returned memory.
+    KJS::Value result = obj->root->interpreter()->evaluate(UString((const UChar *)scriptString,UTF16Length)).value();
     Interpreter::unlock();
-    free ((void *)script);
     
-    NPObject *npresult = convertValueToNPValueType(exec, result);
+    free ((void *)scriptString);
+    
+    convertValueToNPVariant(exec, result, &resultVariant);
+
+    resultCallback (&resultVariant, resultContext);
 
-    resultCallback (npresult, resultContext);
+    NPN_ReleaseVariantValue (&resultVariant);
 }
 
 void NPN_GetProperty (NPScriptObject *o, NPIdentifier propertyName, NPScriptResultFunctionPtr resultCallback, void *resultContext)
 {
     JavaScriptObject *obj = (JavaScriptObject *)o; 
+    NPVariant resultVariant;
 
     ExecState *exec = obj->root->interpreter()->globalExec();
     Interpreter::lock();
     Value result = obj->imp->get (exec, identiferFromNPIdentifier(propertyName));
     Interpreter::unlock();
     
-    NPObject *npresult = convertValueToNPValueType(exec, result);
+    convertValueToNPVariant(exec, result, &resultVariant);
     
-    resultCallback (npresult, resultContext);
+    resultCallback (&resultVariant, resultContext);
+
+    NPN_ReleaseVariantValue (&resultVariant);
 }
 
-void NPN_SetProperty (NPScriptObject *o, NPIdentifier propertyName, NPObject *value)
+void NPN_SetProperty (NPScriptObject *o, NPIdentifier propertyName, const NPVariant *variant)
 {
     JavaScriptObject *obj = (JavaScriptObject *)o; 
 
     ExecState *exec = obj->root->interpreter()->globalExec();
     Interpreter::lock();
-    obj->imp->put (exec, identiferFromNPIdentifier(propertyName), convertNPValueTypeToValue(exec, value));
+    obj->imp->put (exec, identiferFromNPIdentifier(propertyName), convertNPVariantToValue(exec, variant));
     Interpreter::unlock();
 }
 
@@ -164,11 +176,14 @@ void NPN_ToString (NPScriptObject *o, NPScriptResultFunctionPtr resultCallback,
     Object thisObj = Object(const_cast<ObjectImp*>(obj->imp));
     ExecState *exec = obj->root->interpreter()->globalExec();
     
-    NPString *value = (NPString *)coerceValueToNPString(exec, thisObj);
+    NPVariant resultVariant;
+    coerceValueToNPVariantStringType(exec, thisObj, &resultVariant);
 
     Interpreter::unlock();
     
-    resultCallback (value, resultContext);
+    resultCallback (&resultVariant, resultContext);
+    
+    NPN_ReleaseVariantValue (&resultVariant);
 }
 
 void NPN_GetPropertyAtIndex (NPScriptObject *o, int32_t index, NPScriptResultFunctionPtr resultCallback, void *resultContext)
@@ -180,18 +195,21 @@ void NPN_GetPropertyAtIndex (NPScriptObject *o, int32_t index, NPScriptResultFun
     Value result = obj->imp->get (exec, (unsigned)index);
     Interpreter::unlock();
 
-    NPObject *npresult = convertValueToNPValueType(exec, result);
+    NPVariant resultVariant;
+    convertValueToNPVariant(exec, result, &resultVariant);
     
-    resultCallback (npresult, resultContext);
+    resultCallback (&resultVariant, resultContext);
+
+    NPN_ReleaseVariantValue (&resultVariant);
 }
 
-void NPN_SetPropertyAtIndex (NPScriptObject *o, unsigned index, NPObject value)
+void NPN_SetPropertyAtIndex (NPScriptObject *o, unsigned index, const NPVariant *value)
 {
     JavaScriptObject *obj = (JavaScriptObject *)o; 
 
     ExecState *exec = obj->root->interpreter()->globalExec();
     Interpreter::lock();
-    obj->imp->put (exec, (unsigned)index, convertNPValueTypeToValue(exec, &value));
+    obj->imp->put (exec, (unsigned)index, convertNPVariantToValue(exec, value));
     Interpreter::unlock();
 }
 
index 9a330554259ec33b4b38c2c92177d73e5e3d8f21..3ccc17eec3f66a9f2c72c405d3b7eb165b5f970d 100644 (file)
@@ -26,6 +26,8 @@
 
 using namespace KJS::Bindings;
 
+bool NPN_IsValidIdentifier (const NPUTF8 *name);
+
 void CClass::_commonDelete() {
     CFRelease (_fields);
     CFRelease (_methods);
@@ -92,7 +94,7 @@ MethodList CClass::methodsNamed(const char *_name) const
     }
     
     if (NPN_IsValidIdentifier (_name)) {
-        NPIdentifier ident = NPN_IdentifierFromUTF8 (_name);
+        NPIdentifier ident = NPN_GetIdentifier (_name);
         if (_isa->hasMethod && _isa->hasMethod (_isa, ident)){
             Method *aMethod = new CMethod (ident);
             CFDictionaryAddValue ((CFMutableDictionaryRef)_methods, methodName, aMethod);
@@ -116,7 +118,7 @@ Field *CClass::fieldNamed(const char *name) const
     }
 
     if (NPN_IsValidIdentifier (name)) {
-        NPIdentifier ident = NPN_IdentifierFromUTF8 (name);
+        NPIdentifier ident = NPN_GetIdentifier (name);
         if (_isa->hasProperty && _isa->hasProperty (_isa, ident)){
             aField = new CField (ident);
             CFDictionaryAddValue ((CFMutableDictionaryRef)_fields, fieldName, aField);
index 0fd61af9b8b20b6fba8830f31cf3405ea7928cf3..ba42bfb4655b6cd833961eff6f64df54a1daef6a 100644 (file)
@@ -97,31 +97,37 @@ Value CInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodLis
     CMethod *method = 0;
     method = static_cast<CMethod*>(methodList.methodAt(0));
 
-    NPIdentifier ident = NPN_IdentifierFromUTF8 (method->name());
+    NPIdentifier ident = NPN_GetIdentifier (method->name());
     if (!_object->_class->hasMethod (_object->_class, ident))
         return Undefined();
 
     unsigned i, count = args.size();
-    NPObject **cArgs;
-    NPObject *localBuffer[128];
+    NPVariant *cArgs;
+    NPVariant localBuffer[128];
     if (count > 128)
-        cArgs = (NPObject **)malloc (sizeof(NPObject *)*count);
+        cArgs = (NPVariant *)malloc (sizeof(NPVariant)*count);
     else
         cArgs = localBuffer;
     
     for (i = 0; i < count; i++) {
-        cArgs[i] = convertValueToNPValueType (exec, args.at(i));
+        convertValueToNPVariant (exec, args.at(i), &cArgs[i]);
     }
 
     // Invoke the 'C' method.
-    NPObject *result = _object->_class->invoke (_object, ident, cArgs, count);
-    if (result) {
-        resultValue = convertNPValueTypeToValue (exec, result);
+    NPVariant resultVariant;
+    _object->_class->invoke (_object, ident, cArgs, count, &resultVariant);
+
+    for (i = 0; i < count; i++) {
+        NPN_ReleaseVariantValue (&cArgs[i]);
+    }
+
+    if (resultVariant.type != NPVariantVoidType) {
+        resultValue = convertNPVariantToValue (exec, &resultVariant);
         
         if (cArgs != localBuffer)
             free ((void *)cArgs);
             
-        NPN_ReleaseObject (result);
+        NPN_ReleaseVariantValue (&resultVariant);
         
         return resultValue;
     }
@@ -141,23 +147,6 @@ KJS::Value CInstance::defaultValue (KJS::Type hint) const
     else if (hint == KJS::BooleanType) {
         return booleanValue();
     }
-    else if (hint == KJS::UnspecifiedType) {
-        if (NPN_IsKindOfClass (_object, NPStringClass)) {
-            return stringValue();
-        }
-        else if (NPN_IsKindOfClass (_object, NPNumberClass)) {
-            return numberValue();
-        }
-        else if (NPN_IsKindOfClass (_object, NPBooleanClass)) {
-            return booleanValue();
-        }
-        else if (NPN_IsKindOfClass (_object, NPNullClass)) {
-            return Null();
-        }
-        else if (NPN_IsKindOfClass (_object, NPUndefinedClass)) {
-            return Undefined();
-        }
-    }
     
     return valueOf();
 }
index f49724e204af78984f1b5bcdb83ca432fe92a2f3..5bbf51a237bd874445fabc4cf90401d37e3b35a8 100644 (file)
@@ -45,8 +45,9 @@ Value CField::valueFromInstance(KJS::ExecState *exec, const Instance *inst) cons
 {
     const CInstance *instance = static_cast<const CInstance*>(inst);
     NPObject *obj = instance->getObject();
-    NPObject *property = obj->_class->getProperty (obj, _fieldIdentifier);
-    Value aValue = convertNPValueTypeToValue (exec, property);
+    NPVariant property;
+    obj->_class->getProperty (obj, _fieldIdentifier, &property);
+    Value aValue = convertNPVariantToValue (exec, &property);
     return aValue;
 }
 
@@ -54,8 +55,9 @@ void CField::setValueToInstance(KJS::ExecState *exec, const Instance *inst, cons
 {
     const CInstance *instance = static_cast<const CInstance*>(inst);
     NPObject *obj = instance->getObject();
-    NPObject *value = convertValueToNPValueType (exec, aValue);
-    obj->_class->setProperty (obj, _fieldIdentifier, value);
+    NPVariant variant;
+    convertValueToNPVariant (exec, aValue, &variant);
+    obj->_class->setProperty (obj, _fieldIdentifier, &variant);
 }
 
 // ---------------------- CArray ----------------------
index ccd9e5d89f47d11cc82b3e2a20088c8630f95b6f..433ecb3bc46a8d0a878fe931a0bd4dd138661da9 100644 (file)
 using namespace KJS;
 using namespace KJS::Bindings;
 
-NPObject *coerceValueToNPString (KJS::ExecState *exec, const KJS::Value &value)
+// Requires free() of returned UTF16Chars.
+void convertNPStringToUTF16 (const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
+{
+    convertUTF8ToUTF16 (string->UTF8Characters, string->UTF8Length, UTF16Chars, UTF16Length);
+}
+
+// Requires free() of returned UTF16Chars.
+void convertUTF8ToUTF16 (const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length)
+{
+    assert (UTF8Chars);
+    
+    if (UTF8Length == -1)
+        UTF8Length = strlen(UTF8Chars);
+        
+    CFStringRef stringRef = CFStringCreateWithBytes (NULL, (const UInt8*)UTF8Chars, (CFIndex)UTF8Length, kCFStringEncodingUTF8, false);
+
+    *UTF16Length = (unsigned int)CFStringGetLength (stringRef);
+    *UTF16Chars = (NPUTF16 *)malloc (sizeof(NPUTF16) * (*UTF16Length));
+
+    // Convert the string to UTF16.
+    CFRange range = { 0, *UTF16Length };
+    CFStringGetCharacters (stringRef, range, (UniChar *)*UTF16Chars);
+    CFRelease (stringRef);
+}
+
+// Variant value must be released with NPReleaseVariantValue()
+void coerceValueToNPVariantStringType (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
 {
     UString ustring = value.toString(exec);
     CString cstring = ustring.UTF8String();
-    return NPN_CreateStringWithUTF8 (cstring.c_str(), cstring.size());
+    NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
+    NPN_InitializeVariantWithStringCopy (result, &string);
 }
 
-NPObject *convertValueToNPValueType (KJS::ExecState *exec, const KJS::Value &value)
+// Variant value must be released with NPReleaseVariantValue()
+void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
 {
     Type type = value.type();
     
     if (type == StringType) {
         UString ustring = value.toString(exec);
         CString cstring = ustring.UTF8String();
-        return NPN_CreateStringWithUTF8 (cstring.c_str(), cstring.size());
+        NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
+        NPN_InitializeVariantWithStringCopy (result, &string );
     }
     else if (type == NumberType) {
-        return NPN_CreateNumberWithDouble (value.toNumber(exec));
+        NPN_InitializeVariantWithDouble (result, value.toNumber(exec));
     }
     else if (type == BooleanType) {
-        return NPN_CreateBoolean (value.toBoolean(exec));
+        NPN_InitializeVariantWithBool (result, value.toBoolean(exec));
     }
     else if (type == UnspecifiedType) {
-        return NPN_GetUndefined();
+        NPN_InitializeVariantAsUndefined(result);
     }
     else if (type == NullType) {
-        return NPN_GetNull();
+        NPN_InitializeVariantAsNull(result);
     }
     else if (type == ObjectType) {
         KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
         if (strcmp(objectImp->classInfo()->className, "RuntimeObject") == 0) {
             KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
             CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
-            return instance->getObject();
+            NPN_InitializeVariantWithObject (result, instance->getObject());
         }
     }
-    
-    return 0;
+    else
+        NPN_InitializeVariantAsUndefined(result);
 }
 
-Value convertNPValueTypeToValue (KJS::ExecState *exec, const NPObject *obj)
+Value convertNPVariantToValue (KJS::ExecState *exec, const NPVariant *variant)
 {
-    if (NPN_IsKindOfClass (obj, NPBooleanClass)) {
-        if (NPN_BoolFromBoolean ((NPBoolean *)obj))
-            return KJS::Boolean (true);
+    NPVariantType type = variant->type;
+
+    if (type == NPVariantBoolType) {
+        NPBool aBool;
+        if (NPN_VariantToBool (variant, &aBool))
+            return KJS::Boolean (aBool);
         return KJS::Boolean (false);
     }
-    else if (NPN_IsKindOfClass (obj, NPNullClass)) {
+    else if (type == NPVariantNullType) {
         return Null();
     }
-    else if (NPN_IsKindOfClass (obj, NPUndefinedClass)) {
+    else if (type == NPVariantUndefinedType) {
         return Undefined();
     }
-    else if (NPN_IsKindOfClass (obj, NPArrayClass)) {
-        // FIXME:  Need to implement
+    else if (type == NPVariantInt32Type) {
+        int32_t anInt;
+        if (NPN_VariantToInt32 (variant, &anInt))
+            return Number (anInt);
+        return Number (0);
     }
-    else if (NPN_IsKindOfClass (obj, NPNumberClass)) {
-        return Number (NPN_DoubleFromNumber((NPNumber *)obj));
+    else if (type == NPVariantDoubleType) {
+        double aDouble;
+        if (NPN_VariantToDouble (variant, &aDouble))
+            return Number (aDouble);
+        return Number (0);
     }
-    else if (NPN_IsKindOfClass (obj, NPStringClass)) {
-
-        NPUTF8 *utf8String = NPN_UTF8FromString((NPString *)obj);
-        CFStringRef stringRef = CFStringCreateWithCString (NULL, utf8String, kCFStringEncodingUTF8);
-        NPN_DeallocateUTF8 (utf8String);
-
-        int length = CFStringGetLength (stringRef);
-        NPUTF16 *buffer = (NPUTF16 *)malloc(sizeof(NPUTF16)*length);
-
-        // Convert the string to UTF16.
-        CFRange range = { 0, length };
-        CFStringGetCharacters (stringRef, range, (UniChar *)buffer);
-        CFRelease (stringRef);
-
-        String resultString(UString((const UChar *)buffer,length));
-        free (buffer);
-        
+    else if (type == NPVariantStringType) {
+        NPUTF16 *stringValue;
+        unsigned int UTF16Length;
+        convertNPStringToUTF16 (&variant->value.stringValue, &stringValue, &UTF16Length);    // requires free() of returned memory.
+        String resultString(UString((const UChar *)stringValue,UTF16Length));
+        free (stringValue);
         return resultString;
     }
-    else if (NPN_IsKindOfClass (obj, NPScriptObjectClass)) {
-        // Get ObjectImp from NP_JavaScriptObject.
-        JavaScriptObject *o = (JavaScriptObject *)obj;
-        return Object(const_cast<ObjectImp*>(o->imp));
-    }
-    else {
-        //  Wrap NPObject in a CInstance.
-        return Instance::createRuntimeObject(Instance::CLanguage, (void *)obj);
+    else if (type == NPVariantObjectType) {
+        NPObject *obj = variant->value.objectValue;
+        
+        if (NPN_IsKindOfClass (obj, NPArrayClass)) {
+            // FIXME:  Need to implement
+        }
+     
+        else if (NPN_IsKindOfClass (obj, NPScriptObjectClass)) {
+            // Get ObjectImp from NP_JavaScriptObject.
+            JavaScriptObject *o = (JavaScriptObject *)obj;
+            return Object(const_cast<ObjectImp*>(o->imp));
+        }
+        else {
+            //  Wrap NPObject in a CInstance.
+            return Instance::createRuntimeObject(Instance::CLanguage, (void *)obj);
+        }
     }
     
     return Undefined();
index 5f704efc4a5f3713795aadadd500a3d17ac0808c..a7a52d57060f38ef451ac2d72586053656a9fdbc 100644 (file)
@@ -47,8 +47,10 @@ typedef enum
 } NP_ValueType;
 
 
-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);
+extern void convertNPStringToUTF16 (const NPString *string, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
+extern void convertUTF8ToUTF16 (const NPUTF8 *UTF8Chars, int UTF8Length, NPUTF16 **UTF16Chars, unsigned int *UTF16Length);
+extern void coerceValueToNPVariantStringType (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result);
+extern void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result);
+extern KJS::Value convertNPVariantToValue (KJS::ExecState *exec, const NPVariant *variant);
 
 #endif
index 8159a6298a5d0febecb030a7ee90c8c6595bd0fd..6d3d488b74cd3169df712ce49e2b4011381f84dc 100644 (file)
@@ -74,9 +74,9 @@ static CFMutableDictionaryRef getIdentifierDictionary()
 
 static const char **identifierNames = 0;
 static unsigned int maxIdentifierNames;
-static NPIdentifier identifierCount = 1;
+static uint32_t identifierCount = 1;
 
-NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name)
+NPIdentifier NPN_GetIdentifier (const NPUTF8 *name)
 {
     assert (name);
     
@@ -85,7 +85,7 @@ NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name)
         
         identifier = (NPIdentifier)CFDictionaryGetValue (getIdentifierDictionary(), (const void *)name);
         if (identifier == 0) {
-            identifier = identifierCount++;
+            identifier = (NPIdentifier)identifierCount++;
             // We never release identifier names, so this dictionary will grow, as will
             // the memory for the identifier name strings.
             const char *identifierName = strdup (name);
@@ -100,7 +100,7 @@ NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name)
                 identifierNames = (const char **)realloc ((void *)identifierNames, sizeof(const char *)*maxIdentifierNames);
             }
             
-            identifierNames[identifier] = identifierName;
+            identifierNames[(uint32_t)identifier] = identifierName;
 
             CFDictionaryAddValue (getIdentifierDictionary(), identifierName, (const void *)identifier);
         }
@@ -129,495 +129,310 @@ void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *iden
         int i;
         
         for (i = 0; i < nameCount; i++) {
-            identifiers[i] = NPN_IdentifierFromUTF8 (names[i]);
+            identifiers[i] = NPN_GetIdentifier (names[i]);
         }
     }
 }
 
 const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier)
 {
-    if (identifier == 0 || identifier >= identifierCount)
+    if (identifier == 0 || (uint32_t)identifier >= identifierCount)
         return NULL;
         
-    return (const NPUTF8 *)identifierNames[identifier];
+    return (const NPUTF8 *)identifierNames[(uint32_t)identifier];
 }
 
-NPObject *NPN_CreateObject (NPClass *aClass)
+NPBool NPN_VariantIsVoid (const NPVariant *variant)
 {
-    assert (aClass);
-
-    if (aClass) {
-        NPObject *obj;
-        
-        if (aClass->allocate != NULL)
-            obj = aClass->allocate ();
-        else
-            obj = (NPObject *)malloc (sizeof(NPObject));
-            
-        obj->_class = aClass;
-        obj->referenceCount = 1;
-
-        return obj;
-    }
-    
-    return 0;
+    return variant->type == NPVariantVoidType;
 }
 
-
-NPObject *NPN_RetainObject (NPObject *obj)
+NPBool NPN_VariantIsNull (const NPVariant *variant)
 {
-    assert (obj);
-
-    if (obj)
-        obj->referenceCount++;
-
-    return obj;
+    return variant->type == NPVariantNullType;
 }
 
-
-void NPN_ReleaseObject (NPObject *obj)
+NPBool NPN_VariantIsUndefined (const NPVariant *variant)
 {
-    assert (obj);
-    assert (obj->referenceCount >= 1);
-
-    if (obj && obj->referenceCount >= 1) {
-        obj->referenceCount--;
-                
-        if (obj->referenceCount == 0) {
-            if (obj->_class->deallocate)
-                obj->_class->deallocate (obj);
-            else
-                free (obj);
-        }
-    }
+    return variant->type == NPVariantUndefinedType;
 }
 
-bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass)
+NPBool NPN_VariantIsBool (const NPVariant *variant)
 {
-    assert (obj);
-    assert (aClass);
-    
-    if (obj && aClass) {
-        if (obj->_class == aClass)
-            return true;
-    }
-    
-    return false;
+    return variant->type == NPVariantBoolType;
 }
 
-
-void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length)
+NPBool NPN_VariantIsInt32 (const NPVariant *variant)
 {
-    assert (obj);
-    assert (message);
-    if (obj && message) {
-        NPString *m = NPN_CreateStringWithUTF8(message, length);
-        NPN_SetException (obj, m);
-        NPN_ReleaseObject (m);
-    }
+    return variant->type == NPVariantInt32Type;
 }
 
-
-void NPN_SetException (NPObject *obj, NPString *message)
+NPBool NPN_VariantIsDouble (const NPVariant *variant)
 {
-    // FIX ME.  Need to implement.
+    return variant->type == NPVariantDoubleType;
 }
 
-// ---------------------------------- Types ----------------------------------
-
-// ---------------------------------- NPNumber ----------------------------------
-
-typedef struct
-{
-    NPObject object;
-    double number;
-} NumberObject;
-
-static NPObject *numberAllocate()
+NPBool NPN_VariantIsString (const NPVariant *variant)
 {
-    return (NPObject *)malloc(sizeof(NumberObject));
+    return variant->type == NPVariantStringType;
 }
 
-static NPClass _numberClass = { 
-    1,
-    numberAllocate, 
-    (NPDeallocateFunctionPtr)free, 
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-};
-
-static NPClass *numberClass = &_numberClass;
-NPClass *NPNumberClass = numberClass;
-
-NPNumber *NPN_CreateNumberWithInt (int i)
+NPBool NPN_VariantIsObject (const NPVariant *variant)
 {
-    NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
-    number->number = i;
-    return (NPNumber *)number;
+    return variant->type == NPVariantObjectType;
 }
 
-NPNumber *NPN_CreateNumberWithFloat (float f)
+NPBool NPN_VariantToBool (const NPVariant *variant, NPBool *result)
 {
-    NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
-    number->number = f;
-    return (NPNumber *)number;
+    if (variant->type != NPVariantBoolType)
+        return false;
+        
+    *result = variant->value.boolValue;
+    
+    return true;
 }
 
-NPNumber *NPN_CreateNumberWithDouble (double d)
+NPString NPN_VariantToString (const NPVariant *variant)
 {
-    NumberObject *number = (NumberObject *)NPN_CreateObject (numberClass);
-    number->number = d;
-    return (NPNumber *)number;
+    if (variant->type != NPVariantStringType) {
+        NPString emptyString = { 0, 0 };
+        return emptyString;
+    }
+            
+    return variant->value.stringValue;
 }
 
-int NPN_IntFromNumber (NPNumber *obj)
+NPBool NPN_VariantToInt32 (const NPVariant *variant, int32_t *result)
 {
-    assert (obj && NPN_IsKindOfClass (obj, numberClass));
-
-    if (obj && NPN_IsKindOfClass (obj, numberClass)) {
-        NumberObject *number = (NumberObject *)obj;
-        return (int)number->number;
-    }
+    if (variant->type == NPVariantInt32Type)
+        *result = variant->value.intValue;
+    else if (variant->type != NPVariantDoubleType)
+        *result = (int32_t)variant->value.doubleValue;
+    else
+        return false;
     
-    return 0;
+    return true;
 }
 
-float NPN_FloatFromNumber (NPNumber *obj)
+NPBool NPN_VariantToDouble (const NPVariant *variant, double *result)
 {
-    assert (obj && NPN_IsKindOfClass (obj, numberClass));
-
-    if (obj && NPN_IsKindOfClass (obj, numberClass)) {
-        NumberObject *number = (NumberObject *)obj;
-        return (float)number->number;
-    }
+    if (variant->type == NPVariantInt32Type)
+        *result = (double)variant->value.intValue;
+    else if (variant->type != NPVariantDoubleType)
+        *result = variant->value.doubleValue;
+    else
+        return false;
     
-    return 0.;
+    return true;
 }
 
-double NPN_DoubleFromNumber (NPNumber *obj)
+NPBool NPN_VariantToObject (const NPVariant *variant, NPObject **result)
 {
-    assert (obj && NPN_IsKindOfClass (obj, numberClass));
-    
-    if (obj && NPN_IsKindOfClass (obj, numberClass)) {
-        NumberObject *number = (NumberObject *)obj;
-        return number->number;
-    }
+    if (variant->type != NPVariantObjectType)
+        return false;
+            
+    *result = variant->value.objectValue;
     
-    return 0.;
+    return true;
 }
 
-
-// ---------------------------------- NPString ----------------------------------
-
-typedef struct
+void NPN_InitializeVariantAsVoid (NPVariant *variant)
 {
-    NPObject object;
-    NPUTF16 *string;
-    int32_t length;
-} StringObject;
+    variant->type = NPVariantVoidType;
+}
 
-static NPObject *stringAllocate()
+void NPN_InitializeVariantAsNull (NPVariant *variant)
 {
-    return (NPObject *)malloc(sizeof(StringObject));
+    variant->type = NPVariantNullType;
 }
 
-void stringDeallocate (StringObject *string)
+void NPN_InitializeVariantAsUndefined (NPVariant *variant)
 {
-    free (string->string);
-    free (string);
+    variant->type = NPVariantUndefinedType;
 }
 
-static NPClass _stringClass = { 
-    1,
-    stringAllocate, 
-    (NPDeallocateFunctionPtr)stringDeallocate, 
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-};
-
-static NPClass *stringClass = &_stringClass;
-NPClass *NPStringClass = stringClass;
-
-#define LOCAL_CONVERSION_BUFFER_SIZE    4096
-
-NPString *NPN_CreateStringWithUTF8 (const NPUTF8 *utf8String, int32_t length)
+void NPN_InitializeVariantWithBool (NPVariant *variant, NPBool value)
 {
-    assert (utf8String);
-    
-    if (utf8String) {
-        if (length == -1)
-            length = strlen(utf8String);
-            
-        StringObject *string = (StringObject *)NPN_CreateObject (stringClass);
-
-        CFStringRef stringRef = CFStringCreateWithBytes (NULL, (const UInt8*)utf8String, (CFIndex)length, kCFStringEncodingUTF8, false);
-
-        string->length = CFStringGetLength (stringRef);
-        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 (NPString *)string;
-    }
-    
-    return 0;
+    variant->type = NPVariantBoolType;
+    variant->value.boolValue = value;
 }
 
-
-NPString *NPN_CreateStringWithUTF16 (const NPUTF16 *utf16String, int32_t len)
+void NPN_InitializeVariantWithInt32 (NPVariant *variant, int32_t value)
 {
-    assert (utf16String);
-    
-    if (utf16String) {
-        StringObject *string = (StringObject *)NPN_CreateObject (stringClass);
-
-        string->length = len;
-        string->string = (NPUTF16 *)malloc(sizeof(NPUTF16)*string->length);
-        memcpy ((void *)string->string, utf16String, sizeof(NPUTF16)*string->length);
-        
-        return (NPString *)string;
-    }
+    variant->type = NPVariantInt32Type;
+    variant->value.intValue = value;
+}
 
-    return 0;
+void NPN_InitializeVariantWithDouble (NPVariant *variant, double value)
+{
+    variant->type = NPVariantDoubleType;
+    variant->value.doubleValue = value;
 }
 
-void NPN_DeallocateUTF8 (NPUTF8 *UTF8Buffer)
+void NPN_InitializeVariantWithString (NPVariant *variant, const NPString *value)
 {
-    free (UTF8Buffer);
+    variant->type = NPVariantStringType;
+    variant->value.stringValue = *value;
 }
 
-NPUTF8 *NPN_UTF8FromString (NPString *obj)
+void NPN_InitializeVariantWithStringCopy (NPVariant *variant, const NPString *value)
 {
-    assert (obj && NPN_IsKindOfClass (obj, stringClass));
+    variant->type = NPVariantStringType;
+    variant->value.stringValue.UTF8Length = value->UTF8Length;
+    variant->value.stringValue.UTF8Characters = (NPUTF8 *)malloc(sizeof(NPUTF8) * value->UTF8Length);
+    memcpy ((void *)variant->value.stringValue.UTF8Characters, value->UTF8Characters, sizeof(NPUTF8) * value->UTF8Length);
+}
 
-    if (obj && NPN_IsKindOfClass (obj, stringClass)) {
-        StringObject *string = (StringObject *)obj;
+void NPN_InitializeVariantWithObject (NPVariant *variant, NPObject *value)
+{
+    variant->type = NPVariantObjectType;
+    variant->value.objectValue = NPN_RetainObject (value);
+}
 
-        // Allow for max conversion factor.
-        UInt8 *buffer;
-        UInt8 _localBuffer[LOCAL_CONVERSION_BUFFER_SIZE];
-        CFIndex maxBufferLength;
-        
-        if (string->length*sizeof(UInt8)*8 > LOCAL_CONVERSION_BUFFER_SIZE) {
-            maxBufferLength = string->length*sizeof(UInt8)*8;
-            buffer = (UInt8 *)malloc(maxBufferLength);
+void NPN_InitializeVariantWithVariant (NPVariant *destination, const NPVariant *source)
+{
+    switch (source->type){
+        case NPVariantVoidType: {
+            NPN_InitializeVariantAsVoid (destination);
+            break;
         }
-        else {
-            maxBufferLength = LOCAL_CONVERSION_BUFFER_SIZE;
-            buffer = _localBuffer;
+        case NPVariantNullType: {
+            NPN_InitializeVariantAsNull (destination);
+            break;
+        }
+        case NPVariantUndefinedType: {
+            NPN_InitializeVariantAsUndefined (destination);
+            break;
+        }
+        case NPVariantBoolType: {
+            NPN_InitializeVariantWithBool (destination, source->value.boolValue);
+            break;
+        }
+        case NPVariantInt32Type: {
+            NPN_InitializeVariantWithInt32 (destination, source->value.intValue);
+            break;
+        }
+        case NPVariantDoubleType: {
+            NPN_InitializeVariantWithDouble (destination, source->value.doubleValue);
+            break;
+        }
+        case NPVariantStringType: {
+            NPN_InitializeVariantWithStringCopy (destination, &source->value.stringValue);
+            break;
+        }
+        case NPVariantObjectType: {
+            NPN_InitializeVariantWithObject (destination, source->value.objectValue);
+            break;
+        }
+        default: {
+            NPN_InitializeVariantAsUndefined (destination);
+            break;
         }
-        
-        // Convert the string to UTF8.
-        CFIndex usedBufferLength;
-        CFStringRef stringRef = CFStringCreateWithCharacters (NULL, (UniChar *)string->string, string->length);
-        CFRange range = { 0, string->length };
-        CFStringGetBytes (stringRef, range, kCFStringEncodingUTF8, 0, false, buffer, maxBufferLength, &usedBufferLength);
-        
-        NPUTF8 *resultString = (NPUTF8 *)malloc (usedBufferLength+1);
-        strncpy ((char *)resultString, (const char *)buffer, usedBufferLength);
-        char *cp = (char *)resultString;
-        cp[usedBufferLength] = 0;
-        
-        CFRelease (stringRef);
-        if (buffer != _localBuffer)
-            free ((void *)buffer);
-            
-        return resultString;
     }
-    
-    return 0;
 }
 
-NPUTF16 *NPN_UTF16FromString (NPString *obj)
+void NPN_ReleaseVariantValue (NPVariant *variant)
 {
-    assert (obj && NPN_IsKindOfClass (obj, stringClass));
-
-    if (obj && NPN_IsKindOfClass (obj, stringClass)) {
-        StringObject *string = (StringObject *)obj;
-        
-        NPUTF16 *resultString = (NPUTF16*)malloc(sizeof(int16_t)*string->length);
-        memcpy ((void *)resultString, string->string, sizeof(int16_t)*string->length);
-
-        return resultString;
+    assert (variant);
+    
+    if (variant->type == NPVariantObjectType) {
+        NPN_ReleaseObject (variant->value.objectValue);
+        variant->value.objectValue = 0;
+    }
+    else if (variant->type == NPVariantStringType) {
+        free ((void *)variant->value.stringValue.UTF8Characters);
+        variant->value.stringValue.UTF8Characters = 0;
+        variant->value.stringValue.UTF8Length = 0;
     }
     
-    return 0;
+    variant->type = NPVariantUndefinedType;
 }
 
-int32_t NPN_StringLength (NPString *obj)
+
+NPObject *NPN_CreateObject (NPClass *aClass)
 {
-    assert (obj && NPN_IsKindOfClass (obj, stringClass));
+    assert (aClass);
+
+    if (aClass) {
+        NPObject *obj;
+        
+        if (aClass->allocate != NULL)
+            obj = aClass->allocate ();
+        else
+            obj = (NPObject *)malloc (sizeof(NPObject));
+            
+        obj->_class = aClass;
+        obj->referenceCount = 1;
 
-    if (obj && NPN_IsKindOfClass (obj, stringClass)) {
-        StringObject *string = (StringObject *)obj;
-        return string->length;
+        return obj;
     }
     
     return 0;
 }
 
-// ---------------------------------- NP_Boolean ----------------------------------
 
-typedef struct
+NPObject *NPN_RetainObject (NPObject *obj)
 {
-    NPObject object;
-} BooleanObject;
+    assert (obj);
 
-static NPObject *booleanAllocate()
-{
-    return (NPObject *)malloc(sizeof(BooleanObject));
-}
+    if (obj)
+        obj->referenceCount++;
 
-static void booleanDeallocate (BooleanObject *string)
-{
-    // Do nothing, single true and false instances.
+    return obj;
 }
 
-static NPClass _booleanClass = { 
-    1,
-    booleanAllocate, 
-    (NPDeallocateFunctionPtr)booleanDeallocate, 
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-};
-
-static BooleanObject *theTrueObject = 0;
-static BooleanObject *theFalseObject = 0;
-
-static NPClass *booleanClass = &_booleanClass;
-NPClass *NPBooleanClass = booleanClass;
 
-NPBoolean *NPN_CreateBoolean (bool f)
+void NPN_ReleaseObject (NPObject *obj)
 {
-    if (f) {
-        if (!theTrueObject) {
-            theTrueObject = (BooleanObject *)NPN_CreateObject (booleanClass);
-        }
-        return (NPBoolean *)theTrueObject;
-    }
+    assert (obj);
+    assert (obj->referenceCount >= 1);
 
-    // False
-    if (!theFalseObject) {
-        theFalseObject = (BooleanObject *)NPN_CreateObject (booleanClass);
+    if (obj && obj->referenceCount >= 1) {
+        obj->referenceCount--;
+                
+        if (obj->referenceCount == 0) {
+            if (obj->_class->deallocate)
+                obj->_class->deallocate (obj);
+            else
+                free (obj);
+        }
     }
-    return (NPBoolean *)theFalseObject;
 }
 
-bool NPN_BoolFromBoolean (NPBoolean *obj)
+bool NPN_IsKindOfClass (const NPObject *obj, const NPClass *aClass)
 {
-    assert (obj && NPN_IsKindOfClass (obj, booleanClass) 
-            && ((BooleanObject *)obj == theTrueObject || (BooleanObject *)obj == theFalseObject));
-
-    if (obj && NPN_IsKindOfClass (obj, booleanClass) 
-            && ((BooleanObject *)obj == theTrueObject || (BooleanObject *)obj == theFalseObject)) {
-        BooleanObject *booleanObj = (BooleanObject *)obj;
-        if (booleanObj == theTrueObject)
+    assert (obj);
+    assert (aClass);
+    
+    if (obj && aClass) {
+        if (obj->_class == aClass)
             return true;
     }
     
     return false;
 }
 
-// ---------------------------------- NP_Null ----------------------------------
-
-typedef struct
-{
-    NPObject object;
-} NullObject;
-
-static NPObject *nullAllocate()
-{
-    return (NPObject *)malloc(sizeof(NullObject));
-}
-
-static void nullDeallocate (StringObject *string)
-{
-    // Do nothing, the null object is a singleton.
-}
-
-
-static NullObject *theNullObject = 0;
-
-static NPClass _nullClass = { 
-    1,
-    nullAllocate, 
-    (NPDeallocateFunctionPtr)nullDeallocate, 
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-};
-
-static NPClass *nullClass = &_nullClass;
-NPClass *NPNullClass = nullClass;
 
-NPNull *NPN_GetNull()
+void NPN_SetExceptionWithUTF8 (NPObject *obj, const NPUTF8 *message, int32_t length)
 {
-    if (!theNullObject)
-        theNullObject = (NullObject *)NPN_CreateObject(nullClass);
-    return (NPNull *)theNullObject;
+    assert (obj);
+    assert (message);
+    if (obj && message) {
+        NPString string;
+        string.UTF8Characters = message;
+        string.UTF8Length = length;
+        NPN_SetException (obj, &string);
+    }
 }
 
 
-// ---------------------------------- NP_Undefined ----------------------------------
-
-typedef struct
-{
-    NPObject object;
-} UndefinedObject;
-
-static NPObject *undefinedAllocate()
-{
-    return (NPObject *)malloc(sizeof(UndefinedObject));
-}
-
-static void undefinedDeallocate (StringObject *string)
+void NPN_SetException (NPObject *obj, NPString *message)
 {
-    // Do nothing, the null object is a singleton.
+    // FIX ME.  Need to implement.
 }
 
-
-static NullObject *theUndefinedObject = 0;
-
-static NPClass _undefinedClass = { 
-    1,
-    undefinedAllocate, 
-    (NPDeallocateFunctionPtr)undefinedDeallocate, 
-    0,
-    0,
-    0,
-    0,
-    0,
-    0,
-};
-
-static NPClass *undefinedClass = &_undefinedClass;
-NPClass *NPUndefinedClass = undefinedClass;
-
-NPUndefined *NPN_GetUndefined()
-{
-    if (!theUndefinedObject)
-        theUndefinedObject = (NullObject *)NPN_CreateObject(undefinedClass);
-    return (NPUndefined *)theUndefinedObject;
-}
+// ---------------------------------- Types ----------------------------------
 
 // ---------------------------------- NP_Array ----------------------------------
 
index 12e311b74908fee14a1106fd81e83dfe71abf486..e82b38d23edd1984745fb558e82b7b35e56dad50 100644 (file)
  * type names.
  * Renamed "JavaScript" types to "Script".
  *
+ * Revision 7 (April 21, 2004):
+ * NPIdentifier becomes a void*, was int32_t
+ * Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier
+ * Added NPVariant and modified functions to use this new type.
  */
 #ifndef _NP_RUNTIME_H_
 #define _NP_RUNTIME_H_
@@ -93,38 +97,122 @@ typedef struct NPClass NPClass;
 */
 typedef NPObject NPScriptObject;
 
+typedef char NPUTF8;
+typedef struct _NPString {
+    const NPUTF8 *UTF8Characters;
+    uint32_t UTF8Length;
+} NPString;
+
+typedef unsigned char NPBool;
+  
+typedef enum {
+    NPVariantVoidType,
+    NPVariantNullType,
+    NPVariantUndefinedType,
+    NPVariantBoolType,
+    NPVariantInt32Type,
+    NPVariantDoubleType,
+    NPVariantStringType,
+    NPVariantObjectType
+} NPVariantType;
+
+typedef struct _NPVariant {
+    NPVariantType type;
+    union {
+        NPBool boolValue;
+        int32_t intValue;
+        double doubleValue;
+        NPString stringValue;
+        NPObject *objectValue;
+    } value;
+} NPVariant;
+
 /*
-       Type mappings (JavaScript types have been used for illustration
-    purposes):
+    NPN_ReleaseVariantValue is called on all 'out' parameters references.
+    Specifically it is called on variants that are resultant out parameters
+    in NPGetPropertyFunctionPtr and NPInvokeFunctionPtr.  Resultant variants
+    from these two functions should be initialized using the
+    NPN_InitializeVariantXXX() functions.
+    
+    After calling NPReleaseVariantValue, the type of the variant will
+    be set to NPVariantUndefinedType.
+*/
+void NPN_ReleaseVariantValue (NPVariant *variant);
+
+NPBool NPN_VariantIsVoid (const NPVariant *variant);
+NPBool NPN_VariantIsNull (const NPVariant *variant);
+NPBool NPN_VariantIsUndefined (const NPVariant *variant);
+NPBool NPN_VariantIsBool (const NPVariant *variant);
+NPBool NPN_VariantIsInt32 (const NPVariant *variant);
+NPBool NPN_VariantIsDouble (const NPVariant *variant);
+NPBool NPN_VariantIsString (const NPVariant *variant);
+NPBool NPN_VariantIsObject (const NPVariant *variant);
+NPBool NPN_VariantToBool (const NPVariant *variant, NPBool *result);
+NPBool NPN_VariantToInt32 (const NPVariant *variant, int32_t *result);
+NPBool NPN_VariantToDouble (const NPVariant *variant, double *result);
+NPString NPN_VariantToString (const NPVariant *variant);
+NPString NPN_VariantToStringCopy (const NPVariant *variant);
+NPBool NPN_VariantToObject (const NPVariant *variant, NPObject **result);
 
-       script    to             C
-       Boolean                  NPBoolean      
-       Number                   NPNumber
-       String                   NPString
-       Undefined                NPUndefined
-       Null                     NPNull
-       Object (including Array) NPScriptObject
-       Object wrapper           NPObject
-
-
-       C          to            script
-       NPBoolean                Boolean        
-       NPNumber                 Number
-       NPString                 String
-       NPUndefined              Undefined
-       NPNull                   Null
-       NPArray                  Array (restricted)
-       NPScriptObject           Object
-       other NPObject           Object wrapper
+/*
+    NPVariants initialized with the NPN_InitializeVariantXXX() functions
+    must be released using the NPN_ReleaseVariantValue() function.
+*/
+void NPN_InitializeVariantAsVoid (NPVariant *variant);
+void NPN_InitializeVariantAsNull (NPVariant *variant);
+void NPN_InitializeVariantAsUndefined (NPVariant *variant);
+void NPN_InitializeVariantWithBool (NPVariant *variant, NPBool value);
+void NPN_InitializeVariantWithInt32 (NPVariant *variant, int32_t value);
+void NPN_InitializeVariantWithDouble (NPVariant *variant, double value);
 
+/*
+    NPN_InitializeVariantWithString() does not copy string data.  However
+    the string data will be deallocated by calls to NPReleaseVariantValue().
 */
+void NPN_InitializeVariantWithString (NPVariant *variant, const NPString *value);
 
-typedef uint32_t NPIdentifier;
+/*
+    NPN_InitializeVariantWithStringCopy() will copy string data.  The string data
+    will be deallocated by calls to NPReleaseVariantValue().
+*/
+void NPN_InitializeVariantWithStringCopy (NPVariant *variant, const NPString *value);
 
 /*
-    NPUTF8 strings are null terminated.
+    NPN_InitializeVariantWithObject() retains the NPObject.  The object will be released
+    by calls to NPReleaseVariantValue();
 */
-typedef char NPUTF8;
+void NPN_InitializeVariantWithObject (NPVariant *variant, NPObject *value);
+
+void NPN_InitializeVariantWithVariant (NPVariant *destination, const NPVariant *source);
+
+/*
+       Type mappings (JavaScript types have been used for illustration
+    purposes):
+
+       script    to                C
+       Boolean                     NPVariant (with type NPVariantBoolType) 
+       Number                      NPVariant (with type NPVariantDoubleType)
+       String                      NPVariant (with type NPVariantStringType)
+       Undefined                   NPVariant (with type NPVariantUndefinedType)
+       Null                        NPVariant (with type NPVariantNullType)
+       Object (including Array)    NPVariant (with type NPVariantObjectType, objectValue will be a NPScriptObject)
+       Object (NPObject wrapper)   NPVariant (with type NPVariantObjectType)
+
+
+       C          to                                         script
+       NPVariant (with type NPVariantBoolType)               Boolean   
+       NPVariant (with type NPVariantInt32Type)              Number
+       NPVariant (with type NPVariantDoubleType)             Number
+       NPVariant (with type NPVariantStringType)             String
+       NPVariant (with type NPVariantUndefinedType)          Undefined
+       NPVariant (with type NPVariantNullType)               Null
+       NPArray                                               Array (restricted)
+       NPScriptObject                                        Object
+       other NPObject                                        Object (NPObject wrapper)
+
+*/
+
+typedef void *NPIdentifier;
 
 /*
     NPObjects have methods and properties.  Methods and properties are named with NPIdentifiers.
@@ -133,8 +221,7 @@ typedef char NPUTF8;
     NPN_IsValidIdentifier will return true if an identifier for the name has already been
     assigned with either NPIdentifierFromUTF8() or NPN_GetIdentifiers();
 */
-NPIdentifier NPN_IdentifierFromUTF8 (const NPUTF8 *name);
-bool NPN_IsValidIdentifier (const NPUTF8 *name);
+NPIdentifier NPN_GetIdentifier (const NPUTF8 *name);
 void NPN_GetIdentifiers (const NPUTF8 **names, int nameCount, NPIdentifier *identifiers);
 
 /*
@@ -144,15 +231,19 @@ const NPUTF8 *NPN_UTF8FromIdentifier (NPIdentifier identifier);
 
 /*
     NPObject behavior is implemented using the following set of callback functions.
+    
+    The NPVariant *result parameter of NPInvokeFunctionPtr and NPGetPropertyFunctionPtr functions
+    should be initialized using one of the NPN_InitializeVariantXXX functions.  The variant result
+    of the two functions will be released using NPN_ReleaseVariantValue().
 */
 typedef NPObject *(*NPAllocateFunctionPtr)();
 typedef void (*NPDeallocateFunctionPtr)(NPObject *obj);
-typedef void (*NPInvalidateFunctionPtr)();
+typedef void (*NPInvalidateFunctionPtr)(NPObject *obj);
 typedef bool (*NPHasMethodFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef NPObject *(*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, NPObject **args, unsigned argCount);
+typedef void (*NPInvokeFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result);
 typedef bool (*NPHasPropertyFunctionPtr)(NPClass *theClass, NPIdentifier name);
-typedef NPObject *(*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name);
-typedef void (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPObject *value);
+typedef void (*NPGetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, NPVariant *result);
+typedef void (*NPSetPropertyFunctionPtr)(NPObject *obj, NPIdentifier name, const NPVariant *value);
 
 /*
     NPObjects returned by create, retain, invoke, and getProperty 
@@ -214,20 +305,10 @@ void NPN_ReleaseObject (NPObject *obj);
 /*
     Built-in data types.  These classes can be passed to NPN_IsKindOfClass().
 */
-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 script objects represented by NPScriptObject.
@@ -240,53 +321,16 @@ typedef NPObject NPString;
     Calls made from script to the plugin will always be made on the main
     user agent thread, this include calls to NPScriptResultFunctionPtr callbacks.
 */
-typedef void (*NPScriptResultFunctionPtr)(NPObject *obj, void *resultContext);
+typedef void (*NPScriptResultFunctionPtr)(const NPVariant *result, void *resultContext);
 
-void NPN_Call (NPScriptObject *obj, NPIdentifier methodName, NPObject **args, unsigned argCount, NPScriptResultFunctionPtr resultCallback);
+void NPN_Call (NPScriptObject *obj, NPIdentifier methodName, const NPVariant *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_SetProperty (NPScriptObject *obj, NPIdentifier  propertyName, const NPVariant *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.
-*/
-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);
-
-/*
-    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 NPUTF8FromString must be deallocated
-    by calling NPN_DeallocateUTF8.
-*/
-NPUTF8 *NPN_UTF8FromString (NPString *obj);
-void NPN_DeallocateUTF8 (NPUTF8 *UTF8Buffer);
-int32_t NPN_StringLength (NPString *obj);
-
-NPBoolean *NPN_CreateBoolean (bool f);
-bool NPN_BoolFromBoolean (NPBoolean *aBool);
-
-/*
-    NPNull returns a NPNull singleton.
-*/
-NPNull *NPN_GetNull();
-
-/*
-    NPUndefined returns a NPUndefined singleton.
-*/
-NPUndefined *NPN_GetUndefined ();
+void NPN_SetPropertyAtIndex (NPScriptObject *obj, unsigned index, const NPVariant *value);
 
 /*
     NPArrays are immutable.  They are used to pass arguments to 
@@ -297,7 +341,7 @@ NPUndefined *NPN_GetUndefined ();
     
     Objects added to arrays are retained by the array.
 */
-NPArray *NPN_CreateArray (NPObject **, int32_t count);
+NPArray *NPN_CreateArray (NPVariant **, int32_t count);
 NPArray *NPN_CreateArrayV (int32_t count, ...);
 
 /*
index 6b6128f2d5a1c457d6d3b0f2a1fb4b3c447c4b94..5c2764ca0a5b0192a817732e73354dcc6b97528c 100644 (file)
@@ -46,7 +46,7 @@ typedef struct
        NPObject object;
        double doubleValue;
        int intValue;
-       const char *stringValue;
+       NPVariant stringValue;
        bool boolValue;
 } MyObject;
 
@@ -123,160 +123,143 @@ bool myHasMethod (NPClass *theClass, NPIdentifier name)
        return false;
 }
 
-NPObject *myGetProperty (MyObject *obj, NPIdentifier name)
+
+void logMessage (const NPVariant *message)
 {
-       if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
-               return NPN_CreateNumberWithDouble (obj->doubleValue); 
-       }
-       else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
-               return NPN_CreateNumberWithInt (obj->intValue); 
-       }
-       else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
-               return NPN_CreateStringWithUTF8 (obj->stringValue, -1);
-       }
-       else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
-               return NPN_CreateBoolean (obj->boolValue);
-       }
-       else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
-               return NPN_GetNull ();
-       }
-       else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
-               return NPN_GetUndefined (); 
-       }
-       
-       return NPN_GetUndefined();
+       printf ("%s\n", message->value.stringValue.UTF8Characters);
 }
 
-void mySetProperty (MyObject *obj, NPIdentifier name, NPObject *value)
+void setDoubleValue (MyObject *obj, const NPVariant *variant)
 {
-       if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
-               if (NPN_IsKindOfClass (value, NPNumberClass)) {
-                       obj->doubleValue = NPN_DoubleFromNumber (value); 
-               }
-               else {
-                       NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a double value with a non-number type.", -1);
-               }
-       }
-       else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
-               if (NPN_IsKindOfClass (value, NPNumberClass)) {
-                       obj->intValue = NPN_IntFromNumber (value); 
-               }
-               else {
-                       NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a int value with a non-number type.", -1);
-               }
-       }
-       else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
-               if (NPN_IsKindOfClass (value, NPStringClass)) {
-                       if (obj->stringValue)
-                               free((void *)obj->stringValue);
-                       obj->stringValue = NPN_UTF8FromString (value);
-               }
-               else {
-                       NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a string value with a non-string type.", -1);
-               }
-       }
-       else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
-               if (NPN_IsKindOfClass (value, NPStringClass)) {
-                       obj->boolValue = NPN_BoolFromBoolean (value);
-               }
-               else {
-                       NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set a bool value with a non-boolean type.", -1);
-               }
-       }
-       else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
-               // Do nothing!
-       }
-       else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) {
-               // Do nothing!
-       }
+       if (!NPN_VariantToDouble (variant, &obj->doubleValue))
+               NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set double value with invalid type.", -1);
 }
 
-void logMessage (NPString *message)
+void setIntValue (MyObject *obj, const NPVariant *variant)
 {
-       printf ("%s\n", NPN_UTF8FromString (message));
+       if (!NPN_VariantToInt32 (variant, &obj->intValue))
+               NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set int value with invalid type.", -1);
 }
 
-void setDoubleValue (MyObject *obj, NPNumber *number)
+void setStringValue (MyObject *obj, const NPVariant *variant)
 {
-       obj->doubleValue = NPN_DoubleFromNumber (number);
+       NPN_ReleaseVariantValue (&obj->stringValue);
+       NPN_InitializeVariantWithVariant (&obj->stringValue, variant);
 }
 
-void setIntValue (MyObject *obj, NPNumber *number)
+void setBooleanValue (MyObject *obj, const NPVariant *variant)
 {
-       obj->intValue = NPN_IntFromNumber (number);
+       if (!NPN_VariantToBool (variant, (NPBool *)&obj->boolValue))
+               NPN_SetExceptionWithUTF8 ((NPObject *)obj, "Attempt to set bool value with invalid type.", -1);
 }
 
-void setStringValue (MyObject *obj, NPString *string)
+void getDoubleValue (MyObject *obj, NPVariant *variant)
 {
-       NPN_DeallocateUTF8 ((NPUTF8 *)obj->stringValue);
-       obj->stringValue = NPN_UTF8FromString (string);
+       NPN_InitializeVariantWithDouble (variant, obj->doubleValue);
 }
 
-void setBooleanValue (MyObject *obj, NPBoolean *boolean)
+void getIntValue (MyObject *obj, NPVariant *variant)
 {
-       obj->boolValue = NPN_BoolFromBoolean (boolean);
+       NPN_InitializeVariantWithInt32 (variant, obj->intValue);
 }
 
-NPNumber *getDoubleValue (MyObject *obj)
+void getStringValue (MyObject *obj, NPVariant *variant)
 {
-       return NPN_CreateNumberWithDouble (obj->doubleValue);
+       NPN_InitializeVariantWithVariant (variant, &obj->stringValue);
 }
 
-NPNumber *getIntValue (MyObject *obj)
+void getBooleanValue (MyObject *obj, NPVariant *variant)
 {
-       return NPN_CreateNumberWithInt (obj->intValue);
+       NPN_InitializeVariantWithBool (variant, obj->boolValue);
 }
 
-NPString *getStringValue (MyObject *obj)
+void myGetProperty (MyObject *obj, NPIdentifier name, NPVariant *variant)
 {
-       return NPN_CreateStringWithUTF8 (obj->stringValue, -1);
+       if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]){
+               getDoubleValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_INT_VALUE]){
+               getIntValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_STRING_VALUE]){
+               getStringValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]){
+               getBooleanValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_NULL_VALUE]){
+               return NPN_InitializeVariantAsNull (variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]){
+               return NPN_InitializeVariantAsUndefined (variant); 
+       }
+       else
+               NPN_InitializeVariantAsUndefined(variant);
 }
 
-NPBoolean *getBooleanValue (MyObject *obj)
+void mySetProperty (MyObject *obj, NPIdentifier name, const NPVariant *variant)
 {
-       return NPN_CreateBoolean (obj->boolValue);
+       if (name == myPropertyIdentifiers[ID_DOUBLE_VALUE]) {
+               setDoubleValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_INT_VALUE]) {
+               setIntValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_STRING_VALUE]) {
+               setStringValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_BOOLEAN_VALUE]) {
+               setBooleanValue (obj, variant);
+       }
+       else if (name == myPropertyIdentifiers[ID_NULL_VALUE]) {
+               // Do nothing!
+       }
+       else if (name == myPropertyIdentifiers[ID_UNDEFINED_VALUE]) {
+               // Do nothing!
+       }
 }
 
-NPObject *myInvoke (MyObject *obj, NPIdentifier name, NPObject **args, unsigned argCount)
+void myInvoke (MyObject *obj, NPIdentifier name, NPVariant *args, unsigned argCount, NPVariant *result)
 {
        if (name == myMethodIdentifiers[ID_LOG_MESSAGE]) {
-               if (argCount == 1 && NPN_IsKindOfClass (args[0], NPStringClass))
-                       logMessage ((NPString *)args[0]);
-               return 0;
+               if (argCount == 1 && NPN_VariantIsString(&args[0]))
+                       logMessage (&args[0]);
+               NPN_InitializeVariantAsVoid (result);
        }
        else if (name == myMethodIdentifiers[ID_SET_DOUBLE_VALUE]) {
-               if (argCount == 1 && NPN_IsKindOfClass (args[0], NPNumberClass))
-                       setDoubleValue (obj, (NPNumber *)args[0]);
-               return 0;
+               if (argCount == 1 && NPN_VariantIsDouble (&args[0]))
+                       setDoubleValue (obj, &args[0]);
+               NPN_InitializeVariantAsVoid (result);
        }
        else if (name == myMethodIdentifiers[ID_SET_INT_VALUE]) {
-               if (argCount == 1 && NPN_IsKindOfClass (args[0], NPNumberClass))
-                       setIntValue (obj, (NPNumber *)args[0]);
-               return 0;
+               if (argCount == 1 && (NPN_VariantIsDouble (&args[0]) || NPN_VariantIsInt32 (&args[0])))
+                       setIntValue (obj, &args[0]);
+               NPN_InitializeVariantAsVoid (result);
        }
        else if (name == myMethodIdentifiers[ID_SET_STRING_VALUE]) {
-               if (argCount == 1 && NPN_IsKindOfClass (args[0], NPStringClass))
-                       setStringValue (obj, (NPString *)args[0]);
-               return 0;
+               if (argCount == 1 && NPN_VariantIsString (&args[0]))
+                       setStringValue (obj, &args[0]);
+               NPN_InitializeVariantAsVoid (result);
        }
        else if (name == myMethodIdentifiers[ID_SET_BOOLEAN_VALUE]) {
-               if (argCount == 1 && NPN_IsKindOfClass (args[0], NPBooleanClass))
-                       setBooleanValue (obj, (NPBoolean *)args[0]);
-               return 0;
+               if (argCount == 1 && NPN_VariantIsBool (&args[0]))
+                       setBooleanValue (obj, &args[0]);
+               NPN_InitializeVariantAsVoid (result);
        }
        else if (name == myMethodIdentifiers[ID_GET_DOUBLE_VALUE]) {
-               return getDoubleValue (obj);
+               getDoubleValue (obj, result);
        }
        else if (name == myMethodIdentifiers[ID_GET_INT_VALUE]) {
-               return getIntValue (obj);
+               getIntValue (obj, result);
        }
        else if (name == myMethodIdentifiers[ID_GET_STRING_VALUE]) {
-               return getStringValue (obj);
+               getStringValue (obj, result);
        }
        else if (name == myMethodIdentifiers[ID_GET_BOOLEAN_VALUE]) {
-               return getBooleanValue (obj);
+               getBooleanValue (obj, result);
        }
-       return NPN_GetUndefined();
+       else 
+               NPN_InitializeVariantAsUndefined (result);
 }
 
 NPObject *myAllocate ()
@@ -292,7 +275,8 @@ NPObject *myAllocate ()
        newInstance->doubleValue = 666.666;
        newInstance->intValue = 1234;
        newInstance->boolValue = true;
-       newInstance->stringValue = strdup("Hello world");
+       newInstance->stringValue.value.stringValue.UTF8Length = strlen ("Hello world");
+       newInstance->stringValue.value.stringValue.UTF8Characters = strdup ("Hello world");
        
        return (NPObject *)newInstance;
 }