Skip to content

refactor: streamline macros for adding nodes #309

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

Merged
merged 1 commit into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ macro_rules! node_table_add_row_details {
}

macro_rules! node_table_add_row {
($(#[$attr:meta])* => $name: ident, $self: ident, $table: ident $(, $table2: ident )?) => {
($(#[$attr:meta])* => $name: ident, $self: ident, $table: expr) => {
$(#[$attr])*
pub fn $name<F,T,P,I>(
&mut $self,
Expand All @@ -641,13 +641,13 @@ macro_rules! node_table_add_row {
individual,
std::ptr::null(),
0,
(*$self.$table)$(.$table2)?)
$table)
}
};
}

macro_rules! node_table_add_row_with_metadata {
($(#[$attr:meta])* => $name: ident, $self: ident, $table: ident $(, $table2: ident )?) => {
($(#[$attr:meta])* => $name: ident, $self: ident, $table: expr) => {
$(#[$attr])*
pub fn $name<F,T,P,I,M>(
&mut $self,
Expand All @@ -671,7 +671,7 @@ macro_rules! node_table_add_row_with_metadata {
individual,
md.as_ptr(),
md.len().into(),
(*$self.$table)$(.$table2)?)
$table)
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/node_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ build_owned_table_type!(
);

impl OwnedNodeTable {
node_table_add_row!(=> add_row, self, table);
node_table_add_row_with_metadata!(=> add_row_with_metadata, self, table);
node_table_add_row!(=> add_row, self, (*self.table));
node_table_add_row_with_metadata!(=> add_row_with_metadata, self, (*self.table));
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions src/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ impl TableCollection {

node_table_add_row!(
/// Add a row to the node table
=> add_node, self, inner, nodes
=> add_node, self, (*self.inner).nodes
);

node_table_add_row_with_metadata!(
Expand All @@ -389,7 +389,7 @@ impl TableCollection {
/// assert!(tables.add_node_with_metadata(0, 0.0, -1, -1, &metadata).is_ok());
/// # }
/// ```
=> add_node_with_metadata, self, inner, nodes);
=> add_node_with_metadata, self, (*self.inner).nodes);

site_table_add_row!(
/// Add a row to the site table
Expand Down