<commit_before>C codegenerator implementation of classes and interfaces
========================================================

In C++ terms one can imaging a BaseObject interface and other interfaces
inherit it as virtual.
<commit_msg>C OOP implementation doc<commit_after>C codegenerator implementation of classes and interfaces
========================================================

In C++ terms one can image a BaseObject interface and other interfaces
inherit it as virtual.

Class inheritance
-----------------

There's a vtable for each class::

    struct MyClassAVTbl {
        void (*doA)(MyClassAVTbl *this);
    };
    
    struct MyClassA {
        MyClassAVTbl *vtable;
        int field1;
    };

    void MyClassA_InitVTable();

    struct MyClassB {
        MyClassA superClass;
        MyClassBVTable *vB;
        int fieldForB;
    };

    void MyClassB_InitVTable();


Interfaces
----------

Implementing interfaces requires correcting *this* offsets for the methods::

    struct BaseObjInterface {
        int (*hash)(BaseObjInterface *this);
    };
    
    struct ToStringIface {
        char *toString(ToStringIface *this);
    };

    struct MyClassVTbl {        
        BaseObjInterface baseObjInterface;
        ToStringIface toStringIface;
    };

    struct MyClass {
        SuperClass superClass;
        MyClassVTbl vtable;
        char astr[200];
    };

    char *MyClass_toString(ToStringIface *_this) {
        MyClass *this = (MyClass*)((char*)_this - offsetof(MyClassVTbl, toStringIface) - offsetof(MyClass.vtable));
    }

So there we need functions to convert from interface *this* into class instance *this* and vice versa.

{'fraction_non_alphanumeric': 0.14832535885167464, 'fraction_numerical': 0.0023923444976076554, 'mean_word_length': 3.031325301204819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1266417', 'n_tokens_mistral': 460, 'n_tokens_neox': 434, 'n_words': 140}