Use make_intrusive/make_shared for smart pointer construction.

This commit is contained in:
Twan van Laarhoven
2020-04-23 23:51:34 +02:00
parent 815df01ba5
commit 708b4389a0
67 changed files with 313 additions and 329 deletions
+2 -2
View File
@@ -469,9 +469,9 @@ void instrBinary (BinaryInstructionType i, ScriptValueP& a, const ScriptValueP&
} else if (bt == SCRIPT_NIL) {
// a = a;
} else if (at == SCRIPT_FUNCTION && bt == SCRIPT_FUNCTION) {
a = intrusive(new ScriptCompose(a, b));
a = make_intrusive<ScriptCompose>(a, b);
} else if (at == SCRIPT_COLLECTION && bt == SCRIPT_COLLECTION) {
a = intrusive(new ScriptConcatCollection(a, b));
a = make_intrusive<ScriptConcatCollection>(a, b);
} else if (at == SCRIPT_INT && bt == SCRIPT_INT) {
a = to_script((int)*a + (int)*b);
} else if ((at == SCRIPT_INT || at == SCRIPT_DOUBLE) &&
+3 -3
View File
@@ -68,13 +68,13 @@ private:
// Unify two values from different execution paths
void unify(ScriptValueP& a, const ScriptValueP& b) {
assert(a && b);
if (a != b) a = intrusive(new DependencyUnion(a,b));
if (a != b) a = make_intrusive<DependencyUnion>(a,b);
}
// Unify two values from different execution paths
ScriptValueP unified(const ScriptValueP& a, const ScriptValueP& b) {
assert(a && b);
if (a == b) return a;
else return intrusive(new DependencyUnion(a,b));
else return make_intrusive<DependencyUnion>(a,b);
}
/// Behaves like script_nil, but with a name
@@ -293,7 +293,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
case I_GET_VAR: {
ScriptValueP value = variables[i.data].value;
if (!value) {
value = intrusive(new ScriptMissingVariable(variable_to_string((Variable)i.data))); // no errors here
value = make_intrusive<ScriptMissingVariable>(variable_to_string((Variable)i.data)); // no errors here
}
value->dependencyThis(dep);
stack.push_back(value);
+7 -7
View File
@@ -100,7 +100,7 @@ SCRIPT_FUNCTION(to_string) {
SCRIPT_RETURN(input->toString());
}
} catch (const ScriptError& e) {
return intrusive(new ScriptDelayedError(e));
return make_intrusive<ScriptDelayedError>(e);
}
}
@@ -715,7 +715,7 @@ SCRIPT_FUNCTION(keyword_usage) {
/// Turn a script function into a rule, a.k.a. a delayed closure
SCRIPT_FUNCTION(rule) {
SCRIPT_PARAM(ScriptValueP, input);
return intrusive(new ScriptRule(input));
return make_intrusive<ScriptRule>(input);
}
// ----------------------------------------------------------------------------- : Init
@@ -760,17 +760,17 @@ void init_script_basic_functions(Context& ctx) {
ctx.setVariable(_("substring"), script_substring);
ctx.setVariable(_("contains"), script_contains);
ctx.setVariable(_("format"), script_format);
ctx.setVariable(_("format_rule"), intrusive(new ScriptRule(script_format)));
ctx.setVariable(_("format_rule"), make_intrusive<ScriptRule>(script_format));
ctx.setVariable(_("curly_quotes"), script_curly_quotes);
ctx.setVariable(_("regex_escape"), script_regex_escape);
ctx.setVariable(_("sort_text"), script_sort_text);
ctx.setVariable(_("sort_rule"), intrusive(new ScriptRule(script_sort_text)));
ctx.setVariable(_("sort_rule"), make_intrusive<ScriptRule>(script_sort_text));
// tagged string
ctx.setVariable(_("tag_contents"), script_tag_contents);
ctx.setVariable(_("remove_tag"), script_remove_tag);
ctx.setVariable(_("remove_tags"), script_remove_tags);
ctx.setVariable(_("tag_contents_rule"), intrusive(new ScriptRule(script_tag_contents)));
ctx.setVariable(_("tag_remove_rule"), intrusive(new ScriptRule(script_remove_tag)));
ctx.setVariable(_("tag_contents_rule"), make_intrusive<ScriptRule>(script_tag_contents));
ctx.setVariable(_("tag_remove_rule"), make_intrusive<ScriptRule>(script_remove_tag));
// collection
ctx.setVariable(_("position"), script_position_of);
ctx.setVariable(_("length"), script_length);
@@ -782,6 +782,6 @@ void init_script_basic_functions(Context& ctx) {
ctx.setVariable(_("random_select_many"), script_random_select_many);
// keyword
ctx.setVariable(_("expand_keywords"), script_expand_keywords);
ctx.setVariable(_("expand_keywords_rule"), intrusive(new ScriptRule(script_expand_keywords)));
ctx.setVariable(_("expand_keywords_rule"), make_intrusive<ScriptRule>(script_expand_keywords));
ctx.setVariable(_("keyword_usage"), script_keyword_usage);
}
+1 -1
View File
@@ -22,7 +22,7 @@
SCRIPT_FUNCTION(new_card) {
SCRIPT_PARAM(GameP, game);
CardP new_card = intrusive(new Card(*game));
CardP new_card = make_intrusive<Card>(*game);
// set field values
SCRIPT_PARAM(ScriptValueP, input);
ScriptValueP it = input->makeIterator();
+22 -23
View File
@@ -41,14 +41,14 @@ SCRIPT_FUNCTION(linear_blend) {
SCRIPT_PARAM(GeneratedImageP, image2);
SCRIPT_PARAM(double, x1); SCRIPT_PARAM(double, y1);
SCRIPT_PARAM(double, x2); SCRIPT_PARAM(double, y2);
return intrusive(new LinearBlendImage(image1, image2, x1,y1, x2,y2));
return make_intrusive<LinearBlendImage>(image1, image2, x1,y1, x2,y2);
}
SCRIPT_FUNCTION(masked_blend) {
SCRIPT_PARAM(GeneratedImageP, light);
SCRIPT_PARAM(GeneratedImageP, dark);
SCRIPT_PARAM(GeneratedImageP, mask);
return intrusive(new MaskedBlendImage(light, dark, mask));
return make_intrusive<MaskedBlendImage>(light, dark, mask);
}
SCRIPT_FUNCTION(combine_blend) {
@@ -57,19 +57,19 @@ SCRIPT_FUNCTION(combine_blend) {
SCRIPT_PARAM(GeneratedImageP, image2);
ImageCombine image_combine;
parse_enum(combine, image_combine);
return intrusive(new CombineBlendImage(image1, image2, image_combine));
return make_intrusive<CombineBlendImage>(image1, image2, image_combine);
}
SCRIPT_FUNCTION(set_mask) {
SCRIPT_PARAM(GeneratedImageP, image);
SCRIPT_PARAM(GeneratedImageP, mask);
return intrusive(new SetMaskImage(image, mask));
return make_intrusive<SetMaskImage>(image, mask);
}
SCRIPT_FUNCTION(set_alpha) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, alpha);
return intrusive(new SetAlphaImage(input, alpha));
return make_intrusive<SetAlphaImage>(input, alpha);
}
SCRIPT_FUNCTION(set_combine) {
@@ -77,18 +77,18 @@ SCRIPT_FUNCTION(set_combine) {
SCRIPT_PARAM_C(GeneratedImageP, input);
ImageCombine image_combine;
parse_enum(combine, image_combine);
return intrusive(new SetCombineImage(input, image_combine));
return make_intrusive<SetCombineImage>(input, image_combine);
}
SCRIPT_FUNCTION(saturate) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, amount);
return intrusive(new SaturateImage(input, amount));
return make_intrusive<SaturateImage>(input, amount);
}
SCRIPT_FUNCTION(invert_image) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new InvertImage(input));
return make_intrusive<InvertImage>(input);
}
SCRIPT_FUNCTION(recolor_image) {
@@ -97,17 +97,17 @@ SCRIPT_FUNCTION(recolor_image) {
SCRIPT_PARAM(Color, green);
SCRIPT_PARAM(Color, blue);
SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE);
return intrusive(new RecolorImage2(input,red,green,blue,white));
return make_intrusive<RecolorImage2>(input,red,green,blue,white);
} else {
SCRIPT_PARAM(Color, color);
return intrusive(new RecolorImage(input,color));
return make_intrusive<RecolorImage>(input,color);
}
}
SCRIPT_FUNCTION(enlarge) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(double, border_size);
return intrusive(new EnlargeImage(input, border_size));
return make_intrusive<EnlargeImage>(input, border_size);
}
SCRIPT_FUNCTION(crop) {
@@ -116,23 +116,23 @@ SCRIPT_FUNCTION(crop) {
SCRIPT_PARAM(int, height);
SCRIPT_PARAM(double, offset_x);
SCRIPT_PARAM(double, offset_y);
return intrusive(new CropImage(input, width, height, offset_x, offset_y));
return make_intrusive<CropImage>(input, width, height, offset_x, offset_y);
}
SCRIPT_FUNCTION(flip_horizontal) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new FlipImageHorizontal(input));
return make_intrusive<FlipImageHorizontal>(input);
}
SCRIPT_FUNCTION(flip_vertical) {
SCRIPT_PARAM_C(GeneratedImageP, input);
return intrusive(new FlipImageVertical(input));
return make_intrusive<FlipImageVertical>(input);
}
SCRIPT_FUNCTION(rotate) {
SCRIPT_PARAM_C(GeneratedImageP, input);
SCRIPT_PARAM(Degrees, angle);
return intrusive(new RotateImage(input,deg_to_rad(angle)));
return make_intrusive<RotateImage>(input,deg_to_rad(angle));
}
SCRIPT_FUNCTION(drop_shadow) {
@@ -142,7 +142,7 @@ SCRIPT_FUNCTION(drop_shadow) {
SCRIPT_OPTIONAL_PARAM_(double, alpha);
SCRIPT_OPTIONAL_PARAM_(double, blur_radius);
SCRIPT_OPTIONAL_PARAM_(Color, color);
return intrusive(new DropShadowImage(input, offset_x, offset_y, alpha, blur_radius, color));
return make_intrusive<DropShadowImage>(input, offset_x, offset_y, alpha, blur_radius, color);
}
SCRIPT_FUNCTION(symbol_variation) {
@@ -170,7 +170,7 @@ SCRIPT_FUNCTION(symbol_variation) {
FOR_EACH(v, style->variations) {
if (v->name == variation) {
// found it
return intrusive(new SymbolToImage(value, filename, value->last_update, v));
return make_intrusive<SymbolToImage>(value, filename, value->last_update, v);
}
}
throw ScriptError(_("Variation of symbol not found ('") + variation + _("')"));
@@ -183,7 +183,7 @@ SCRIPT_FUNCTION(symbol_variation) {
if (fill_type == _("solid") || fill_type.empty()) {
SCRIPT_PARAM(Color, fill_color);
SCRIPT_PARAM(Color, border_color);
var->filter = intrusive(new SolidFillSymbolFilter(fill_color, border_color));
var->filter = make_intrusive<SolidFillSymbolFilter>(fill_color, border_color);
} else if (fill_type == _("linear gradient")) {
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
@@ -193,24 +193,23 @@ SCRIPT_FUNCTION(symbol_variation) {
SCRIPT_PARAM(double, center_y);
SCRIPT_PARAM(double, end_x);
SCRIPT_PARAM(double, end_y);
var->filter = intrusive(new LinearGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2
,center_x, center_y, end_x, end_y));
var->filter = make_intrusive<LinearGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2, center_x, center_y, end_x, end_y);
} else if (fill_type == _("radial gradient")) {
SCRIPT_PARAM(Color, fill_color_1);
SCRIPT_PARAM(Color, border_color_1);
SCRIPT_PARAM(Color, fill_color_2);
SCRIPT_PARAM(Color, border_color_2);
var->filter = intrusive(new RadialGradientSymbolFilter(fill_color_1, border_color_1, fill_color_2, border_color_2));
var->filter = make_intrusive<RadialGradientSymbolFilter>(fill_color_1, border_color_1, fill_color_2, border_color_2);
} else {
throw ScriptError(_("Unknown fill type for symbol_variation: ") + fill_type);
}
return intrusive(new SymbolToImage(value, filename, value ? value->last_update : Age(0), var));
return make_intrusive<SymbolToImage>(value, filename, value ? value->last_update : Age(0), var);
}
}
SCRIPT_FUNCTION(built_in_image) {
SCRIPT_PARAM_C(String, input);
return intrusive(new BuiltInImage(input));
return make_intrusive<BuiltInImage>(input);
}
// ----------------------------------------------------------------------------- : Init
+5 -5
View File
@@ -53,7 +53,7 @@ ScriptRegexP regex_from_script(const ScriptValueP& value) {
ScriptRegexP regex = dynamic_pointer_cast<ScriptRegex>(value);
if (!regex) {
// TODO: introduce some kind of caching?
regex = intrusive(new ScriptRegex(*value));
regex = make_intrusive<ScriptRegex>(*value);
}
return regex;
}
@@ -251,8 +251,8 @@ void init_script_regex_functions(Context& ctx) {
ctx.setVariable(_("split_text"), script_split_text);
ctx.setVariable(_("match_text"), script_match_text);
ctx.setVariable(_("match"), script_match_text); // old name
ctx.setVariable(_("replace_rule"), intrusive(new ScriptRule(script_replace_text)));
ctx.setVariable(_("filter_rule"), intrusive(new ScriptRule(script_filter_text)));
ctx.setVariable(_("break_rule"), intrusive(new ScriptRule(script_break_text)));
ctx.setVariable(_("match_rule"), intrusive(new ScriptRule(script_match_text)));
ctx.setVariable(_("replace_rule"), make_intrusive<ScriptRule>(script_replace_text));
ctx.setVariable(_("filter_rule"), make_intrusive<ScriptRule>(script_filter_text));
ctx.setVariable(_("break_rule"), make_intrusive<ScriptRule>(script_break_text));
ctx.setVariable(_("match_rule"), make_intrusive<ScriptRule>(script_match_text));
}
+43 -43
View File
@@ -154,25 +154,25 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
#define SCRIPT_RULE_1_C(funname, type1, name1) \
SCRIPT_RULE_1_N(funname, type1, SCRIPT_VAR_ ## name1, name1)
/// Utility for defining a script rule with a single named parameter
#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \
class ScriptRule_##funname: public ScriptValue { \
public: \
inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \
protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \
type1 name1; \
}; \
SCRIPT_FUNCTION(funname##_rule) { \
SCRIPT_PARAM_N(type1, str1, name1); \
return intrusive(new ScriptRule_##funname(name1)); \
} \
SCRIPT_FUNCTION(funname) { \
SCRIPT_PARAM_N(type1, str1, name1); \
return ScriptRule_##funname(name1).eval(ctx); \
} \
#define SCRIPT_RULE_1_N(funname, type1, str1, name1) \
class ScriptRule_##funname: public ScriptValue { \
public: \
inline ScriptRule_##funname(const type1& name1) : name1(name1) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \
protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \
type1 name1; \
}; \
SCRIPT_FUNCTION(funname##_rule) { \
SCRIPT_PARAM_N(type1, str1, name1) \
return make_intrusive<ScriptRule_##funname>(name1); \
} \
SCRIPT_FUNCTION(funname) { \
SCRIPT_PARAM_N(type1, str1, name1); \
return ScriptRule_##funname(name1).eval(ctx); \
} \
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
/// Utility for defining a script rule with two parameters
@@ -194,30 +194,30 @@ inline Type from_script(const ScriptValueP& v, Variable var) {
})
#define SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, dep, more) \
class ScriptRule_##funname: public ScriptValue { \
public: \
inline ScriptRule_##funname(const type1& name1, const type2& name2) \
: name1(name1), name2(name2) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \
dep \
protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \
type1 name1; \
type2 name2; \
}; \
SCRIPT_FUNCTION(funname##_rule) { \
SCRIPT_PARAM_N(type1, str1, name1); \
SCRIPT_PARAM_N(type2, str2, name2); \
return intrusive(new ScriptRule_##funname(name1, name2)); \
} \
SCRIPT_FUNCTION_AUX(funname, dep) { \
SCRIPT_PARAM_N(type1, str1, name1); \
SCRIPT_PARAM_N(type2, str2, name2); \
return ScriptRule_##funname(name1, name2).eval(ctx); \
} \
more \
class ScriptRule_##funname: public ScriptValue { \
public: \
inline ScriptRule_##funname(const type1& name1, const type2& name2) \
: name1(name1), name2(name2) {} \
virtual ScriptType type() const { return SCRIPT_FUNCTION; } \
virtual String typeName() const { return _(#funname)_("_rule"); } \
dep \
protected: \
virtual ScriptValueP do_eval(Context& ctx, bool) const; \
private: \
type1 name1; \
type2 name2; \
}; \
SCRIPT_FUNCTION(funname##_rule) { \
SCRIPT_PARAM_N(type1, str1, name1); \
SCRIPT_PARAM_N(type2, str2, name2); \
return make_intrusive<ScriptRule_##funname>(name1, name2); \
} \
SCRIPT_FUNCTION_AUX(funname, dep) { \
SCRIPT_PARAM_N(type1, str1, name1); \
SCRIPT_PARAM_N(type2, str2, name2); \
return ScriptRule_##funname(name1, name2).eval(ctx); \
} \
more \
ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const
#define SCRIPT_RULE_2_DEPENDENCIES(name) \
+1 -1
View File
@@ -80,7 +80,7 @@ template <> void Reader::handle(ScriptableImage& s) {
s.script.parse(*this, true);
} else {
// a filename
s.value = intrusive(new PackagedImage(s.script.unparsed));
s.value = make_intrusive<PackagedImage>(s.script.unparsed);
}
}
template <> void Writer::handle(const ScriptableImage& s) {
+4 -4
View File
@@ -61,7 +61,7 @@ void profile_aggregate(FunctionProfile& parent, int level, int max_level, size_t
// add to item at idx
FunctionProfileP& fpp = parent.children[idx];
if (!fpp) {
fpp = intrusive(new FunctionProfile(p.name));
fpp = make_intrusive<FunctionProfile>(p.name);
}
fpp->time_ticks += p.time_ticks;
fpp->calls += p.calls;
@@ -97,7 +97,7 @@ Profiler::Profiler(Timer& timer, Variable function_name)
if ((int)function_name >= 0) {
FunctionProfileP& fpp = parent->children[(size_t)function_name << 1 | 1];
if (!fpp) {
fpp = intrusive(new FunctionProfile(variable_to_string(function_name)));
fpp = make_intrusive<FunctionProfile>(variable_to_string(function_name));
}
function = fpp.get();
}
@@ -111,7 +111,7 @@ Profiler::Profiler(Timer& timer, const Char* function_name)
{
FunctionProfileP& fpp = parent->children[(size_t)function_name];
if (!fpp) {
fpp = intrusive(new FunctionProfile(function_name));
fpp = make_intrusive<FunctionProfile>(function_name);
}
function = fpp.get();
timer.exclude_time();
@@ -124,7 +124,7 @@ Profiler::Profiler(Timer& timer, void* function_object, const String& function_n
{
FunctionProfileP& fpp = parent->children[(size_t)function_object];
if (!fpp) {
fpp = intrusive(new FunctionProfile(function_name));
fpp = make_intrusive<FunctionProfile>(function_name);
}
function = fpp.get();
timer.exclude_time();
+1 -1
View File
@@ -56,7 +56,7 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
// NOTE: do not use a smart pointer for the pointer to the set, because the set owns this
// which would lead to a reference cycle.
init_script_functions(*ctx);
ctx->setVariable(SCRIPT_VAR_set, intrusive(new ScriptObject<Set*>(&set)));
ctx->setVariable(SCRIPT_VAR_set, make_intrusive<ScriptObject<Set*>>(&set));
ctx->setVariable(SCRIPT_VAR_game, to_script(set.game));
ctx->setVariable(SCRIPT_VAR_stylesheet, to_script(stylesheet));
ctx->setVariable(SCRIPT_VAR_card_style, to_script(&stylesheet->card_style));
+1 -1
View File
@@ -76,7 +76,7 @@ void OptionalScript::initDependencies(Context& ctx, const Dependency& dep) const
}
Script& OptionalScript::getMutableScript() {
if (!script) script = intrusive(new Script());
if (!script) script = make_intrusive<Script>();
return *script;
}
+7 -7
View File
@@ -95,10 +95,10 @@ class ScriptDelayedError : public ScriptValue {
};
inline ScriptValueP delay_error(const String& m) {
return intrusive(new ScriptDelayedError(ScriptError(m)));
return make_intrusive<ScriptDelayedError>(ScriptError(m));
}
inline ScriptValueP delay_error(const ScriptError& error) {
return intrusive(new ScriptDelayedError(error));
return make_intrusive<ScriptDelayedError>(error);
}
// ----------------------------------------------------------------------------- : Iterators
@@ -160,7 +160,7 @@ class ScriptCollection : public ScriptCollectionBase {
}
}
virtual ScriptValueP makeIterator(const ScriptValueP& thisP) const {
return intrusive(new ScriptCollectionIterator<Collection>(value));
return make_intrusive<ScriptCollectionIterator<Collection>>(value);
}
virtual int itemCount() const { return (int)value->size(); }
/// Collections can be compared by comparing pointers
@@ -402,13 +402,13 @@ inline ScriptValueP to_script(long v) { return to_script((int) v); }
ScriptValueP to_script(wxDateTime v);
inline ScriptValueP to_script(bool v) { return v ? script_true : script_false; }
template <typename T>
inline ScriptValueP to_script(const vector<T>* v) { return intrusive(new ScriptCollection<vector<T> >(v)); }
inline ScriptValueP to_script(const vector<T>* v) { return make_intrusive<ScriptCollection<vector<T>>>(v); }
template <typename K, typename V>
inline ScriptValueP to_script(const map<K,V>* v) { return intrusive(new ScriptMap<map<K,V> >(v)); }
inline ScriptValueP to_script(const map<K,V>* v) { return make_intrusive<ScriptMap<map<K,V>>>(v); }
template <typename K, typename V>
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return intrusive(new ScriptMap<IndexMap<K,V> >(v)); }
inline ScriptValueP to_script(const IndexMap<K,V>* v) { return make_intrusive<ScriptMap<IndexMap<K,V>>>(v); }
template <typename T>
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return intrusive(new ScriptObject<intrusive_ptr<T> >(v)); }
inline ScriptValueP to_script(const intrusive_ptr<T>& v) { return make_intrusive<ScriptObject<intrusive_ptr<T>>>(v); }
template <typename T>
inline ScriptValueP to_script(const Defaultable<T>& v) { return to_script(v()); }
+16 -16
View File
@@ -111,11 +111,11 @@ ScriptDelayedError::operator bool() const { throw error; }
ScriptDelayedError::operator Color() const { throw error; }
int ScriptDelayedError::itemCount() const { throw error; }
CompareWhat ScriptDelayedError::compareAs(String&, void const*&) const { throw error; }
ScriptValueP ScriptDelayedError::getMember(const String&) const { return intrusive(new ScriptDelayedError(error)); }
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return intrusive(new ScriptDelayedError(error)); }
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return intrusive(new ScriptDelayedError(error)); }
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP ? thisP : intrusive(new ScriptDelayedError(error)); }
ScriptValueP ScriptDelayedError::getMember(const String&) const { return make_intrusive<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::dependencyMember(const String&, const Dependency&) const { return make_intrusive<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::do_eval(Context&, bool) const { return make_intrusive<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::dependencies(Context&, const Dependency&) const { return make_intrusive<ScriptDelayedError>(error); }
ScriptValueP ScriptDelayedError::makeIterator(const ScriptValueP& thisP) const { return thisP ? thisP : make_intrusive<ScriptDelayedError>(error); }
// ----------------------------------------------------------------------------- : Iterators
@@ -144,7 +144,7 @@ class ScriptRangeIterator : public ScriptIterator {
};
ScriptValueP rangeIterator(int start, int end) {
return intrusive(new ScriptRangeIterator(start, end));
return make_intrusive<ScriptRangeIterator>(start, end);
}
// ----------------------------------------------------------------------------- : Integers
@@ -190,7 +190,7 @@ ScriptValueP to_script(int v) {
destroy_value); // deallocation function
#endif
#else
return intrusive(new ScriptInt(v));
return make_intrusive<ScriptInt>(v);
#endif
}
@@ -233,7 +233,7 @@ class ScriptDouble : public ScriptValue {
};
ScriptValueP to_script(double v) {
return intrusive(new ScriptDouble(v));
return make_intrusive<ScriptDouble>(v);
}
// ----------------------------------------------------------------------------- : String type
@@ -287,9 +287,9 @@ class ScriptString : public ScriptValue {
}
virtual GeneratedImageP toImage(const ScriptValueP&) const {
if (value.empty()) {
return intrusive(new BlankImage());
return make_intrusive<BlankImage>();
} else {
return intrusive(new PackagedImage(value));
return make_intrusive<PackagedImage>(value);
}
}
virtual int itemCount() const { return (int)value.size(); }
@@ -307,7 +307,7 @@ class ScriptString : public ScriptValue {
};
ScriptValueP to_script(const String& v) {
return intrusive(new ScriptString(v));
return make_intrusive<ScriptString>(v);
}
@@ -329,7 +329,7 @@ private:
};
ScriptValueP to_script(Color v) {
return intrusive(new ScriptColor(v));
return make_intrusive<ScriptColor>(v);
}
@@ -350,7 +350,7 @@ class ScriptDateTime : public ScriptValue {
};
ScriptValueP to_script(wxDateTime v) {
return intrusive(new ScriptDateTime(v));
return make_intrusive<ScriptDateTime>(v);
}
@@ -367,7 +367,7 @@ public:
operator bool() const override { return false; }
operator Color() const override { return wxTransparentColour; }
GeneratedImageP toImage(const ScriptValueP&) const {
return intrusive(new BlankImage());
return make_intrusive<BlankImage>();
}
String toCode() const override {
return "nil";
@@ -440,7 +440,7 @@ ScriptValueP ScriptCustomCollection::getIndex(int index) const {
}
}
ScriptValueP ScriptCustomCollection::makeIterator(const ScriptValueP& thisP) const {
return intrusive(new ScriptCustomCollectionIterator(this, thisP));
return make_intrusive<ScriptCustomCollectionIterator>(this, thisP);
}
// ----------------------------------------------------------------------------- : Concat collection
@@ -484,7 +484,7 @@ ScriptValueP ScriptConcatCollection::getIndex(int index) const {
}
}
ScriptValueP ScriptConcatCollection::makeIterator(const ScriptValueP& thisP) const {
return intrusive(new ScriptConcatCollectionIterator(a->makeIterator(a), b->makeIterator(b)));
return make_intrusive<ScriptConcatCollectionIterator>(a->makeIterator(a), b->makeIterator(b));
}
// ----------------------------------------------------------------------------- : Default arguments / closure