Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Figure out when a record needs to be generated as a class #59

Open
Therzok opened this issue Mar 12, 2018 · 0 comments
Open

Figure out when a record needs to be generated as a class #59

Therzok opened this issue Mar 12, 2018 · 0 comments

Comments

@Therzok
Copy link
Contributor

Therzok commented Mar 12, 2018

There are a few scenarios where plain structs were defined as classes in managed land.

Note in this issue the cases where we need to generate a class instead of a struct for Record:

  • GList:
// This native struct cannot be expressed in C#. We need to generate a wrapper class for the struct pointer.
struct List
{
    void *data;
    List *prev, *next;
}

// Managed then becomes
class List
{
     IntPtr native;
     // Methods which interact with the native pointer.

     // In case we want to provide unsafe access to the native data
     unsafe struct ListInternal
     {
          IntPtr data;
          ListInternal* prev, next;
     }

     public unsafe ListInternal *Native => (ListInternal *)native;
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant