[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:27:02 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit fcc7819e344b1f0da151028a651807c468e7ca9a
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 18 01:56:51 2004 +0000

    	Added String <-> NSString conversion.
    	Added tests of String <-> NSString conversion to test program.
    
            Reviewed by Chris.
    
            * bindings/objc/objc_utility.mm:
            (KJS::Bindings::convertValueToObjcValue):
            (KJS::Bindings::convertObjcValueToValue):
            * bindings/test.js:
            * bindings/testbindings.mm:
            (-[MyFirstInterface getString]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 41442b5..fb287d2 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,17 @@
+2004-02-17  Richard Williamson   <rjw at apple.com>
+
+	Added String <-> NSString conversion.
+	Added tests of String <-> NSString conversion to test program.
+
+        Reviewed by Chris.
+
+        * bindings/objc/objc_utility.mm:
+        (KJS::Bindings::convertValueToObjcValue):
+        (KJS::Bindings::convertObjcValueToValue):
+        * bindings/test.js:
+        * bindings/testbindings.mm:
+        (-[MyFirstInterface getString]):
+
 2004-02-15  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
diff --git a/JavaScriptCore/bindings/objc/objc_utility.mm b/JavaScriptCore/bindings/objc/objc_utility.mm
index 4c0d776..250698b 100644
--- a/JavaScriptCore/bindings/objc/objc_utility.mm
+++ b/JavaScriptCore/bindings/objc/objc_utility.mm
@@ -22,10 +22,15 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
+#include <Foundation/Foundation.h>
+
+#include <JavascriptCore/internal.h>
+
 #include <runtime_object.h>
 #include <objc_instance.h>
 #include <objc_utility.h>
 
+
 using namespace KJS;
 using namespace KJS::Bindings;
 
@@ -105,7 +110,14 @@ ObjcValue KJS::Bindings::convertValueToObjcValue (KJS::ExecState *exec, KJS::Val
                 }
             }
             
-            // FIXME:  Deal with String to NSString conversion.
+            // Convert JavaScript String value to NSString?
+            else if (value.type() == KJS::StringType) {
+                KJS::StringImp *s = static_cast<KJS::StringImp*>(value.imp());
+                UString u = s->value();
+                
+                NSString *string = [NSString stringWithCharacters:(const unichar*)u.data() length:u.size()];
+                result.objectValue = string;
+            }
             
             // FIXME:  Deal with other Object types by creating a JavaScriptObjects
         }
@@ -182,11 +194,23 @@ Value KJS::Bindings::convertObjcValueToValue (KJS::ExecState *exec, void *buffer
         case ObjcObjectType:
             {
                 ObjectStructPtr *obj = (ObjectStructPtr *)buffer;
-                aValue = Object(new RuntimeObjectImp(new ObjcInstance (*obj)));
                 
-                // FIXME:  Deal with NSString to String conversions.
-                
-                // FIXME:  Deal with NSArray to Array conversions.
+                if ([*obj isKindOfClass:[NSString class]]){
+                    NSString *string = (NSString *)*obj;
+                    unichar *chars;
+                    unsigned int length = [string length];
+                    chars = (unichar *)malloc(sizeof(unichar)*length);
+                    [string getCharacters:chars];
+                    UString u((const KJS::UChar*)chars, length);
+                    aValue = String (u);
+                    free((void *)chars);
+                }
+                else if ([*obj isKindOfClass:[NSArray class]]) {
+                    // FIXME:  Deal with NSArray to Array conversions.
+                }
+                else {
+                    aValue = Object(new RuntimeObjectImp(new ObjcInstance (*obj)));
+                }
             }
             break;
         case ObjcCharType:
diff --git a/JavaScriptCore/bindings/test.js b/JavaScriptCore/bindings/test.js
index 89a6c8e..e1075e0 100644
--- a/JavaScriptCore/bindings/test.js
+++ b/JavaScriptCore/bindings/test.js
@@ -4,6 +4,7 @@ myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt());
 
 myInterface.logMessage ("myInterface.setInt_(666) = " + myInterface.setInt_(666));
 myInterface.logMessage ("myInterface.getInt() = " + myInterface.getInt());
+myInterface.logMessage ("myInterface.getString() = " + myInterface.getString());
 myInterface.logMessage ("myInterface.myInt = " + myInterface.myInt);
 myInterface.logMessage ("setting myInterface.myInt = 777");
 myInterface.myInt = 777;
diff --git a/JavaScriptCore/bindings/testbindings.mm b/JavaScriptCore/bindings/testbindings.mm
index 8c4d298..7d13bea 100644
--- a/JavaScriptCore/bindings/testbindings.mm
+++ b/JavaScriptCore/bindings/testbindings.mm
@@ -106,6 +106,11 @@
     myInt = anInt;
 }
 
+- (NSString *)getString
+{
+	return @"This is a string from ObjC";
+}
+
 - (MySecondInterface *)getMySecondInterface 
 {
     LOG ("\n");

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list