Changeset 6086 in webkit
- Timestamp:
- Feb 13, 2004, 2:39:36 PM (21 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 13 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/JavaScriptCore/ChangeLog ¶
r6083 r6086 1 2004-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 1 107 === Safari-128 === 2 108 -
TabularUnified trunk/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj ¶
r6085 r6086 18 18 INSTALL_PATH = "@executable_path/../Frameworks"; 19 19 OPTIMIZATION_CFLAGS = "-O0"; 20 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";21 20 SECTORDER_FLAGS = ""; 21 STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)"; 22 22 ZERO_LINK = YES; 23 23 }; … … 33 33 GCC_ENABLE_FIX_AND_CONTINUE = NO; 34 34 INSTALL_PATH = "@executable_path/../Frameworks"; 35 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";36 35 SECTORDER_FLAGS = ""; 36 STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)"; 37 37 ZERO_LINK = NO; 38 38 }; … … 110 110 0867D69AFE84028FC02AAC07 = { 111 111 children = ( 112 51F0EC0705C86C9A00E6DF1B, 113 51F0EB6105C86C6B00E6DF1B, 112 114 6560A4CF04B3B3E7008AE952, 113 115 6560A63D04B3B69F008AE952, … … 142 144 OPTIMIZATION_CFLAGS = "-Os"; 143 145 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; 145 148 PRECOMPILE_PREFIX_HEADER = YES; 146 149 PREFIX_HEADER = JavaScriptCorePrefix.h; 147 150 PRODUCT_NAME = JavaScriptCore; 148 151 SECTORDER_FLAGS = "-sectorder __TEXT __text /AppleInternal/OrderFiles/JavaScriptCore.order"; 152 STYLE_LDFLAGS = "-umbrella WebKit -allowable_client JavaScriptGlue"; 149 153 USE_GCC3_PFE_SUPPORT = YES; 150 154 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"; … … 179 183 <string>1.2</string> 180 184 <key>CFBundleVersion</key> 181 <string>12 9u</string>185 <string>128u</string> 182 186 </dict> 183 187 </plist> … … 245 249 513DF74305C0861F00F89391, 246 250 51C4974205C0A5D4006FBFF5, 251 518CF93905C72271003CF905, 252 51F0EB0205C85A6300E6DF1B, 253 51F0EC1105C86F3500E6DF1B, 254 51F0EC9805C88DC700E6DF1B, 255 7084D99505DD6211007E4C0E, 247 256 ); 248 257 isa = PBXHeadersBuildPhase; … … 306 315 7073BE3E0581291E005EE2C9, 307 316 513DF74205C0861F00F89391, 317 518CF93A05C72271003CF905, 318 518CF93B05C72271003CF905, 319 51F0EB0605C85A9000E6DF1B, 320 51F0EC9905C88DC700E6DF1B, 321 7084D9BA05DD6CF8007E4C0E, 308 322 ); 309 323 isa = PBXSourcesBuildPhase; … … 316 330 6560A63E04B3B69F008AE952, 317 331 51856D990562F158008B9D83, 332 51F0EB6205C86C6B00E6DF1B, 333 51F0EC0805C86C9A00E6DF1B, 318 334 ); 319 335 isa = PBXFrameworksBuildPhase; … … 633 649 70B16A260569A10900DB756D, 634 650 70B16A270569A10900DB756D, 651 518CF93605C72271003CF905, 652 518CF93705C72271003CF905, 653 51F0EC1005C86F3500E6DF1B, 654 51F0EB0005C85A6300E6DF1B, 655 51F0EB0505C85A9000E6DF1B, 656 7084D99405DD6211007E4C0E, 657 7084D9B905DD6CF8007E4C0E, 635 658 51C4974105C0A5D4006FBFF5, 659 518CF93805C72271003CF905, 660 51F0EC9605C88DC700E6DF1B, 661 51F0EC9705C88DC700E6DF1B, 636 662 ); 637 663 isa = PBXGroup; … … 654 680 }; 655 681 }; 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 }; 656 727 51A58A8D057D3A6A00A3E942 = { 657 728 fileEncoding = 30; … … 695 766 51C4974205C0A5D4006FBFF5 = { 696 767 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; 697 871 isa = PBXBuildFile; 698 872 settings = { … … 975 1149 }; 976 1150 }; 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 }; 977 1181 70B16A260569A10900DB756D = { 978 1182 fileEncoding = 30; … … 1281 1485 DEBUG_CFLAGS = ""; 1282 1486 INSTALL_PATH = "@executable_path/../Frameworks"; 1283 OTHER_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)";1487 STYLE_LDFLAGS = "-seg1addr $(LOCAL_SEG1_ADDR)"; 1284 1488 }; 1285 1489 isa = PBXBuildStyle; -
TabularUnified trunk/JavaScriptCore/Makefile.am ¶
r5981 r6086 10 10 11 11 all-am: JavaScriptCore-stamp 12 JavaScriptCore-stamp: kjs/*.cpp kjs/*.h pcre/*.c pcre/*.h bindings/*.h bindings/*.cpp bindings/jni/*.cpp bindings/jni/*.h 12 JavaScriptCore-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 13 13 xcodebuild -buildstyle $(BUILDSTYLE) OBJROOT=$(SYMROOTS) SYMROOT=$(SYMROOTS) DSTROOT=$(SYMROOTS) && touch $@ 14 14 clean-am: -
TabularUnified trunk/JavaScriptCore/bindings/jni/jni_class.cpp ¶
r5919 r6086 160 160 } 161 161 162 MethodList *JavaClass::methodsNamed(const char *name) const162 MethodList JavaClass::methodsNamed(const char *name) const 163 163 { 164 164 CFStringRef methodName = CFStringCreateWithCString(NULL, name, kCFStringEncodingASCII); 165 165 MethodList *methodList = (MethodList *)CFDictionaryGetValue(_methods, methodName); 166 166 CFRelease (methodName); 167 return methodList;167 return *methodList; 168 168 } 169 169 -
TabularUnified trunk/JavaScriptCore/bindings/jni/jni_class.h ¶
r5919 r6086 32 32 #include <runtime.h> 33 33 #include <jni_runtime.h> 34 35 #include <runtime.h>36 34 37 35 namespace KJS { … … 101 99 virtual const char *name() const { return _name; }; 102 100 103 virtual MethodList *methodsNamed(const char *name) const;101 virtual MethodList methodsNamed(const char *name) const; 104 102 105 103 virtual Field *fieldNamed(const char *name) const; -
TabularUnified trunk/JavaScriptCore/bindings/jni/jni_instance.cpp ¶
r6012 r6086 105 105 } 106 106 107 Value JavaInstance::invokeMethod (KJS::ExecState *exec, const MethodList *methodList, const List &args)107 Value JavaInstance::invokeMethod (KJS::ExecState *exec, const MethodList &methodList, const List &args) 108 108 { 109 109 int i, count = args.size(); … … 111 111 Value resultValue; 112 112 Method *method = 0; 113 unsigned int numMethods = methodList ->length();113 unsigned int numMethods = methodList.length(); 114 114 115 115 // Try to find a good match for the overloaded method. The … … 121 121 Method *aMethod; 122 122 for (methodIndex = 0; methodIndex < numMethods; methodIndex++) { 123 aMethod = methodList ->methodAt (methodIndex);123 aMethod = methodList.methodAt (methodIndex); 124 124 if (aMethod->numParameters() == count) { 125 125 method = aMethod; … … 147 147 148 148 jvalue result; 149 149 jobject obj = _instance->_instance; 150 150 switch (jMethod->JNIReturnType()){ 151 151 case void_type: { -
TabularUnified trunk/JavaScriptCore/bindings/jni/jni_instance.h ¶
r5919 r6086 94 94 virtual KJS::Value defaultValue (KJS::Type hint) const; 95 95 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); 97 97 98 98 jobject javaInstance() const { return _instance->_instance; } -
TabularUnified trunk/JavaScriptCore/bindings/jni/jni_runtime.h ¶
r5966 r6086 243 243 244 244 virtual const char *name() const { return _name.UTF8String(); }; 245 virtualRuntimeType returnType() const { return _returnType.UTF8String(); };245 RuntimeType returnType() const { return _returnType.UTF8String(); }; 246 246 virtual Parameter *parameterAt(long i) const { return &_parameters[i]; }; 247 247 virtual long numParameters() const { return _numParameters; }; -
TabularUnified trunk/JavaScriptCore/bindings/objc/objc_runtime.h ¶
r5966 r6086 1 1 /* 2 * Copyright (C) 200 3Apple Computer, Inc. All rights reserved.2 * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 23 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 #ifndef _ OBJC_RUNTIME_H_26 #define _ OBJC_RUNTIME_H_25 #ifndef _BINDINGS_OBJC_RUNTIME_H_ 26 #define _BINDINGS_OBJC_RUNTIME_H_ 27 27 28 28 #include <CoreFoundation/CoreFoundation.h> … … 30 30 #include <runtime.h> 31 31 #include <ustring.h> 32 33 #include <objc_header.h> 32 34 33 35 namespace KJS … … 38 40 { 39 41 40 class ObjcParameter : public Parameter41 {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 Constructor66 {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 109 42 class ObjcField : public Field 110 43 { 111 44 public: 112 ObjcField() {}; 45 ObjcField(Ivar ivar); 46 113 47 ~ObjcField() {}; 114 48 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 }; 117 61 118 62 virtual KJS::Value valueFromInstance(const Instance *instance) const; … … 123 67 124 68 private: 69 Ivar _ivar; 125 70 }; 126 71 … … 129 74 { 130 75 public: 131 ObjcMethod() : Method(); 132 ~ObjcMethod (); 76 ObjcMethod() : Method(), _objcClass(0), _selector(0) {}; 133 77 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 } 136 96 137 97 virtual const char *name() const; 138 virtual RuntimeType returnType() const; 139 virtual Parameter *parameterAt(long i) const; 98 140 99 virtual long numParameters() const; 141 100 101 NSMethodSignature *getMethodSignature() const; 102 142 103 private: 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; 160 106 }; 161 107 -
TabularUnified trunk/JavaScriptCore/bindings/runtime.cpp ¶
r5919 r6086 25 25 #include <value.h> 26 26 27 #include <runtime .h>27 #include <runtime_object.h> 28 28 #include <jni_instance.h> 29 #include <objc_instance.h> 29 30 30 31 using namespace KJS; … … 59 60 } 60 61 62 MethodList::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 } 61 68 62 Instance *Instance::createBindingForLanguageInstance (BindingLanguage language, void *instance)69 MethodList &MethodList::operator=(const MethodList &other) 63 70 { 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; 67 82 } 83 68 84 69 85 Value Instance::getValueOfField (const Field *aField) const { … … 74 90 return aField->setValueToInstance (exec, this, aValue); 75 91 } 92 93 Instance *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 102 Object Instance::createRuntimeObject (BindingLanguage language, void *myInterface) 103 { 104 Instance *interfaceObject = Instance::createBindingForLanguageInstance (language, (void *)myInterface); 105 return Object(new RuntimeObjectImp(interfaceObject,true)); 106 } -
TabularUnified trunk/JavaScriptCore/bindings/runtime.h ¶
r5966 r6086 27 27 28 28 #include "list.h" 29 #include "object.h" 29 30 #include "value.h" 30 31 … … 41 42 typedef const char * RuntimeType; 42 43 44 // FIXME: Parameter should be removed from abstract runtime classes. 43 45 class Parameter 44 46 { … … 48 50 }; 49 51 52 // FIXME: Constructor should be removed from abstract runtime classes 53 // unless we want to support instantiation of runtime objects from 54 // JavaScript. 50 55 class Constructor 51 56 { … … 81 86 ~MethodList(); 82 87 88 MethodList (const MethodList &other); 89 MethodList &operator=(const MethodList &other); 90 83 91 private: 84 92 Method **_methods; … … 91 99 public: 92 100 virtual const char *name() const = 0; 93 virtual RuntimeType returnType() const = 0; 94 virtual Parameter *parameterAt(long i) const = 0; 101 95 102 virtual long numParameters() const = 0; 96 103 … … 103 110 virtual const char *name() const = 0; 104 111 105 virtual MethodList *methodsNamed(const char *name) const = 0;112 virtual MethodList methodsNamed(const char *name) const = 0; 106 113 107 114 virtual Constructor *constructorAt(long i) const = 0; … … 123 130 static Instance *createBindingForLanguageInstance (BindingLanguage language, void *instance); 124 131 132 static Object createRuntimeObject (BindingLanguage language, void *myInterface); 133 125 134 // These functions are called before and after the main entry points into 126 135 // the native implementations. They can be used to establish and cleanup … … 134 143 virtual void setValueOfField (KJS::ExecState *exec, const Field *aField, const KJS::Value &aValue) const; 135 144 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; 137 146 138 147 virtual KJS::Value defaultValue (KJS::Type hint) const = 0; -
TabularUnified trunk/JavaScriptCore/bindings/runtime_method.cpp ¶
r5919 r6086 32 32 using namespace KJS; 33 33 34 RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::MethodList *m) : FunctionImp (exec, ident)34 RuntimeMethodImp::RuntimeMethodImp(ExecState *exec, const Identifier &ident, Bindings::MethodList &m) : FunctionImp (exec, ident) 35 35 { 36 36 _methodList = m; … … 61 61 // JavaScript doesn't have the notion of method overloading and 62 62 // Java does. 63 return Number(_methodList ->methodAt(0)->numParameters());63 return Number(_methodList.methodAt(0)->numParameters()); 64 64 } 65 65 … … 74 74 Value RuntimeMethodImp::call(ExecState *exec, Object &thisObj, const List &args) 75 75 { 76 if (_methodList ) {76 if (_methodList.length() > 0) { 77 77 RuntimeObjectImp *imp = static_cast<RuntimeObjectImp*>(thisObj.imp()); 78 78 if (imp) { -
TabularUnified trunk/JavaScriptCore/bindings/runtime_method.h ¶
r5919 r6086 35 35 { 36 36 public: 37 RuntimeMethodImp(ExecState *exec, const Identifier &n = Identifier::null(), Bindings::MethodList *methodList = 0);37 RuntimeMethodImp(ExecState *exec, const Identifier &n, Bindings::MethodList &methodList); 38 38 39 39 virtual ~RuntimeMethodImp(); … … 49 49 50 50 private: 51 Bindings::MethodList *_methodList;51 Bindings::MethodList _methodList; 52 52 }; 53 53 -
TabularUnified trunk/JavaScriptCore/bindings/runtime_object.cpp ¶
r5964 r6086 72 72 // Now check if a method with specified name exists, if so return a function object for 73 73 // 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) { 76 76 instance->end(); 77 77 return Object (new RuntimeMethodImp(exec, propertyName, methodList)); … … 119 119 } 120 120 121 MethodList *methodList = instance->getClass()->methodsNamed(propertyName.ascii());121 MethodList methodList = instance->getClass()->methodsNamed(propertyName.ascii()); 122 122 123 123 instance->end(); 124 124 125 if (methodList )125 if (methodList.length() > 0) 126 126 return true; 127 127
Note:
See TracChangeset
for help on using the changeset viewer.