Skip to content

Commit

Permalink
fix example query_group_by_callback + add snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Indra-db committed Apr 13, 2024
1 parent a26a6af commit 5c1cd8c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flecs_ecs/examples/query_group_by_callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ extern "C" fn callback_group_create(
extern "C" fn callback_group_delete(
world: *mut WorldT,
group_id: u64,
ctx: *mut c_void,
_group_by_arg: *mut c_void,
_ctx: *mut c_void,
group_by_ctx: *mut c_void,
) {
let snap = unsafe { &mut *(ctx as *mut Snap) };
let snap = unsafe { &mut *(group_by_ctx as *mut Snap) };

let world_ref = unsafe { WorldRef::from_ptr(world) };
fprintln!(
Expand All @@ -54,6 +54,7 @@ extern "C" fn callback_group_delete(
);

// if you have any data associated with the group, you need to free it
// or use the callback group_by_ctx where you pass a context to the callback
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
source: flecs_ecs/examples/common.rs
expression: self.str
---
- "\n"
- "Group created: \"Third\""
- "\n"
- "Group created: \"Second\""
- "\n"
- "Group created: \"First\""
- "\n"
- "Group: \"::query_group_by_callbacks::common::First\" - Table: [Some(query_group_by_callbacks.common.Position, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.First))] - Counter: 3"
- " [Position { x: 3.0, y: 3.0 }]"
- "\n"
- "Group: \"::query_group_by_callbacks::common::First\" - Table: [Some(query_group_by_callbacks.common.Position, query_group_by_callbacks.common.Tag, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.First))] - Counter: 3"
- " [Position { x: 6.0, y: 6.0 }]"
- "\n"
- "Group: \"::query_group_by_callbacks::common::Second\" - Table: [Some(query_group_by_callbacks.common.Position, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.Second))] - Counter: 2"
- " [Position { x: 2.0, y: 2.0 }]"
- "\n"
- "Group: \"::query_group_by_callbacks::common::Second\" - Table: [Some(query_group_by_callbacks.common.Position, query_group_by_callbacks.common.Tag, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.Second))] - Counter: 2"
- " [Position { x: 5.0, y: 5.0 }]"
- "\n"
- "Group: \"::query_group_by_callbacks::common::Third\" - Table: [Some(query_group_by_callbacks.common.Position, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.Third))] - Counter: 1"
- " [Position { x: 1.0, y: 1.0 }]"
- "\n"
- "Group: \"::query_group_by_callbacks::common::Third\" - Table: [Some(query_group_by_callbacks.common.Position, query_group_by_callbacks.common.Tag, (query_group_by_callbacks.common.Group,query_group_by_callbacks.common.Third))] - Counter: 1"
- " [Position { x: 4.0, y: 4.0 }]"
- "\n"
- "Group deleted: \"Second\""
- "Group deleted: \"First\""
- "Group deleted: \"Third\""

0 comments on commit 5c1cd8c

Please sign in to comment.