Skip to content

Commit

Permalink
Add functions to AttrDataBlock to query how many attributes are conta…
Browse files Browse the repository at this point in the history
…ined.

This is for debugging mostly, to ensure - from the C++ outside world only
 - that our data still exists inside the AttrDataBlock object.

Issue #114.
  • Loading branch information
david-cattermole committed Jan 1, 2022
1 parent 1d8b93e commit 8361024
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/mmscenegraph/cppbind/include/mmscenegraph/_cxxbridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,8 @@ struct MarkerNode final {
#define CXXBRIDGE1_STRUCT_mmscenegraph$ShimAttrDataBlock
struct ShimAttrDataBlock final : public ::rust::Opaque {
MMSCENEGRAPH_API_EXPORT void clear() noexcept;
MMSCENEGRAPH_API_EXPORT ::std::size_t num_attr_static() const noexcept;
MMSCENEGRAPH_API_EXPORT ::std::size_t num_attr_anim_dense() const noexcept;
MMSCENEGRAPH_API_EXPORT ::mmscenegraph::AttrId create_attr_static(double value) noexcept;
MMSCENEGRAPH_API_EXPORT ::mmscenegraph::AttrId create_attr_anim_dense(::rust::Vec<double> values, ::std::uint32_t frame_start) noexcept;
MMSCENEGRAPH_API_EXPORT double get_attr_value(::mmscenegraph::AttrId attr_id, ::std::uint32_t frame) const noexcept;
Expand Down
10 changes: 10 additions & 0 deletions src/mmscenegraph/cppbind/include/mmscenegraph/attrdatablock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,19 @@ class AttrDataBlock {
rust::Box<ShimAttrDataBlock>
get_inner() noexcept;

MMSCENEGRAPH_API_EXPORT
void
set_inner(rust::Box<ShimAttrDataBlock> &value) noexcept;

MMSCENEGRAPH_API_EXPORT
void clear() noexcept;

MMSCENEGRAPH_API_EXPORT
size_t num_attr_static() noexcept;

MMSCENEGRAPH_API_EXPORT
size_t num_attr_anim_dense() noexcept;

MMSCENEGRAPH_API_EXPORT
AttrId create_attr_static(Real value) noexcept;

Expand Down
15 changes: 15 additions & 0 deletions src/mmscenegraph/cppbind/src/_cxxbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,8 @@ struct MarkerNode final {
#define CXXBRIDGE1_STRUCT_mmscenegraph$ShimAttrDataBlock
struct ShimAttrDataBlock final : public ::rust::Opaque {
MMSCENEGRAPH_API_EXPORT void clear() noexcept;
MMSCENEGRAPH_API_EXPORT ::std::size_t num_attr_static() const noexcept;
MMSCENEGRAPH_API_EXPORT ::std::size_t num_attr_anim_dense() const noexcept;
MMSCENEGRAPH_API_EXPORT ::mmscenegraph::AttrId create_attr_static(double value) noexcept;
MMSCENEGRAPH_API_EXPORT ::mmscenegraph::AttrId create_attr_anim_dense(::rust::Vec<double> values, ::std::uint32_t frame_start) noexcept;
MMSCENEGRAPH_API_EXPORT double get_attr_value(::mmscenegraph::AttrId attr_id, ::std::uint32_t frame) const noexcept;
Expand Down Expand Up @@ -1219,6 +1221,10 @@ ::std::size_t mmscenegraph$cxxbridge1$ShimAttrDataBlock$operator$alignof() noexc

void mmscenegraph$cxxbridge1$ShimAttrDataBlock$clear(::mmscenegraph::ShimAttrDataBlock &self) noexcept;

::std::size_t mmscenegraph$cxxbridge1$ShimAttrDataBlock$num_attr_static(const ::mmscenegraph::ShimAttrDataBlock &self) noexcept;

::std::size_t mmscenegraph$cxxbridge1$ShimAttrDataBlock$num_attr_anim_dense(const ::mmscenegraph::ShimAttrDataBlock &self) noexcept;

::mmscenegraph::AttrId mmscenegraph$cxxbridge1$ShimAttrDataBlock$create_attr_static(::mmscenegraph::ShimAttrDataBlock &self, double value) noexcept;

::mmscenegraph::AttrId mmscenegraph$cxxbridge1$ShimAttrDataBlock$create_attr_anim_dense(::mmscenegraph::ShimAttrDataBlock &self, ::rust::Vec<double> *values, ::std::uint32_t frame_start) noexcept;
Expand Down Expand Up @@ -1540,6 +1546,14 @@ MMSCENEGRAPH_API_EXPORT void ShimAttrDataBlock::clear() noexcept {
mmscenegraph$cxxbridge1$ShimAttrDataBlock$clear(*this);
}

MMSCENEGRAPH_API_EXPORT ::std::size_t ShimAttrDataBlock::num_attr_static() const noexcept {
return mmscenegraph$cxxbridge1$ShimAttrDataBlock$num_attr_static(*this);
}

MMSCENEGRAPH_API_EXPORT ::std::size_t ShimAttrDataBlock::num_attr_anim_dense() const noexcept {
return mmscenegraph$cxxbridge1$ShimAttrDataBlock$num_attr_anim_dense(*this);
}

MMSCENEGRAPH_API_EXPORT ::mmscenegraph::AttrId ShimAttrDataBlock::create_attr_static(double value) noexcept {
return mmscenegraph$cxxbridge1$ShimAttrDataBlock$create_attr_static(*this, value);
}
Expand Down Expand Up @@ -1637,6 +1651,7 @@ MMSCENEGRAPH_API_EXPORT ::rust::Slice<const double> ShimFlatScene::deviations()
return ::rust::impl<::rust::Slice<const double>>::slice(mmscenegraph$cxxbridge1$ShimFlatScene$deviations(*this));
}


MMSCENEGRAPH_API_EXPORT ::std::size_t ShimFlatScene::num_points() const noexcept {
return mmscenegraph$cxxbridge1$ShimFlatScene$num_points(*this);
}
Expand Down
17 changes: 16 additions & 1 deletion src/mmscenegraph/cppbind/src/attrdatablock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,34 @@ namespace mmscenegraph {

AttrDataBlock::AttrDataBlock() noexcept
: inner_(shim_create_attr_data_block_box()) {
std::cout << "AttrDataBlock()" << '\n';
}

rust::Box<ShimAttrDataBlock>
AttrDataBlock::get_inner() noexcept {
return std::move(inner_);
}

void
AttrDataBlock::set_inner(rust::Box<ShimAttrDataBlock> &value) noexcept {
inner_ = std::move(value);
return;
}

void
AttrDataBlock::clear() noexcept {
return inner_->clear();
}

size_t
AttrDataBlock::num_attr_static() noexcept {
return inner_->num_attr_static();
}

size_t
AttrDataBlock::num_attr_anim_dense() noexcept {
return inner_->num_attr_anim_dense();
}

AttrId
AttrDataBlock::create_attr_static(Real value) noexcept {
return inner_->create_attr_static(value);
Expand Down
8 changes: 8 additions & 0 deletions src/mmscenegraph/cppbind/src/attrdatablock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ impl ShimAttrDataBlock {
self.inner.clear()
}

pub fn num_attr_static(&self) -> usize {
self.inner.num_attr_static()
}

pub fn num_attr_anim_dense(&self) -> usize {
self.inner.num_attr_anim_dense()
}

pub fn create_attr_static(&mut self, value: CoreReal) -> BindAttrId {
let attr_id = self.inner.create_attr_static(value);
core_to_bind_attr_id(attr_id)
Expand Down
3 changes: 3 additions & 0 deletions src/mmscenegraph/cppbind/src/cxxbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ pub mod ffi {

fn clear(&mut self);

fn num_attr_static(&self) -> usize;
fn num_attr_anim_dense(&self) -> usize;

fn create_attr_static(&mut self, value: f64) -> AttrId;
fn create_attr_anim_dense(
&mut self,
Expand Down
8 changes: 8 additions & 0 deletions src/mmscenegraph/rust/src/attr/datablock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ impl AttrDataBlock {
self.anim_dense_attrs.clear();
}

pub fn num_attr_static(&self) -> usize {
self.static_attrs.len()
}

pub fn num_attr_anim_dense(&self) -> usize {
self.anim_dense_attrs.len()
}

pub fn create_attr_static(&mut self, value: Real) -> AttrId {
let mut attr = StaticAttr::new();
attr.set_value(value);
Expand Down

0 comments on commit 8361024

Please sign in to comment.