diff --git a/include/c74_min_attribute_impl.h b/include/c74_min_attribute_impl.h index e968583..e2d3566 100644 --- a/include/c74_min_attribute_impl.h +++ b/include/c74_min_attribute_impl.h @@ -12,7 +12,7 @@ namespace c74::min { template class limit_type, allow_repetitions repetitions> template - attribute::attribute(object_base* an_owner, const std::string a_name, const T a_default_value, ARGS... args) + inline attribute::attribute(object_base* an_owner, const std::string a_name, const T a_default_value, ARGS... args) : attribute_base{ *an_owner, a_name } { m_owner.attributes()[a_name] = this; @@ -57,7 +57,7 @@ namespace c74::min { template<> template - attribute::attribute(object_base* an_owner, const std::string a_name, const time_value a_default_value, ARGS... args) + inline attribute::attribute(object_base* an_owner, const std::string a_name, const time_value a_default_value, ARGS... args) : attribute_base{ *an_owner, a_name } , m_value{ an_owner, a_name, static_cast(a_default_value) } { m_owner.attributes()[a_name] = this; @@ -76,7 +76,7 @@ namespace c74::min { template class limit_type, allow_repetitions repetitions> - void attribute::create(max::t_class* c, const max::method getter, const max::method setter, const bool isjitclass) { + inline void attribute::create(max::t_class* c, const max::method getter, const max::method setter, const bool isjitclass) { long attr_flags {}; if (visible() == visibility::hide) attr_flags |= max::ATTR_SET_OPAQUE_USER; @@ -102,7 +102,7 @@ namespace c74::min { template<> - void attribute::create(max::t_class* c, const max::method getter, const max::method setter, bool const isjitclass) { + inline void attribute::create(max::t_class* c, const max::method getter, const max::method setter, bool const isjitclass) { long attr_flags {}; if (visible() == visibility::hide) attr_flags |= max::ATTR_SET_OPAQUE_USER; @@ -126,7 +126,7 @@ namespace c74::min { template<> - void attribute::create(max::t_class* c, const max::method getter, const max::method setter, bool const isjitclass) { + inline void attribute::create(max::t_class* c, const max::method getter, const max::method setter, bool const isjitclass) { long attr_flags {}; if (visible() == visibility::hide) attr_flags |= max::ATTR_SET_OPAQUE_USER; @@ -151,7 +151,7 @@ namespace c74::min { // enum classes cannot be converted implicitly to the underlying type, so we do that explicitly here. template class limit_type, allow_repetitions repetitions, typename enable_if::value, int>::type = 0> - std::string range_string_item(const attribute* attr, const T& item) { + inline std::string range_string_item(const attribute* attr, const T& item) { const auto i = static_cast(item); if (attr->get_enum_map().empty()) @@ -162,7 +162,7 @@ namespace c74::min { // vectors cannot be passed directly to stringstream template class limit_type, allow_repetitions repetitions, typename enable_if>::value, int>::type = 0> - std::string range_string_item(const attribute* attr, const T& item) { + inline std::string range_string_item(const attribute* attr, const T& item) { string str; for (const auto& i : item) { str += std::to_string(i); @@ -172,7 +172,7 @@ namespace c74::min { // vectors cannot be passed directly to stringstream template class limit_type, allow_repetitions repetitions, typename enable_if>::value, int>::type = 0> - std::string range_string_item(const attribute* attr, const T& item) { + inline std::string range_string_item(const attribute* attr, const T& item) { string str; for (const auto& i : item) { str += std::to_string(i); @@ -189,13 +189,13 @@ namespace c74::min { int >::type = 0 > - T range_string_item(const attribute* attr, const T& item) { + inline T range_string_item(const attribute* attr, const T& item) { return item; } template class limit_type, allow_repetitions repetitions> - std::string attribute::range_string() const { + inline std::string attribute::range_string() const { std::stringstream ss; for (const auto& val : m_range) ss << "\"" << range_string_item(this, val) << "\" "; @@ -204,7 +204,7 @@ namespace c74::min { template<> - std::string attribute::range_string() const { + inline std::string attribute::range_string() const { if (m_range.empty()) return ""; @@ -218,7 +218,7 @@ namespace c74::min { template<> - std::string attribute::range_string() const { + inline std::string attribute::range_string() const { if (m_range.empty()) return ""; @@ -233,7 +233,7 @@ namespace c74::min { // enum attrs use the special enum map for range template class limit_type, allow_repetitions repetitions, typename enable_if::value, int>::type = 0> - void range_copy_helper(attribute* attr) { + inline void range_copy_helper(attribute* attr) { for (auto i = 0; i < attr->get_enum_map().size(); ++i) attr->range_ref().push_back(static_cast(i)); } @@ -241,25 +241,25 @@ namespace c74::min { // color attrs don't use range template class limit_type, allow_repetitions repetitions, typename enable_if::value, int>::type = 0> - void range_copy_helper(attribute* attr) {} + inline void range_copy_helper(attribute* attr) {} // most attrs can just copy range normally template class limit_type, allow_repetitions repetitions, typename enable_if::value && !is_color::value, int>::type = 0> - void range_copy_helper(attribute* attr) { + inline void range_copy_helper(attribute* attr) { for (const auto& a : attr->get_range_args()) attr->range_ref().push_back(a); } template class limit_type, allow_repetitions repetitions> - void attribute::copy_range() { + inline void attribute::copy_range() { range_copy_helper(this); }; template<> - void attribute::copy_range() { + inline void attribute::copy_range() { if (!m_range.empty()) { // the range for this type is a low-bound and high-bound applied to all elements in the vector assert(m_range_args.size() == 2); @@ -272,7 +272,7 @@ namespace c74::min { template<> - void attribute::copy_range() { + inline void attribute::copy_range() { if (!m_range.empty()) { // the range for this type is a low-bound and high-bound applied to all elements in the vector assert(m_range_args.size() == 2); @@ -285,22 +285,22 @@ namespace c74::min { template class limit_type, allow_repetitions repetitions> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { return (args[0] == m_value); } template<> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { return equivalent(args[0], m_value); } template<> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { return (args[0] == m_value); } template<> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { if (args.size() == m_value.size()) { for (auto i=0; i(args[i], m_value[i])) @@ -312,7 +312,7 @@ namespace c74::min { } template<> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { if (args.size() == m_value.size()) { for (auto i=0; i(args[i], m_value[i])) @@ -324,7 +324,7 @@ namespace c74::min { } template<> - bool attribute::compare_to_current_value(const atoms& args) const { + inline bool attribute::compare_to_current_value(const atoms& args) const { return equivalent(args[0], m_value.red()) && equivalent(args[1], m_value.green()) && equivalent(args[2], m_value.blue()) diff --git a/include/c74_min_buffer_impl.h b/include/c74_min_buffer_impl.h index ac73d74..04cbe9a 100644 --- a/include/c74_min_buffer_impl.h +++ b/include/c74_min_buffer_impl.h @@ -11,7 +11,7 @@ namespace c74::min { template<> - buffer_lock::buffer_lock(buffer_reference& a_buffer_ref) + inline buffer_lock::buffer_lock(buffer_reference& a_buffer_ref) : m_buffer_ref { a_buffer_ref } { m_buffer_obj = buffer_ref_getobject(m_buffer_ref.m_instance); m_tab = buffer_locksamples(m_buffer_obj); @@ -19,7 +19,7 @@ namespace c74::min { } template<> - buffer_lock::buffer_lock(buffer_reference& a_buffer_ref) + inline buffer_lock::buffer_lock(buffer_reference& a_buffer_ref) : m_buffer_ref { a_buffer_ref } { max::t_buffer_info info; @@ -31,13 +31,13 @@ namespace c74::min { template<> - buffer_lock::~buffer_lock() { + inline buffer_lock::~buffer_lock() { if (m_tab) buffer_unlocksamples(m_buffer_obj); } template<> - buffer_lock::~buffer_lock() { + inline buffer_lock::~buffer_lock() { buffer_edit_end(m_buffer_obj, true); } diff --git a/include/c74_min_impl.h b/include/c74_min_impl.h index f0f2ea5..52056b8 100644 --- a/include/c74_min_impl.h +++ b/include/c74_min_impl.h @@ -17,7 +17,7 @@ namespace c74::min { // implemented out-of-line because of bi-directional dependency of min::message<> and min::object_base - atoms object_base::try_call(const std::string& name, const atoms& args) { + inline atoms object_base::try_call(const std::string& name, const atoms& args) { auto found_message = m_messages.find(name); if (found_message != m_messages.end()) return (*found_message->second)(args); @@ -27,7 +27,7 @@ namespace c74::min { // implemented out-of-line because of bi-directional dependency of min::argument<> and min::object_base - void object_base::process_arguments(const atoms& args) { + inline void object_base::process_arguments(const atoms& args) { auto arg_count = std::min(args.size(), m_arguments.size()); for (auto i = 0; i < arg_count; ++i) @@ -39,7 +39,7 @@ namespace c74::min { // max creates them from right-to-left // note that some objects will not call this function... i.e. dsp objects or other strongly-typed objects. - void object_base::create_inlets() { + inline void object_base::create_inlets() { if (m_inlets.empty()) return; for (auto i = m_inlets.size() - 1; i > 0; --i) @@ -50,7 +50,7 @@ namespace c74::min { // outlets have to be created as a separate step (by the wrapper) because // max creates them from right-to-left - void object_base::create_outlets() { + inline void object_base::create_outlets() { for (auto outlet = m_outlets.rbegin(); outlet != m_outlets.rend(); ++outlet) (*outlet)->create(); } @@ -64,21 +64,21 @@ namespace c74::min { // c-style callback from the max kernel (clock for the min::timer class) - void timer_tick_callback(timer_impl* a_timer) { + inline void timer_tick_callback(timer_impl* a_timer) { a_timer->m_owner->tick_callback(); } // c-style callback from the max kernel (qelem for the min::timer class) - void timer_qfn_callback(timer_impl* a_timer) { + inline void timer_qfn_callback(timer_impl* a_timer) { a_timer->m_owner->qfn_callback(); } // c-style callback from the max kernel (qelem for the min::queue class) - void queue_qfn_callback(queue<>* a_queue) { + inline void queue_qfn_callback(queue<>* a_queue) { a_queue->qfn(); } @@ -90,12 +90,12 @@ namespace c74::min { // parts of the symbol class but must be defined after atom is defined - symbol::symbol(const atom& value) { + inline symbol::symbol(const atom& value) { s = value; } - symbol& symbol::operator=(const atom& value) { + inline symbol& symbol::operator=(const atom& value) { s = value; return *this; } @@ -107,52 +107,52 @@ namespace c74::min { #endif - bool atom::operator==(const max::t_symbol* s) const { + inline bool atom::operator==(const max::t_symbol* s) const { return atom_getsym(this) == s; } - bool atom::operator==(const symbol s) const { + inline bool atom::operator==(const symbol s) const { return atom_getsym(this) == (const max::t_symbol*)s; } - bool atom::operator==(const char* str) const { + inline bool atom::operator==(const char* str) const { return atom_getsym(this) == max::gensym(str); } - bool atom::operator==(const bool value) const { + inline bool atom::operator==(const bool value) const { return (atom_getlong(this) != 0) == value; } - bool atom::operator==(const int value) const { + inline bool atom::operator==(const int value) const { return atom_getlong(this) == value; } - bool atom::operator==(const long value) const { + inline bool atom::operator==(const long value) const { return atom_getlong(this) == value; } - bool atom::operator==(const double value) const { + inline bool atom::operator==(const double value) const { return atom_getfloat(this) == value; } - bool atom::operator==(const max::t_object* value) const { + inline bool atom::operator==(const max::t_object* value) const { return atom_getobj(this) == value; } - bool atom::operator==(const max::t_atom& b) const { + inline bool atom::operator==(const max::t_atom& b) const { return this->a_type == b.a_type && this->a_w.w_obj == b.a_w.w_obj; } - bool atom::operator==(const time_value value) const { + inline bool atom::operator==(const time_value value) const { const max::t_atom& a = *this; return atom_getfloat(&a) == static_cast(value); } @@ -167,7 +167,7 @@ namespace c74::min { // specialized implementations of outlet_call_is_safe() used by outlet<> implementation template<> - bool outlet_call_is_safe() { + inline bool outlet_call_is_safe() { if (max::systhread_ismainthread()) return true; else @@ -176,7 +176,7 @@ namespace c74::min { template<> - bool outlet_call_is_safe() { + inline bool outlet_call_is_safe() { if (max::systhread_istimerthread()) return true; else @@ -185,7 +185,7 @@ namespace c74::min { template<> - bool outlet_call_is_safe() { + inline bool outlet_call_is_safe() { if (max::systhread_ismainthread() || max::systhread_istimerthread()) return true; else @@ -194,7 +194,7 @@ namespace c74::min { template<> - bool outlet_call_is_safe() { + inline bool outlet_call_is_safe() { return true; }; @@ -208,7 +208,7 @@ namespace c74::min { // implementation of sample_operator-style calls made to a vector_operator template - sample vector_operator::operator()(const sample x) { + inline sample vector_operator::operator()(const sample x) { sample input_storage[1] { x }; sample output_storage[1] {}; sample* input { input_storage }; @@ -228,7 +228,7 @@ namespace c74::min { #endif - void deferred_message::pop() { + inline void deferred_message::pop() { deferred_message x; if (m_owning_message->m_deferred_messages.try_dequeue(x)) x.m_owning_message->m_function(x.m_args, x.m_inlet); diff --git a/include/c74_min_object_wrapper.h b/include/c74_min_object_wrapper.h index 1fa0f18..425e24f 100644 --- a/include/c74_min_object_wrapper.h +++ b/include/c74_min_object_wrapper.h @@ -435,7 +435,7 @@ namespace c74::min { struct wrapper_message_name_##str { \ static const char name[]; \ }; \ - const char wrapper_message_name_##str::name[] = #str; + inline const char wrapper_message_name_##str::name[] = #str; #else #define MIN_WRAPPER_CREATE_TYPE_FROM_STRING(str) \ struct wrapper_message_name_##str { \