Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rock generates invalid C code when trying to access an interface's generic type #996

Open
alexnask opened this issue May 10, 2016 · 2 comments

Comments

@alexnask
Copy link
Collaborator

CraaazyInterface: interface <T> {
    gimme: func -> T

    doCraaazyThings: func {
        T name println()
    }
}

Generated code:

void test__CraaazyInterface_doCraaazyThings_impl(CraaazyInterface__reference this) {
    #line 5 "C:\\dev\\test.ooc"
    lang_String__String_println(this->T->name);
}

// Somewhere in a header file
struct _CraaazyInterface__reference {
    test__CraaazyInterfaceClass* impl;
    lang_types__Object* obj;
};

struct _test__CraaazyInterfaceClass {
    struct _lang_types__ClassClass __super__;
    void (*gimme)(void*, uint8_t*);
    void (*doCraaazyThings)(void*);
};

Basically, there is no way to get to T from an interface reference.

@alexnask
Copy link
Collaborator Author

T should probably live in CraaazyInterface__reference in the generated code.

@alexnask
Copy link
Collaborator Author

alexnask commented May 10, 2016

Well, technically T can be accessed in some way through obj but the whole point is that we do not know the type of obj, so we can't cast it to the actual object type of the current interface reference passed to access it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant