July 11, 2015 [dmd-internals] [D-Programming-Language/dmd] 867d54: Implement basic support for Objective-C methods. | ||||
---|---|---|---|---|
| ||||
Attachments:
| Branch: refs/heads/master Home: https://github.com/D-Programming-Language/dmd Commit: 867d5479b6d98b23b6c797ee487d1ec1474bee10 https://github.com/D-Programming-Language/dmd/commit/867d5479b6d98b23b6c797ee487d1ec1474bee10 Author: Michel Fortin <michel.fortin@michelf.com> Date: 2015-07-11 (Sat, 11 Jul 2015) Changed paths: M src/aggregate.h M src/attrib.c M src/class.c M src/declaration.h M src/e2ir.c M src/expression.c M src/expression.h M src/func.c M src/globals.h M src/glue.c M src/hdrgen.c M src/idgen.d M src/magicport.json M src/magicport/typenames.d M src/mangle.c M src/mars.c M src/module.c M src/module.h A src/objc.c A src/objc.di A src/objc.h A src/objc_glue.c A src/objc_glue_stubs.c A src/objc_stubs.c A src/objc_stubs.d M src/parse.c M src/posix.mak M src/tocsym.c M src/toobj.c M src/win32.mak A test/compilable/objc_gfunc.d A test/compilable/objc_interface.d A test/fail_compilation/objc_interface1.d A test/fail_compilation/objc_interface2.d A test/fail_compilation/objc_interface3.d A test/runnable/objc_call.d Log Message: ----------- Implement basic support for Objective-C methods. Basic support for classes, interfaces and instance methods. This is implemented by adding a new linkage attribute, `Objective-C`, and a compiler recognized UDA, `@selector`. The linkage attribute is to be used on a class or interface. The UDA is attached to a method. The linkage attribute tells the compiler that the class should use the name mangling that matches the one used by Objective-C (same as C, no mangling) and that all methods in the class should use the Objective-C way of calling methods, see below. The calling convention for Objective-C methods and functions is the same as for C. The selector UDA tells the compiler what Objective-C selector the method should have. The selector is used in the Objective-C runtime to find the implementation of a given method. An Objective-C method call is implemented by making a regular C call to the `objc_msgSend` function in the Objective-C runtime. The signature of `objc_msgSend` looks something like this: `id objc_msgSend(id self, SEL op, ...);` * The first parameter is the object (this/self pointer) * The second parameter is the selector attached to the method * The last parameter is for all the arguments that the implementation expects The call to `objc_msgSend` should not be performed as a variadic call but instead as if it had the same signature as the method that should be called but with the two additional parameter, `self` and `op`, added first. The implementation of `objc_msgSend` will jump to the method instead of calling it. Because of the above, multiple versions exist of `objc_msgSend`. Depending on the return type of the method that is called the correct version need to be used. This depends on the ABI. This is a list of functions and for which types they're used on OS X 64bit: * objc_msgSend_stret - Used for structs too large to be returned in registries * objc_msgSend_fpret - Used for `long double` * objc_msgSend_fp2ret - Used for `_Complex long double` * objc_msgSend - Used for everything else Commit: 929b56cac5502c4af71f92426951eabd9d3cd787 https://github.com/D-Programming-Language/dmd/commit/929b56cac5502c4af71f92426951eabd9d3cd787 Author: Jacob Carlborg <doob@me.com> Date: 2015-07-11 (Sat, 11 Jul 2015) Changed paths: A test/runnable/extra-files/objc_objc_msgSend.m A test/runnable/objc_objc_msgSend.d Log Message: ----------- Add tests for the various objc_msgSend_* functions. Commit: 941808dc44a03396d41657cfa9ccc8bfe901f3a7 https://github.com/D-Programming-Language/dmd/commit/941808dc44a03396d41657cfa9ccc8bfe901f3a7 Author: Walter Bright <walter@walterbright.com> Date: 2015-07-11 (Sat, 11 Jul 2015) Changed paths: M src/aggregate.h M src/attrib.c M src/class.c M src/declaration.h M src/e2ir.c M src/expression.c M src/expression.h M src/func.c M src/globals.h M src/glue.c M src/hdrgen.c M src/idgen.d M src/magicport.json M src/magicport/typenames.d M src/mangle.c M src/mars.c M src/module.c M src/module.h A src/objc.c A src/objc.di A src/objc.h A src/objc_glue.c A src/objc_glue_stubs.c A src/objc_stubs.c A src/objc_stubs.d M src/parse.c M src/posix.mak M src/tocsym.c M src/toobj.c M src/win32.mak A test/compilable/objc_gfunc.d A test/compilable/objc_interface.d A test/fail_compilation/objc_interface1.d A test/fail_compilation/objc_interface2.d A test/fail_compilation/objc_interface3.d A test/runnable/extra-files/objc_objc_msgSend.m A test/runnable/objc_call.d A test/runnable/objc_objc_msgSend.d Log Message: ----------- Merge pull request #4321 from jacob-carlborg/dobjc_instance_methods Implement basic support for Objective-C methods. Compare: https://github.com/D-Programming-Language/dmd/compare/971b319e45c4...941808dc44a0 |
Copyright © 1999-2021 by the D Language Foundation