1 2 /* Compiler implementation of the D programming language 3 * Copyright (C) 2015-2022 by The D Language Foundation, All Rights Reserved 4 * written by Michel Fortin 5 * https://www.digitalmars.com 6 * Distributed under the Boost Software License, Version 1.0. 7 * https://www.boost.org/LICENSE_1_0.txt 8 * https://github.com/dlang/dmd/blob/master/src/dmd/objc.h 9 */ 10 11 #pragma once 12 13 #include "root/dsystem.h" 14 #include "arraytypes.h" 15 16 class AggregateDeclaration; 17 class AttribDeclaration; 18 class ClassDeclaration; 19 class FuncDeclaration; 20 class Identifier; 21 class InterfaceDeclaration; 22 23 struct Scope; 24 25 struct ObjcSelector 26 { 27 const char *stringvalue; 28 size_t stringlen; 29 size_t paramCount; 30 31 static void _init(); 32 33 ObjcSelector(const char *sv, size_t len, size_t pcount); 34 35 static ObjcSelector *create(FuncDeclaration *fdecl); 36 }; 37 38 struct ObjcClassDeclaration 39 { 40 bool isMeta; 41 bool isExtern; 42 43 Identifier* identifier; 44 ClassDeclaration* classDeclaration; 45 ClassDeclaration* metaclass; 46 DArray<FuncDeclaration*> methodList; 47 48 bool isRootClass() const; 49 }; 50 51 struct ObjcFuncDeclaration 52 { 53 ObjcSelector* selector; 54 VarDeclaration* selectorParameter; 55 bool isOptional; 56 }; 57 58 class Objc 59 { 60 public: 61 static void _init(); 62 63 virtual void setObjc(ClassDeclaration* cd) = 0; 64 virtual void setObjc(InterfaceDeclaration*) = 0; 65 virtual const char *toPrettyChars(ClassDeclaration *cd, bool qualifyTypes) const = 0; 66 67 virtual void setSelector(FuncDeclaration*, Scope* sc) = 0; 68 virtual void validateSelector(FuncDeclaration* fd) = 0; 69 virtual void checkLinkage(FuncDeclaration* fd) = 0; 70 virtual bool isVirtual(const FuncDeclaration*) const = 0; 71 virtual void setAsOptional(FuncDeclaration *fd, Scope *sc) const = 0; 72 virtual void validateOptional(FuncDeclaration *fd) const = 0; 73 virtual ClassDeclaration* getParent(FuncDeclaration*, ClassDeclaration*) const = 0; 74 virtual void addToClassMethodList(FuncDeclaration*, ClassDeclaration*) const = 0; 75 virtual AggregateDeclaration* isThis(FuncDeclaration* fd) = 0; 76 virtual VarDeclaration* createSelectorParameter(FuncDeclaration*, Scope*) const = 0; 77 78 virtual void setMetaclass(InterfaceDeclaration* id, Scope*) const = 0; 79 virtual void setMetaclass(ClassDeclaration* id, Scope*) const = 0; 80 virtual ClassDeclaration* getRuntimeMetaclass(ClassDeclaration* cd) = 0; 81 82 virtual void addSymbols(AttribDeclaration*, ClassDeclarations*, ClassDeclarations*) const = 0; 83 virtual void addSymbols(ClassDeclaration*, ClassDeclarations*, ClassDeclarations*) const = 0; 84 }; 85