Re-enabled intrusive_ptr

This commit is contained in:
Twan van Laarhoven
2020-05-07 22:25:02 +02:00
parent 360f8d71ad
commit 8b25815f72
7 changed files with 99 additions and 49 deletions
+2 -14
View File
@@ -134,20 +134,8 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
void SetScriptManager::onAction(const Action& action, bool undone) {
TYPE_CASE(action, ValueAction) {
if (action.card) {
#ifdef USE_INTRUSIVE_PTR
// we can just turn the Card* into a CardP
updateValue(*action.valueP, CardP(const_cast<Card*>(action.card)));
return;
#else
// find the affected card
FOR_EACH(card, set.cards) {
if (card->data.contains(action.valueP)) {
updateValue(*action.valueP, card);
return;
}
}
assert(false);
#endif
updateValue(*action.valueP, const_cast<Card*>(action.card)->intrusive_from_this());
return;
} else {
// is it a keyword's fake value?
KeywordTextValue* value = dynamic_cast<KeywordTextValue*>(action.valueP.get());
+7 -7
View File
@@ -210,8 +210,8 @@ ScriptValueP rangeIterator(int start, int end) {
// ----------------------------------------------------------------------------- : Integers
#ifdef USE_INTRUSIVE_PTR
#define USE_POOL_ALLOCATOR
#if defined(USE_INTRUSIVE_PTR) && !defined(USE_POOL_ALLOCATOR)
#define USE_POOL_ALLOCATOR 0 // disabled by default
#endif
// Integer values
@@ -224,8 +224,8 @@ public:
double toDouble() const override { return value; }
int toInt() const override { return value; }
protected:
#ifdef USE_POOL_ALLOCATOR
virtual void destroy() {
#if USE_POOL_ALLOCATOR
void destroy() const override {
boost::singleton_pool<ScriptValue, sizeof(ScriptInt)>::free(this);
}
#endif
@@ -233,7 +233,7 @@ private:
int value;
};
#if defined(USE_POOL_ALLOCATOR) && !defined(USE_INTRUSIVE_PTR)
#if USE_POOL_ALLOCATOR && !USE_INTRUSIVE_PTR
// deallocation function for pool allocated integers
void destroy_value(ScriptInt* v) {
boost::singleton_pool<ScriptValue, sizeof(ScriptInt)>::free(v);
@@ -241,8 +241,8 @@ private:
#endif
ScriptValueP to_script(int v) {
#ifdef USE_POOL_ALLOCATOR
#ifdef USE_INTRUSIVE_PTR
#if USE_POOL_ALLOCATOR
#if USE_INTRUSIVE_PTR
return ScriptValueP(
new(boost::singleton_pool<ScriptValue, sizeof(ScriptInt)>::malloc())
ScriptInt(v));