Moved value_t::set_type into value.cc, since it had grown.
This commit is contained in:
parent
9344598eb0
commit
433bb11fa9
2 changed files with 21 additions and 18 deletions
20
src/value.cc
20
src/value.cc
|
|
@ -104,6 +104,26 @@ value_t::operator bool() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void value_t::set_type(type_t new_type)
|
||||
{
|
||||
assert(new_type >= VOID && new_type <= POINTER);
|
||||
if (new_type == VOID) {
|
||||
#if BOOST_VERSION >= 103700
|
||||
storage.reset();
|
||||
#else
|
||||
storage = intrusive_ptr<storage_t>();
|
||||
#endif
|
||||
assert(is_null());
|
||||
} else {
|
||||
if (! storage || storage->refc > 1)
|
||||
storage = new storage_t;
|
||||
else
|
||||
storage->data = false; // destruct all other types
|
||||
storage->type = new_type;
|
||||
assert(is_type(new_type));
|
||||
}
|
||||
}
|
||||
|
||||
bool value_t::to_boolean() const
|
||||
{
|
||||
if (is_boolean()) {
|
||||
|
|
|
|||
19
src/value.h
19
src/value.h
|
|
@ -459,24 +459,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void set_type(type_t new_type) {
|
||||
assert(new_type >= VOID && new_type <= POINTER);
|
||||
if (new_type == VOID) {
|
||||
#if BOOST_VERSION >= 103700
|
||||
storage.reset();
|
||||
#else
|
||||
storage = intrusive_ptr<storage_t>();
|
||||
#endif
|
||||
assert(is_null());
|
||||
} else {
|
||||
if (! storage || storage->refc > 1)
|
||||
storage = new storage_t;
|
||||
else
|
||||
storage->data = false; // destruct all other types
|
||||
storage->type = new_type;
|
||||
assert(is_type(new_type));
|
||||
}
|
||||
}
|
||||
void set_type(type_t new_type);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue