Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion hvcc/generators/ir2c/templates/Heavy_NAME.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,28 @@ extern "C" {
{%- endfor %}
{%- endif %}


#ifdef __EXCEPTIONS
class my_bad_alloc : public std::bad_alloc {
virtual const char* what() const noexcept
{
return "Heavy_{{name}} object is improperly aligned. Avoid heap allocation, use operator new or use -std=c++17\n";
}
};
#endif // __EXCEPTIONS

/*
* Class Functions
*/

Heavy_{{name}}::Heavy_{{name}}(double sampleRate, int poolKb, int inQueueKb, int outQueueKb)
: HeavyContext(sampleRate, poolKb, inQueueKb, outQueueKb) {
#ifdef __EXCEPTIONS
if(size_t(this) & size_t(alignof(Heavy_{{name}}) - 1))
{
my_bad_alloc e;
throw(e);
}
#endif // __EXCEPTIONS
{%- for x in init_list %}
numBytes += {{x}}
{%- endfor %}
Expand Down