obj: Move Platform and InitOptions fields into core.windows (#1309)

* obj: Make field tracking use a single bitset

* obj: module: fix comment

* obj: Move `Platform` state and `InitOptions` fields into `core.windows`, initial push, only triangle example working on macos currently

* obj: `get` and `getValue` (renamed `getAll`) now do not return optionals, comment revisions, `device` is no longer optional, `native` is optional

* core: Lots of cleanup of unnecessary comments

* core: `Event`s now all contain `window_id`, darwin/windows: event functions now send window id

* core: comments, examples: fix `core-custom-entrypoint`
This commit is contained in:
Colton Franklin 2024-11-30 16:13:14 -06:00 committed by GitHub
parent b4e2da1b69
commit 1fe47b2b19
Failed to generate hash of commit
7 changed files with 651 additions and 610 deletions

View file

@ -85,7 +85,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
pub const Slice = struct {
index: Index,
objs: *Objects(T),
objs: *Objects(options, T),
/// Same as Objects(T).set but doesn't employ safety checks
pub fn set(objs: *@This(), id: ObjectID, value: T) void {
@ -127,6 +127,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
defer iter.index += 1;
if (!dead.isSet(iter.index)) return @bitCast(PackedID{
.type_id = iter.objs.internal.type_id,
.generation = generation.items[iter.index],
.index = iter.index,
});
@ -208,10 +209,10 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
///
/// Unlike setAll(), this method does not respect any mach.Objects tracking
/// options, so changes made to an object through this method will not be tracked.
pub fn setAllRaw(objs: *@This(), id: ObjectID, value: T) void {
pub fn setValueRaw(objs: *@This(), id: ObjectID, value: T) void {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "setAllRaw");
const unpacked = objs.validateAndUnpack(id, "setValueRaw");
data.set(unpacked.index, value);
}
@ -219,10 +220,10 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
///
/// Unlike setAllRaw, this method respects mach.Objects tracking
/// and changes made to an object through this method will be tracked.
pub fn setAll(objs: *@This(), id: ObjectID, value: T) void {
pub fn setValue(objs: *@This(), id: ObjectID, value: T) void {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "setAll");
const unpacked = objs.validateAndUnpack(id, "setValue");
data.set(unpacked.index, value);
if (objs.internal.updated) |*updated_fields| {
@ -266,7 +267,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
}
/// Get a single field.
pub fn get(objs: *@This(), id: ObjectID, comptime field_name: std.meta.FieldEnum(T)) ?std.meta.FieldType(T, field_name) {
pub fn get(objs: *@This(), id: ObjectID, comptime field_name: std.meta.FieldEnum(T)) std.meta.FieldType(T, field_name) {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "get");
@ -275,10 +276,10 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type {
}
/// Get all fields.
pub fn getAll(objs: *@This(), id: ObjectID) ?T {
pub fn getValue(objs: *@This(), id: ObjectID) T {
const data = &objs.internal.data;
const unpacked = objs.validateAndUnpack(id, "getAll");
const unpacked = objs.validateAndUnpack(id, "getValue");
return data.get(unpacked.index);
}