PrusaSlicer-NonPlainar/xs/xsp/PlaceholderParser.xsp
Chow Loong Jin a32281c268 Fix format-security violations (#802)
croak() expects printf-style format strings. Calling croak(e.what()) directly
causes compilations to fail with -Werror=format-security
2018-03-21 08:38:33 +01:00

34 lines
907 B
Plaintext

%module{Slic3r::XS};
%{
#include <xsinit.h>
#include <vector>
#include "libslic3r/PlaceholderParser.hpp"
%}
%name{Slic3r::GCode::PlaceholderParser} class PlaceholderParser {
PlaceholderParser();
~PlaceholderParser();
void apply_config(DynamicPrintConfig *config)
%code%{ THIS->apply_config(*config); %};
void set(std::string key, int value);
std::string process(std::string str) const
%code%{
try {
RETVAL = THIS->process(str, 0);
} catch (std::exception& e) {
croak("%s\n", e.what());
}
%};
bool evaluate_boolean_expression(const char *str) const
%code%{
try {
RETVAL = THIS->evaluate_boolean_expression(str, THIS->config());
} catch (std::exception& e) {
croak("%s\n", e.what());
}
%};
};