From 541523eebab8f62b182643296deab26a47117f6f Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 30 Apr 2019 10:53:39 -0700 Subject: compilers: Split C-Like functionality into a mixin classes Currently C++ inherits C, which can lead to diamond problems. By pulling the code out into a standalone mixin class that the C, C++, ObjC, and Objc++ compilers can inherit and override as necessary we remove one source of diamonding. I've chosen to split this out into it's own file as the CLikeCompiler class is over 1000 lines by itself. This also breaks the VisualStudio derived classes inheriting from each other, to avoid the same C -> CPP inheritance problems. This is all one giant patch because there just isn't a clean way to separate this. I've done the same for Fortran since it effectively inherits the CCompiler (I say effectively because was it actually did was gross beyond explanation), it's probably not correct, but it seems to work for now. There really is a lot of layering violation going on in the Compilers, and a really good scrubbing would do this code a lot of good. --- mesonbuild/compilers/objc.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'mesonbuild/compilers/objc.py') diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index c4a7019..55311ed 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -13,16 +13,18 @@ # limitations under the License. import os.path, subprocess +import typing from ..mesonlib import EnvironmentException, MachineChoice -from .c import CCompiler -from .compilers import ClangCompiler, GnuCompiler +from .clike import CLikeCompiler +from .compilers import Compiler, ClangCompiler, GnuCompiler -class ObjCCompiler(CCompiler): - def __init__(self, exelist, version, is_cross, exe_wrap): +class ObjCCompiler(CLikeCompiler, Compiler): + def __init__(self, exelist, version, is_cross: bool, exe_wrap: typing.Optional[str]): self.language = 'objc' - CCompiler.__init__(self, exelist, version, is_cross, exe_wrap) + Compiler.__init__(self, exelist, version) + CLikeCompiler.__init__(self, is_cross, exe_wrap) def get_display_language(self): return 'Objective-C' -- cgit v1.1