Changeset 6086 in webkit


Ignore:
Timestamp:
Feb 13, 2004 2:39:36 PM (20 years ago)
Author:
rjw
Message:

rk towards the JavaScript ObjC bindings. The bindings now work for

simple scalar types. testbindings.mm is an illustration of how the
bindings work.

Reviewed by Ken.

  • JavaScriptCore.pbproj/project.pbxproj:
  • Makefile.am:
  • bindings/jni/jni_class.cpp: (JavaClass::methodsNamed):
  • bindings/jni/jni_class.h:
  • bindings/jni/jni_instance.cpp: (JavaInstance::invokeMethod):
  • bindings/jni/jni_instance.h:
  • bindings/jni/jni_runtime.h: (KJS::Bindings::JavaMethod::returnType):
  • bindings/make_testbindings: Added.
  • bindings/objc/objc_class.h: Added. (KJS::Bindings::ObjcClass::~ObjcClass): (KJS::Bindings::ObjcClass::ObjcClass): (KJS::Bindings::ObjcClass::operator=): (KJS::Bindings::ObjcClass::constructorAt): (KJS::Bindings::ObjcClass::numConstructors):
  • bindings/objc/objc_class.mm: Added. (ObjcClass::_commonDelete): (ObjcClass::_commonCopy): (ObjcClass::_commonInit): (_createClassesByIsAIfNecessary): (ObjcClass::classForIsA): (ObjcClass::ObjcClass): (ObjcClass::name): (ObjcClass::methodsNamed): (ObjcClass::fieldNamed):
  • bindings/objc/objc_header.h: Added.
  • bindings/objc/objc_instance.h: Added. (KJS::Bindings::ObjcInstance::getObject):
  • bindings/objc/objc_instance.mm: Added. (ObjcInstance::ObjcInstance): (ObjcInstance::~ObjcInstance): (ObjcInstance::operator=): (ObjcInstance::begin): (ObjcInstance::end): (ObjcInstance::getClass): (ObjcInstance::invokeMethod): (ObjcInstance::defaultValue): (ObjcInstance::stringValue): (ObjcInstance::numberValue): (ObjcInstance::booleanValue): (ObjcInstance::valueOf):
  • bindings/objc/objc_jsobject.h: Added.
  • bindings/objc/objc_jsobject.mm: Added.
  • bindings/objc/objc_runtime.h: (KJS::Bindings::ObjcField::~ObjcField): (KJS::Bindings::ObjcField::ObjcField): (KJS::Bindings::ObjcField::operator=): (KJS::Bindings::ObjcMethod::ObjcMethod): (KJS::Bindings::ObjcMethod::~ObjcMethod): (KJS::Bindings::ObjcMethod::operator=):
  • bindings/objc/objc_runtime.mm: Added. (ObjcMethod::ObjcMethod): (ObjcMethod::name): (ObjcMethod::numParameters): (ObjcMethod::getMethodSignature): (ObjcField::ObjcField): (ObjcField::name): (ObjcField::type): (ObjcField::valueFromInstance): (ObjcField::setValueToInstance):
  • bindings/objc/objc_utility.h: Added. (KJS::Bindings::):
  • bindings/objc/objc_utility.mm: Added. (KJS::Bindings::JSMethodNameToObjCMethodName): (KJS::Bindings::convertValueToObjcValue): (KJS::Bindings::convertObjcValueToValue): (KJS::Bindings::objcValueTypeForType):
  • bindings/runtime.cpp: (MethodList::MethodList): (MethodList::operator=): (Instance::setValueOfField): (Instance::createBindingForLanguageInstance): (Instance::createRuntimeObject):
  • bindings/runtime.h:
  • bindings/runtime_method.cpp: (RuntimeMethodImp::RuntimeMethodImp): (RuntimeMethodImp::get): (RuntimeMethodImp::call):
  • bindings/runtime_method.h:
  • bindings/runtime_object.cpp: (RuntimeObjectImp::get): (RuntimeObjectImp::hasProperty):
  • bindings/test.js: Added.
  • bindings/testbindings.mm: Added. (-[MySecondInterface init]): (-[MyFirstInterface init]): (-[MyFirstInterface dealloc]): (+[MyFirstInterface JavaScriptNameForSelector:]): (-[MyFirstInterface getInt]): (-[MyFirstInterface setInt:]): (-[MyFirstInterface getMySecondInterface]): (-[MyFirstInterface logMessage:]): (GlobalImp::className): (readJavaScriptFromFile): (main):
