Skip to content

refactor shared/sleep flags into a capabilities bitfield on lunatik_class_t #443

@sneaky-potato

Description

@sneaky-potato

As discussed here, the shared and sleep flags on lunatik_class_t and lunatik_object_t are currently overloaded with multiple distinct responsibilities, which makes the semantics harder to reason about.
Specifically, class->shared currently controls three separate concerns:

  • Whether lunatik_monitorobject() is called during class registration (i.e., does this class support monitoring?)
  • Whether lunatik_cloneobject() is allowed for this class
  • Which metatable lunatik_setclass() picks for new object instances

Similarly, class->sleep has different semantics at the class level ("this class can have sleepable objects") vs. at the object level (the actual sleep mode of a given object).
Proposed refactor: Replace the individual bool flags with a capabilities struct (or bitfield) on lunatik_class_t

We could also add separate flags for clone and monitor (right now both are related to shared flag)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions