Skip to content

Commit

Permalink
Fix multiple void return points and fix val pointer copies
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrulich committed Aug 13, 2024
1 parent 58cf704 commit 9991f17
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions nautilus/include/nautilus/val_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@ class base_ptr_val {
base_ptr_val() : value() {};
#ifdef ENABLE_TRACING
base_ptr_val(ValuePtrType ptr) : state(tracing::traceConstant((void*) ptr)), value(ptr) {};
#else
base_ptr_val(ValuePtrType ptr) : value(ptr) {};
#endif
base_ptr_val(ValuePtrType ptr, tracing::value_ref tc) : state(tc), value(ptr) {};
base_ptr_val(ValuePtrType ptr, tracing::TypedValueRefHolder tc) : state(tc), value(ptr) {};

base_ptr_val(tracing::value_ref ref) : state(ref), value(nullptr) {
}
#else
base_ptr_val(ValuePtrType ptr) : value(ptr) {};
#endif

#ifdef ENABLE_TRACING
tracing::TypedValueRefHolder state;
#endif
ValuePtrType value;
};

Expand All @@ -104,11 +106,20 @@ class val<ValuePtrType> : public base_ptr_val<ValuePtrType> {
// enable cast to type T
template <typename T>
operator val<T*>() const {
#ifdef ENABLE_TRACING
return val<T*>((T*) this->value, this->state);
#else
return val<T*>((T*) this->value);
#endif
}

#ifdef ENABLE_TRACING
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value, tracing::traceCopy(otherValue.state)) {
}
#else
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value) {
}
#endif

val<ValuePtrType>& operator=(const val<ValuePtrType>& other) {
#ifdef ENABLE_TRACING
Expand All @@ -127,8 +138,13 @@ class val<ValuePtrType> : public base_ptr_val<ValuePtrType> {
using base_ptr_val<ValuePtrType>::base_ptr_val;
using ValType = typename base_ptr_val<ValuePtrType>::ValType;

#ifdef ENABLE_TRACING
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value, tracing::traceCopy(otherValue.state)) {
}
#else
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value) {
}
#endif

val<ValuePtrType>& operator=(const val<ValuePtrType>& other) {
#ifdef ENABLE_TRACING
Expand Down Expand Up @@ -183,8 +199,13 @@ class val<ValuePtrType> : public base_ptr_val<ValuePtrType> {
public:
using base_ptr_val<ValuePtrType>::base_ptr_val;

#ifdef ENABLE_TRACING
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value, tracing::traceCopy(otherValue.state)) {
}
#else
val(const val<ValuePtrType>& otherValue) : base_ptr_val<ValuePtrType>(otherValue.value) {
}
#endif

val<ValuePtrType>& operator=(const val<ValuePtrType>& other) {
#ifdef ENABLE_TRACING
Expand Down

0 comments on commit 9991f17

Please sign in to comment.