aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/objc.h
blob: 305ce812487fe33cef1c587b7b3015bfcf044d24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

/* Compiler implementation of the D programming language
 * Copyright (C) 2015-2023 by The D Language Foundation, All Rights Reserved
 * written by Michel Fortin
 * https://www.digitalmars.com
 * Distributed under the Boost Software License, Version 1.0.
 * https://www.boost.org/LICENSE_1_0.txt
 * https://github.com/dlang/dmd/blob/master/src/dmd/objc.h
 */

#pragma once

#include "root/dsystem.h"
#include "arraytypes.h"

class AggregateDeclaration;
class AttribDeclaration;
class ClassDeclaration;
class FuncDeclaration;
class Identifier;
class InterfaceDeclaration;

struct Scope;

struct ObjcSelector
{
    const char *stringvalue;
    size_t stringlen;
    size_t paramCount;

    static void _init();

    ObjcSelector(const char *sv, size_t len, size_t pcount);

    static ObjcSelector *create(FuncDeclaration *fdecl);
};

struct ObjcClassDeclaration
{
    bool isMeta;
    bool isExtern;

    Identifier* identifier;
    ClassDeclaration* classDeclaration;
    ClassDeclaration* metaclass;
    DArray<FuncDeclaration*> methodList;

    bool isRootClass() const;
};

struct ObjcFuncDeclaration
{
    ObjcSelector* selector;
    VarDeclaration* selectorParameter;
    bool isOptional;
};

class Objc
{
public:
    static void _init();

    virtual void setObjc(ClassDeclaration* cd) = 0;
    virtual void setObjc(InterfaceDeclaration*) = 0;
    virtual const char *toPrettyChars(ClassDeclaration *cd, bool qualifyTypes) const = 0;

    virtual void setSelector(FuncDeclaration*, Scope* sc) = 0;
    virtual void validateSelector(FuncDeclaration* fd) = 0;
    virtual void checkLinkage(FuncDeclaration* fd) = 0;
    virtual bool isVirtual(const FuncDeclaration*) const = 0;
    virtual void setAsOptional(FuncDeclaration *fd, Scope *sc) const = 0;
    virtual void validateOptional(FuncDeclaration *fd) const = 0;
    virtual ClassDeclaration* getParent(FuncDeclaration*, ClassDeclaration*) const = 0;
    virtual void addToClassMethodList(FuncDeclaration*, ClassDeclaration*) const = 0;
    virtual AggregateDeclaration* isThis(FuncDeclaration* fd) = 0;
    virtual VarDeclaration* createSelectorParameter(FuncDeclaration*, Scope*) const = 0;

    virtual void setMetaclass(InterfaceDeclaration* id, Scope*) const = 0;
    virtual void setMetaclass(ClassDeclaration* id, Scope*) const = 0;
    virtual ClassDeclaration* getRuntimeMetaclass(ClassDeclaration* cd) = 0;

    virtual void addSymbols(AttribDeclaration*, ClassDeclarations*, ClassDeclarations*) const = 0;
    virtual void addSymbols(ClassDeclaration*, ClassDeclarations*, ClassDeclarations*) const = 0;
};