# dmd.dclass

Defines a `class` declaration.

Specification: Classes

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: dclass.d

Documentation: https://dlang.org/phobos/dmd_dclass.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/dclass.d

- `BaseClass`

  #### Declaration

  `struct `BaseClass`;`

  - `fillVtbl`

    #### Declaration

    `bool `fillVtbl`(ClassDeclaration `cd`, FuncDeclarations* `vtbl`, int `newinstance`);`

    Fill in `vtbl`[] for base class based on member functions of class `cd`.

    Input: `vtbl` if !=NULL, fill it in `newinstance` !=0 means all entries must be filled in by members of `cd`, not members of any base classes of `cd`.

    #### Return Value

    `true` if any entries were filled in by members of `cd` (not exclusively by base classes)

- `ClassDeclaration`

  #### Declaration

  `class `ClassDeclaration`: dmd.aggregate.AggregateDeclaration;`

  - `stack`

    #### Declaration

    `bool `stack`;`

    `true` if this is a scope class

  - `cppDtorVtblIndex`

    #### Declaration

    `int `cppDtorVtblIndex`;`

    if this is a C++ class, this is the slot reserved for the virtual destructor

  - `baseok`

    #### Declaration

    `Baseok `baseok`;`

    set the progress of base classes resolving

  - `objc`

    #### Declaration

    `ObjcClassDeclaration `objc`;`

    Data for a class declaration that is needed for the Objective-C integration.

  - `isBaseOf2`

    #### Declaration

    `final pure nothrow @nogc bool `isBaseOf2`(ClassDeclaration `cd`);`

    Determine if 'this' is a base class of `cd`. This is used to detect circular inheritance only.

  - `isBaseOf`

    #### Declaration

    `pure nothrow @nogc bool `isBaseOf`(ClassDeclaration `cd`, int* `poffset`);`

    Determine if 'this' is a base class of `cd`.

  - `isBaseInfoComplete`

    #### Declaration

    `final const bool `isBaseInfoComplete`();`

    Determine if 'this' has complete base class information. This is used to detect forward references in covariant overloads.

  - `searchBase`

    #### Declaration

    `final ClassDeclaration `searchBase`(Identifier `ident`);`

    Search base classes in depth-first, left-to-right order for a class or interface named '`ident`'. Stops at first found. Does not look for additional matches.

    #### Parameters

    `Identifier `ident`` | identifier to search for

    #### Return Value

    ClassDeclaration if found, `null` if not

  - `hasMonitor`

    #### Declaration

    `final bool `hasMonitor`();`

    #### Return Value

    `true` if there's a __monitor field

  - `findFunc`

    #### Declaration

    `final FuncDeclaration `findFunc`(Identifier `ident`, TypeFunction `tf`);`

    Find virtual function matching identifier and type. Used to build virtual function tables for interface implementations.

    #### Parameters

    `Identifier `ident`` | function's identifier
    `TypeFunction `tf`` | function's type

    #### Return Value

    function symbol if found, `null` if not

    Errors: prints error message if more than one match

  - `isCOMclass`

    #### Declaration

    `final const bool `isCOMclass`();`

  - `isAbstract`

    #### Declaration

    `final bool `isAbstract`();`

  - `vtblOffset`

    #### Declaration

    `const int `vtblOffset`();`

    Determine if slot 0 of the vtbl[] is reserved for something else. For class objects, yes, this is where the classinfo ptr goes. For COM interfaces, no. For non-COM interfaces, yes, this is where the Interface ptr goes.

    #### Return Value

    0 vtbl[0] is first virtual function pointer 1 vtbl[0] is classinfo/interfaceinfo pointer

  - `kind`

    #### Declaration

    `const const(char)* `kind`();`

  - `addLocalClass`

    #### Declaration

    `final void `addLocalClass`(ClassDeclarations* `aclasses`);`

- `InterfaceDeclaration`

  #### Declaration

  `class `InterfaceDeclaration`: dmd.dclass.ClassDeclaration;`

  - `isBaseOf`

    #### Declaration

    `pure nothrow @nogc bool `isBaseOf`(ClassDeclaration `cd`, int* `poffset`);`

    Determine if 'this' is a base class of `cd`. (Actually, if it is an interface supported by `cd`)

    Output: *`poffset` offset to start of class OFFSET_RUNTIME must determine offset at runtime

    #### Return Value

    `false` not a base `true` is a base

  - `kind`

    #### Declaration

    `const const(char)* `kind`();`

  - `vtblOffset`

    #### Declaration

    `const int `vtblOffset`();`

    Determine if slot 0 of the vtbl[] is reserved for something else. For class objects, yes, this is where the ClassInfo ptr goes. For COM interfaces, no. For non-COM interfaces, yes, this is where the Interface ptr goes.