Location:
trunk/JavaScriptCore
Files:
13 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r6083 r6086  
     12004-02-13  Richard Williamson   <rjw@apple.com>
     2
     3        Work towards the JavaScript ObjC bindings.  The bindings now work for
     4        simple scalar types.  testbindings.mm is an illustration of how the
     5        bindings work.
     6
     7        Reviewed by Ken.
     8
     9        * JavaScriptCore.pbproj/project.pbxproj:
     10        * Makefile.am:
     11        * bindings/jni/jni_class.cpp:
     12        (JavaClass::methodsNamed):
     13        * bindings/jni/jni_class.h:
     14        * bindings/jni/jni_instance.cpp:
     15        (JavaInstance::invokeMethod):
     16        * bindings/jni/jni_instance.h:
     17        * bindings/jni/jni_runtime.h:
     18        (KJS::Bindings::JavaMethod::returnType):
     19        * bindings/make_testbindings: Added.
     20        * bindings/objc/objc_class.h: Added.
     21        (KJS::Bindings::ObjcClass::~ObjcClass):
     22        (KJS::Bindings::ObjcClass::ObjcClass):
     23        (KJS::Bindings::ObjcClass::operator=):
     24        (KJS::Bindings::ObjcClass::constructorAt):
     25        (KJS::Bindings::ObjcClass::numConstructors):
     26        * bindings/objc/objc_class.mm: Added.
     27        (ObjcClass::_commonDelete):
     28        (ObjcClass::_commonCopy):
     29        (ObjcClass::_commonInit):
     30        (_createClassesByIsAIfNecessary):
     31        (ObjcClass::classForIsA):
     32        (ObjcClass::ObjcClass):
     33        (ObjcClass::name):
     34        (ObjcClass::methodsNamed):
     35        (ObjcClass::fieldNamed):
     36        * bindings/objc/objc_header.h: Added.
     37        * bindings/objc/objc_instance.h: Added.
     38        (KJS::Bindings::ObjcInstance::getObject):
     39        * bindings/objc/objc_instance.mm: Added.
     40        (ObjcInstance::ObjcInstance):
     41        (ObjcInstance::~ObjcInstance):
     42        (ObjcInstance::operator=):
     43        (ObjcInstance::begin):
     44        (ObjcInstance::end):
     45        (ObjcInstance::getClass):
     46        (ObjcInstance::invokeMethod):
     47        (ObjcInstance::defaultValue):
     48        (ObjcInstance::stringValue):
     49        (ObjcInstance::numberValue):
     50        (ObjcInstance::booleanValue):
     51        (ObjcInstance::valueOf):
     52        * bindings/objc/objc_jsobject.h: Added.
     53        * bindings/objc/objc_jsobject.mm: Added.
     54        * bindings/objc/objc_runtime.h:
     55        (KJS::Bindings::ObjcField::~ObjcField):
     56        (KJS::Bindings::ObjcField::ObjcField):
     57        (KJS::Bindings::ObjcField::operator=):
     58        (KJS::Bindings::ObjcMethod::ObjcMethod):
     59        (KJS::Bindings::ObjcMethod::~ObjcMethod):
     60        (KJS::Bindings::ObjcMethod::operator=):
     61        * bindings/objc/objc_runtime.mm: Added.
     62        (ObjcMethod::ObjcMethod):
     63        (ObjcMethod::name):
     64        (ObjcMethod::numParameters):
     65        (ObjcMethod::getMethodSignature):
     66        (ObjcField::ObjcField):
     67        (ObjcField::name):
     68        (ObjcField::type):
     69        (ObjcField::valueFromInstance):
     70        (ObjcField::setValueToInstance):
     71        * bindings/objc/objc_utility.h: Added.
     72        (KJS::Bindings::):
     73        * bindings/objc/objc_utility.mm: Added.
     74        (KJS::Bindings::JSMethodNameToObjCMethodName):
     75        (KJS::Bindings::convertValueToObjcValue):
     76        (KJS::Bindings::convertObjcValueToValue):
     77        (KJS::Bindings::objcValueTypeForType):
     78        * bindings/runtime.cpp:
     79        (MethodList::MethodList):
     80        (MethodList::operator=):
     81        (Instance::setValueOfField):
     82        (Instance::createBindingForLanguageInstance):
     83        (Instance::createRuntimeObject):
     84        * bindings/runtime.h:
     85        * bindings/runtime_method.cpp:
     86        (RuntimeMethodImp::RuntimeMethodImp):
     87        (RuntimeMethodImp::get):
     88        (RuntimeMethodImp::call):
     89        * bindings/runtime_method.h:
     90        * bindings/runtime_object.cpp:
     91        (RuntimeObjectImp::get):
     92        (RuntimeObjectImp::hasProperty):
     93        * bindings/test.js: Added.
     94        * bindings/testbindings.mm: Added.
     95        (-[MySecondInterface init]):
     96        (-[MyFirstInterface init]):
     97        (-[MyFirstInterface dealloc]):
     98        (+[MyFirstInterface JavaScriptNameForSelector:]):
     99        (-[MyFirstInterface getInt]):
     100        (-[MyFirstInterface setInt:]):
     101        (-[MyFirstInterface getMySecondInterface]):
     102        (-[MyFirstInterface logMessage:]):
     103        (GlobalImp::className):
     104        (readJavaScriptFromFile):
     105        (main):
     106
    1107=== Safari-128 ===
    2108
  • trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj

    r6085 r6086  
    1818                                INSTALL_PATH = "@executable_path/../Frameworks";
    1919                                OPTIMIZATION_CFLAGS = "-O0";
    20                                 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
    2120                                SECTORDER_FLAGS = "";
     21                                STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
    2222                                ZERO_LINK = YES;
    2323                        };
     
    3333                                GCC_ENABLE_FIX_AND_CONTINUE = NO;
    3434                                INSTALL_PATH = "@executable_path/../Frameworks";
    35                                 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
    3635                                SECTORDER_FLAGS = "";
     36                                STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
    3737                                ZERO_LINK = NO;
    3838                        };
     
    110110                0867D69AFE84028FC02AAC07 = {
    111111                        children = (
     112                                51F0EC0705C86C9A00E6DF1B,
     113                                51F0EB6105C86C6B00E6DF1B,
    112114                                6560A4CF04B3B3E7008AE952,
    113115                                6560A63D04B3B69F008AE952,
     
    142144                                OPTIMIZATION_CFLAGS = "-Os";
    143145                                OTHER_CFLAGS = "$(DEBUG_CFLAGS) -DAPPLE_CHANGES -DHAVE_CONFIG_H";
    144                                 OTHER_LDFLAGS = "-umbrella WebKit -allowable_client JavaScriptGlue";
     146                                OTHER_LDFLAGS = "$(STYLE_LDFLAGS) -sub_library libobjc";
     147                                PREBINDING = NO;
    145148                                PRECOMPILE_PREFIX_HEADER = YES;
    146149                                PREFIX_HEADER = JavaScriptCorePrefix.h;
    147150                                PRODUCT_NAME = JavaScriptCore;
    148151                                SECTORDER_FLAGS = "-sectorder __TEXT __text /AppleInternal/OrderFiles/JavaScriptCore.order";
     152                                STYLE_LDFLAGS = "-umbrella WebKit -allowable_client JavaScriptGlue";
    149153                                USE_GCC3_PFE_SUPPORT = YES;
    150154                                WARNING_CFLAGS = "-Werror -Wall -W -Wcast-align -Wchar-subscripts -Wformat-security -Wmissing-format-attribute -Wmissing-prototypes -Wpointer-arith -Wwrite-strings -Wno-format-y2k -Wno-unused-parameter -Wno-long-double";
     
    179183        <string>1.2</string>
    180184        <key>CFBundleVersion</key>
    181         <string>129u</string>
     185        <string>128u</string>
    182186</dict>
    183187</plist>
     
    245249                                513DF74305C0861F00F89391,
    246250                                51C4974205C0A5D4006FBFF5,
     251                                518CF93905C72271003CF905,
     252                                51F0EB0205C85A6300E6DF1B,
     253                                51F0EC1105C86F3500E6DF1B,
     254                                51F0EC9805C88DC700E6DF1B,
     255                                7084D99505DD6211007E4C0E,
    247256                        );
    248257                        isa = PBXHeadersBuildPhase;
     
    306315                                7073BE3E0581291E005EE2C9,
    307316                                513DF74205C0861F00F89391,
     317                                518CF93A05C72271003CF905,
     318                                518CF93B05C72271003CF905,
     319                                51F0EB0605C85A9000E6DF1B,
     320                                51F0EC9905C88DC700E6DF1B,
     321                                7084D9BA05DD6CF8007E4C0E,
    308322                        );
    309323                        isa = PBXSourcesBuildPhase;
     
    316330                                6560A63E04B3B69F008AE952,
    317331                                51856D990562F158008B9D83,
     332                                51F0EB6205C86C6B00E6DF1B,
     333                                51F0EC0805C86C9A00E6DF1B,
    318334                        );
    319335                        isa = PBXFrameworksBuildPhase;
     
    633649                                70B16A260569A10900DB756D,
    634650                                70B16A270569A10900DB756D,
     651                                518CF93605C72271003CF905,
     652                                518CF93705C72271003CF905,
     653                                51F0EC1005C86F3500E6DF1B,
     654                                51F0EB0005C85A6300E6DF1B,
     655                                51F0EB0505C85A9000E6DF1B,
     656                                7084D99405DD6211007E4C0E,
     657                                7084D9B905DD6CF8007E4C0E,
    635658                                51C4974105C0A5D4006FBFF5,
     659                                518CF93805C72271003CF905,
     660                                51F0EC9605C88DC700E6DF1B,
     661                                51F0EC9705C88DC700E6DF1B,
    636662                        );
    637663                        isa = PBXGroup;
     
    654680                        };
    655681                };
     682                518CF93605C72271003CF905 = {
     683                        fileEncoding = 30;
     684                        isa = PBXFileReference;
     685                        lastKnownFileType = sourcecode.c.h;
     686                        name = objc_class.h;
     687                        path = bindings/objc/objc_class.h;
     688                        refType = 4;
     689                        sourceTree = "<group>";
     690                };
     691                518CF93705C72271003CF905 = {
     692                        fileEncoding = 30;
     693                        isa = PBXFileReference;
     694                        lastKnownFileType = sourcecode.cpp.objcpp;
     695                        name = objc_class.mm;
     696                        path = bindings/objc/objc_class.mm;
     697                        refType = 4;
     698                        sourceTree = "<group>";
     699                };
     700                518CF93805C72271003CF905 = {
     701                        fileEncoding = 30;
     702                        isa = PBXFileReference;
     703                        lastKnownFileType = sourcecode.cpp.objcpp;
     704                        name = objc_runtime.mm;
     705                        path = bindings/objc/objc_runtime.mm;
     706                        refType = 4;
     707                        sourceTree = "<group>";
     708                };
     709                518CF93905C72271003CF905 = {
     710                        fileRef = 518CF93605C72271003CF905;
     711                        isa = PBXBuildFile;
     712                        settings = {
     713                        };
     714                };
     715                518CF93A05C72271003CF905 = {
     716                        fileRef = 518CF93705C72271003CF905;
     717                        isa = PBXBuildFile;
     718                        settings = {
     719                        };
     720                };
     721                518CF93B05C72271003CF905 = {
     722                        fileRef = 518CF93805C72271003CF905;
     723                        isa = PBXBuildFile;
     724                        settings = {
     725                        };
     726                };
    656727                51A58A8D057D3A6A00A3E942 = {
    657728                        fileEncoding = 30;
     
    695766                51C4974205C0A5D4006FBFF5 = {
    696767                        fileRef = 51C4974105C0A5D4006FBFF5;
     768                        isa = PBXBuildFile;
     769                        settings = {
     770                        };
     771                };
     772                51F0EB0005C85A6300E6DF1B = {
     773                        fileEncoding = 30;
     774                        isa = PBXFileReference;
     775                        lastKnownFileType = sourcecode.c.h;
     776                        name = objc_instance.h;
     777                        path = bindings/objc/objc_instance.h;
     778                        refType = 4;
     779                        sourceTree = "<group>";
     780                };
     781                51F0EB0205C85A6300E6DF1B = {
     782                        fileRef = 51F0EB0005C85A6300E6DF1B;
     783                        isa = PBXBuildFile;
     784                        settings = {
     785                        };
     786                };
     787                51F0EB0505C85A9000E6DF1B = {
     788                        fileEncoding = 30;
     789                        isa = PBXFileReference;
     790                        lastKnownFileType = sourcecode.cpp.objcpp;
     791                        name = objc_instance.mm;
     792                        path = bindings/objc/objc_instance.mm;
     793                        refType = 4;
     794                        sourceTree = "<group>";
     795                };
     796                51F0EB0605C85A9000E6DF1B = {
     797                        fileRef = 51F0EB0505C85A9000E6DF1B;
     798                        isa = PBXBuildFile;
     799                        settings = {
     800                        };
     801                };
     802                51F0EB6105C86C6B00E6DF1B = {
     803                        isa = PBXFileReference;
     804                        lastKnownFileType = wrapper.framework;
     805                        name = Foundation.framework;
     806                        path = /System/Library/Frameworks/Foundation.framework;
     807                        refType = 0;
     808                        sourceTree = "<absolute>";
     809                };
     810                51F0EB6205C86C6B00E6DF1B = {
     811                        fileRef = 51F0EB6105C86C6B00E6DF1B;
     812                        isa = PBXBuildFile;
     813                        settings = {
     814                        };
     815                };
     816                51F0EC0705C86C9A00E6DF1B = {
     817                        isa = PBXFileReference;
     818                        lastKnownFileType = "compiled.mach-o.dylib";
     819                        name = libobjc.dylib;
     820                        path = /usr/lib/libobjc.dylib;
     821                        refType = 0;
     822                        sourceTree = "<absolute>";
     823                };
     824                51F0EC0805C86C9A00E6DF1B = {
     825                        fileRef = 51F0EC0705C86C9A00E6DF1B;
     826                        isa = PBXBuildFile;
     827                        settings = {
     828                        };
     829                };
     830                51F0EC1005C86F3500E6DF1B = {
     831                        fileEncoding = 30;
     832                        isa = PBXFileReference;
     833                        lastKnownFileType = sourcecode.c.h;
     834                        name = objc_header.h;
     835                        path = bindings/objc/objc_header.h;
     836                        refType = 4;
     837                        sourceTree = "<group>";
     838                };
     839                51F0EC1105C86F3500E6DF1B = {
     840                        fileRef = 51F0EC1005C86F3500E6DF1B;
     841                        isa = PBXBuildFile;
     842                        settings = {
     843                        };
     844                };
     845                51F0EC9605C88DC700E6DF1B = {
     846                        fileEncoding = 30;
     847                        isa = PBXFileReference;
     848                        lastKnownFileType = sourcecode.c.h;
     849                        name = objc_utility.h;
     850                        path = bindings/objc/objc_utility.h;
     851                        refType = 4;
     852                        sourceTree = "<group>";
     853                };
     854                51F0EC9705C88DC700E6DF1B = {
     855                        fileEncoding = 30;
     856                        isa = PBXFileReference;
     857                        lastKnownFileType = sourcecode.cpp.objcpp;
     858                        name = objc_utility.mm;
     859                        path = bindings/objc/objc_utility.mm;
     860                        refType = 4;
     861                        sourceTree = "<group>";
     862                };
     863                51F0EC9805C88DC700E6DF1B = {
     864                        fileRef = 51F0EC9605C88DC700E6DF1B;
     865                        isa = PBXBuildFile;
     866                        settings = {
     867                        };
     868                };
     869                51F0EC9905C88DC700E6DF1B = {
     870                        fileRef = 51F0EC9705C88DC700E6DF1B;
    697871                        isa = PBXBuildFile;
    698872                        settings = {
     
    9751149                        };
    9761150                };
     1151                7084D99405DD6211007E4C0E = {
     1152                        fileEncoding = 30;
     1153                        isa = PBXFileReference;
     1154                        lastKnownFileType = sourcecode.c.h;
     1155                        name = objc_jsobject.h;
     1156                        path = bindings/objc/objc_jsobject.h;
     1157                        refType = 4;
     1158                        sourceTree = "<group>";
     1159                };
     1160                7084D99505DD6211007E4C0E = {
     1161                        fileRef = 7084D99405DD6211007E4C0E;
     1162                        isa = PBXBuildFile;
     1163                        settings = {
     1164                        };
     1165                };
     1166                7084D9B905DD6CF8007E4C0E = {
     1167                        fileEncoding = 30;
     1168                        isa = PBXFileReference;
     1169                        lastKnownFileType = sourcecode.cpp.objcpp;
     1170                        name = objc_jsobject.mm;
     1171                        path = bindings/objc/objc_jsobject.mm;
     1172                        refType = 4;
     1173                        sourceTree = "<group>";
     1174                };
     1175                7084D9BA05DD6CF8007E4C0E = {
     1176                        fileRef = 7084D9B905DD6CF8007E4C0E;
     1177                        isa = PBXBuildFile;
     1178                        settings = {
     1179                        };
     1180                };
    9771181                70B16A260569A10900DB756D = {
    9781182                        fileEncoding = 30;
     
    12811485                                DEBUG_CFLAGS = "";
    12821486                                INSTALL_PATH = "@executable_path/../Frameworks";
    1283                                 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
     1487                                STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";
    12841488                        };
    12851489                        isa = PBXBuildStyle;
  • trunk/JavaScriptCore/Makefile.am

    r5981 r6086  
    1010
    1111all-am: JavaScriptCore-stamp
    12 JavaScriptCore-stamp: kjs/*.cpp kjs/*.h pcre/*.c pcre/*.h bindings/*.h bindings/*.cpp bindings/jni/*.cpp bindings/jni/*.h
     12JavaScriptCore-stamp: kjs/*.cpp kjs/*.h pcre/*.c pcre/*.h bindings/*.h bindings/*.cpp bindings/jni/*.cpp bindings/jni/*.h bindings/objc/*.h bindings/objc/*.mm
    1313        xcodebuild -buildstyle $(BUILDSTYLE) OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS) && touch $@
    1414clean-am:
  • trunk/JavaScriptCore/bindings/jni/jni_class.cpp

    r5919 r6086  
    160160}
    161161
    162 MethodList *JavaClass::methodsNamed(const char *name) const
     162MethodList JavaClass::methodsNamed(const char *name) const
    163163{
    164164    CFStringRef methodName = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII);
    165165    MethodList *methodList = (MethodList *)CFDictionaryGetValue(_methods, methodName);
    166166    CFRelease (methodName);
    167     return methodList;
     167    return *methodList;
    168168}
    169169
  • trunk/JavaScriptCore/bindings/jni/jni_class.h

    r5919 r6086  
    3232#include <runtime.h>
    3333#include <jni_runtime.h>
    34 
    35 #include <runtime.h>
    3634
    3735namespace KJS {
     
    10199    virtual const char *name() const { return _name; };
    102100   
    103     virtual MethodList *methodsNamed(const char *name) const;
     101    virtual MethodList methodsNamed(const char *name) const;
    104102   
    105103    virtual Field *fieldNamed(const char *name) const;
  • trunk/JavaScriptCore/bindings/jni/jni_instance.cpp

    r6012 r6086  
    105105}
    106106
    107 Value JavaInstance::invokeMethod (KJS::ExecState *exec, const MethodList *methodList, const List &args)
     107Value JavaInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodList, const List &args)
    108108{
    109109    int i, count = args.size();
     
    111111    Value resultValue;
    112112    Method *method = 0;
    113     unsigned int numMethods = methodList->length();
     113    unsigned int numMethods = methodList.length();
    114114   
    115115    // Try to find a good match for the overloaded method.  The
     
    121121    Method *aMethod;
    122122    for (methodIndex = 0; methodIndex < numMethods; methodIndex++) {
    123         aMethod = methodList->methodAt (methodIndex);
     123        aMethod = methodList.methodAt (methodIndex);
    124124        if (aMethod->numParameters() == count) {
    125125            method = aMethod;
     
    147147   
    148148    jvalue result;
    149         jobject obj = _instance->_instance;
     149    jobject obj = _instance->_instance;
    150150    switch (jMethod->JNIReturnType()){
    151151        case void_type: {
  • trunk/JavaScriptCore/bindings/jni/jni_instance.h

    r5919 r6086  
    9494    virtual KJS::Value defaultValue (KJS::Type hint) const;
    9595
    96     virtual KJS::Value invokeMethod (KJS::ExecState *exec, const MethodList *method, const KJS::List &args);
     96    virtual KJS::Value invokeMethod (KJS::ExecState *exec, const MethodList &method, const KJS::List &args);
    9797
    9898    jobject javaInstance() const { return _instance->_instance; }
  • trunk/JavaScriptCore/bindings/jni/jni_runtime.h

    r5966 r6086  
    243243
    244244    virtual const char *name() const { return _name.UTF8String(); };
    245     virtual RuntimeType returnType() const { return _returnType.UTF8String(); };
     245    RuntimeType returnType() const { return _returnType.UTF8String(); };
    246246    virtual Parameter *parameterAt(long i) const { return &_parameters[i]; };
    247247    virtual long numParameters() const { return _numParameters; };
  • trunk/JavaScriptCore/bindings/objc/objc_runtime.h

    r5966 r6086  
    11/*
    2  * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
     2 * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    25 #ifndef _OBJC_RUNTIME_H_
    26 #define _OBJC_RUNTIME_H_
     25#ifndef _BINDINGS_OBJC_RUNTIME_H_
     26#define _BINDINGS_OBJC_RUNTIME_H_
    2727
    2828#include <CoreFoundation/CoreFoundation.h>
     
    3030#include <runtime.h>
    3131#include <ustring.h>
     32
     33#include <objc_header.h>
    3234
    3335namespace KJS
     
    3840{
    3941
    40 class ObjcParameter : public Parameter
    41 {
    42 public:
    43     ObjcParameter () {};
    44    
    45     ~ObjcParameter() {
    46     };
    47 
    48     ObjcParameter(const ObjcParameter &other) : Parameter() {
    49     };
    50 
    51     ObjcParameter &operator=(const ObjcParameter &other)
    52     {
    53         if (this == &other)
    54             return *this;
    55                    
    56         return *this;
    57     }
    58    
    59     virtual RuntimeType type() {}
    60    
    61 private:
    62 };
    63 
    64 
    65 class ObjcConstructor : public Constructor
    66 {
    67 public:
    68     ObjcConstructor() : _parameters (0), _numParameters(0) {};
    69        
    70     ~ObjcConstructor() {
    71         delete [] _parameters;
    72     };
    73 
    74     void _commonCopy(const ObjcConstructor &other) {
    75         _numParameters = other._numParameters;
    76         _parameters = new ObjcParameter[_numParameters];
    77         long i;
    78         for (i = 0; i < _numParameters; i++) {
    79             _parameters[i] = other._parameters[i];
    80         }
    81     }
    82    
    83     ObjcConstructor(const ObjcConstructor &other) : Constructor() {
    84         _commonCopy (other);
    85     };
    86 
    87     ObjcConstructor &operator=(const ObjcConstructor &other)
    88     {
    89         if (this == &other)
    90             return *this;
    91            
    92         delete [] _parameters;
    93        
    94         _commonCopy (other);
    95 
    96         return *this;
    97     }
    98 
    99     virtual KJS::Value value() const { return KJS::Value(0); }
    100     virtual Parameter *parameterAt(long i) const { return &_parameters[i]; };
    101     virtual long numParameters() const { return _numParameters; };
    102    
    103 private:
    104     ObjcParameter *_parameters;
    105     long _numParameters;
    106 };
    107 
    108 
    10942class ObjcField : public Field
    11043{
    11144public:
    112     ObjcField() {};
     45    ObjcField(Ivar ivar);
     46   
    11347    ~ObjcField() {};
    11448
    115     ObjcField(const ObjcField &other);
    116     ObjcField &operator=(const ObjcField &other);
     49    ObjcField(const ObjcField &other) : Field() {
     50        _ivar = other._ivar;
     51    };
     52   
     53    ObjcField &operator=(const ObjcField &other) {
     54        if (this == &other)
     55            return *this;
     56
     57        _ivar = other._ivar;
     58       
     59        return *this;
     60    };
    11761       
    11862    virtual KJS::Value valueFromInstance(const Instance *instance) const;
     
    12367   
    12468private:
     69    Ivar _ivar;
    12570};
    12671
     
    12974{
    13075public:
    131     ObjcMethod() : Method();
    132     ~ObjcMethod ();
     76    ObjcMethod() : Method(), _objcClass(0), _selector(0) {};
    13377
    134     ObjcMethod(const ObjcMethod &other) : Method();
    135     ObjcMethod &operator=(const ObjcMethod &other);
     78    ObjcMethod(struct objc_class *aClass, const char *_selector);
     79    ~ObjcMethod () {
     80    };
     81
     82    ObjcMethod(const ObjcMethod &other) : Method() {
     83        _objcClass = other._objcClass;
     84        _selector = other._selector;
     85    };
     86   
     87    ObjcMethod &operator=(const ObjcMethod &other) {
     88        if (this == &other)
     89            return *this;
     90
     91        _objcClass = other._objcClass;
     92        _selector = other._selector;
     93       
     94        return *this;
     95    }
    13696
    13797    virtual const char *name() const;
    138     virtual RuntimeType returnType() const;
    139     virtual Parameter *parameterAt(long i) const;
     98
    14099    virtual long numParameters() const;
    141100   
     101    NSMethodSignature *getMethodSignature() const;
     102   
    142103private:
    143 };
    144 
    145 class ObjcArray : public Array
    146 {
    147 public:
    148     ObjcArray (jobject a, const char *type);
    149     virtual ~ObjcArray();
    150 
    151     ObjcArray (const ObjcArray &other);
    152     ObjcArray &operator=(const ObjcArray &other);
    153 
    154     virtual void setValueAt(KJS::ExecState *exec, unsigned int index, const KJS::Value &aValue) const;
    155     virtual KJS::Value valueAt(unsigned int index) const;
    156     virtual unsigned int getLength() const;
    157    
    158 
    159 private:
     104    struct objc_class *_objcClass;
     105    const char *_selector;
    160106};
    161107
  • trunk/JavaScriptCore/bindings/runtime.cpp

    r5919 r6086  
    2525#include <value.h>
    2626
    27 #include <runtime.h>
     27#include <runtime_object.h>
    2828#include <jni_instance.h>
     29#include <objc_instance.h>
    2930
    3031using namespace KJS;
     
    5960}
    6061
     62MethodList::MethodList (const MethodList &other) {
     63    _length = other._length;
     64    _methods = new Method *[_length];
     65    if (_length > 0)
     66        memcpy (_methods, other._methods, sizeof(Method *) * _length);
     67}
    6168
    62 Instance *Instance::createBindingForLanguageInstance (BindingLanguage language, void *instance)
     69MethodList &MethodList::operator=(const MethodList &other)
    6370{
    64     if (language == Instance::JavaLanguage)
    65         return new Bindings::JavaInstance ((jobject)instance);
    66     return 0;
     71    if (this == &other)
     72        return *this;
     73           
     74    delete [] _methods;
     75   
     76    _length = other._length;
     77    _methods = new Method *[_length];
     78    if (_length > 0)
     79        memcpy (_methods, other._methods, sizeof(Method *) * _length);
     80
     81    return *this;
    6782}
     83
    6884
    6985Value Instance::getValueOfField (const Field *aField) const { 
     
    7490    return aField->setValueToInstance (exec, this, aValue);
    7591}
     92
     93Instance *Instance::createBindingForLanguageInstance (BindingLanguage language, void *instance)
     94{
     95    if (language == Instance::JavaLanguage)
     96        return new Bindings::JavaInstance ((jobject)instance);
     97    if (language == Instance::ObjectiveCLanguage)
     98        return new Bindings::ObjcInstance ((struct objc_object *)instance);
     99    return 0;
     100}
     101
     102Object Instance::createRuntimeObject (BindingLanguage language, void *myInterface)
     103{
     104    Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)myInterface);
     105    return Object(new RuntimeObjectImp(interfaceObject,true));
     106}
  • trunk/JavaScriptCore/bindings/runtime.h

    r5966 r6086  
    2727
    2828#include "list.h"
     29#include "object.h"
    2930#include "value.h"
    3031
     
    4142typedef const char * RuntimeType;
    4243
     44// FIXME:  Parameter should be removed from abstract runtime classes.
    4345class Parameter
    4446{
     
    4850};
    4951
     52// FIXME:  Constructor should be removed from abstract runtime classes
     53// unless we want to support instantiation of runtime objects from
     54// JavaScript.
    5055class Constructor
    5156{
     
    8186    ~MethodList();
    8287   
     88    MethodList (const MethodList &other);
     89    MethodList &operator=(const MethodList &other);
     90
    8391private:
    8492    Method **_methods;
     
    9199public:
    92100    virtual const char *name() const = 0;
    93     virtual RuntimeType returnType() const = 0;
    94     virtual Parameter *parameterAt(long i) const = 0;
     101
    95102    virtual long numParameters() const = 0;
    96103       
     
    103110    virtual const char *name() const = 0;
    104111   
    105     virtual MethodList *methodsNamed(const char *name) const = 0;
     112    virtual MethodList methodsNamed(const char *name) const = 0;
    106113   
    107114    virtual Constructor *constructorAt(long i) const = 0;
     
    123130    static Instance *createBindingForLanguageInstance (BindingLanguage language, void *instance);
    124131
     132    static Object createRuntimeObject (BindingLanguage language, void *myInterface);
     133
    125134    // These functions are called before and after the main entry points into
    126135    // the native implementations.  They can be used to establish and cleanup
     
    134143    virtual void setValueOfField (KJS::ExecState *exec, const Field *aField, const KJS::Value &aValue) const;
    135144   
    136     virtual KJS::Value invokeMethod (KJS::ExecState *exec, const MethodList *method, const KJS::List &args) = 0;
     145    virtual KJS::Value invokeMethod (KJS::ExecState *exec, const MethodList &method, const KJS::List &args) = 0;
    137146   
    138147    virtual KJS::Value defaultValue (KJS::Type hint) const = 0;
  • trunk/JavaScriptCore/bindings/runtime_method.cpp

    r5919 r6086  
    3232using namespace KJS;
    3333
    34 RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::MethodList *m) : FunctionImp (exec, ident)
     34RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) : FunctionImp (exec, ident)
    3535{
    3636    _methodList = m;
     
    6161        // JavaScript doesn't have the notion of method overloading and
    6262        // Java does.
    63         return Number(_methodList->methodAt(0)->numParameters());
     63        return Number(_methodList.methodAt(0)->numParameters());
    6464    }
    6565   
     
    7474Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args)
    7575{
    76     if (_methodList) {
     76    if (_methodList.length() > 0) {
    7777        RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj.imp());
    7878        if (imp) {
  • trunk/JavaScriptCore/bindings/runtime_method.h

    r5919 r6086  
    3535{
    3636public:
    37     RuntimeMethodImp(ExecState *exec, const Identifier &n = Identifier::null(), Bindings::MethodList *methodList = 0);
     37    RuntimeMethodImp(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList);
    3838   
    3939    virtual ~RuntimeMethodImp();
     
    4949
    5050private:
    51     Bindings::MethodList *_methodList;
     51    Bindings::MethodList _methodList;
    5252};
    5353
  • trunk/JavaScriptCore/bindings/runtime_object.cpp

    r5964 r6086  
    7272    // Now check if a method with specified name exists, if so return a function object for
    7373    // that method.
    74     MethodList *methodList = instance->getClass()->methodsNamed(propertyName.ascii());
    75     if (methodList) {
     74    MethodList methodList = instance->getClass()->methodsNamed(propertyName.ascii());
     75    if (methodList.length() > 0) {
    7676        instance->end();
    7777        return Object (new RuntimeMethodImp(exec, propertyName, methodList));
     
    119119    }
    120120       
    121     MethodList *methodList = instance->getClass()->methodsNamed(propertyName.ascii());
     121    MethodList methodList = instance->getClass()->methodsNamed(propertyName.ascii());
    122122
    123123    instance->end();
    124124
    125     if (methodList)
     125    if (methodList.length() > 0)
    126126        return true;
    127127       
Note: See TracChangeset for help on using the changeset viewer.