diff options
author | bubnikv <bubnikv@gmail.com> | 2017-09-19 14:55:48 +0300 |
---|---|---|
committer | bubnikv <bubnikv@gmail.com> | 2017-09-19 14:55:48 +0300 |
commit | 473233019cf6b3d0e6a9aac5b4b8e1b904e5d9ee (patch) | |
tree | eb564a05dad1dcdb423438577eda9258175e5a68 /xs/xsp/GUI_Preset.xsp | |
parent | b58756f38b9871f713926fae38daec2db2e64640 (diff) |
Initial partial implementation of presets in C++.
Diffstat (limited to 'xs/xsp/GUI_Preset.xsp')
-rw-r--r-- | xs/xsp/GUI_Preset.xsp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/xs/xsp/GUI_Preset.xsp b/xs/xsp/GUI_Preset.xsp new file mode 100644 index 000000000..938a86373 --- /dev/null +++ b/xs/xsp/GUI_Preset.xsp @@ -0,0 +1,56 @@ +%module{Slic3r::XS}; + +%{ +#include <xsinit.h> +#include "slic3r/GUI/Preset.hpp" +%} + +%name{Slic3r::GUI::Preset} class Preset { + // owned by PresetCollection, no constructor/destructor + + bool is_default() %code%{ RETVAL = THIS->is_default; %}; + bool is_external() %code%{ RETVAL = THIS->is_external; %}; + bool is_visible() %code%{ RETVAL = THIS->is_visible; %}; + bool is_dirty() %code%{ RETVAL = THIS->is_dirty; %}; + + const char* name() %code%{ RETVAL = THIS->name.c_str(); %}; + const char* file() %code%{ RETVAL = THIS->file.c_str(); %}; + + bool loaded() %code%{ RETVAL = THIS->loaded; %}; + + Ref<DynamicPrintConfig> config() %code%{ RETVAL = &THIS->config; %}; +}; + +%name{Slic3r::GUI::PresetCollection} class PresetCollection { + + Ref<Preset> preset(size_t idx) %code%{ RETVAL = &THIS->preset(idx); %}; + size_t size() const; + size_t num_visible() const; +%{ + +SV* +PresetCollection::arrayref() + CODE: + AV* av = newAV(); + av_fill(av, THIS->size()-1); + int i = 0; + for (size_t i = 0; i < THIS->size(); ++ i) { + Preset &preset = THIS->preset(i); + av_store(av, i++, perl_to_SV_ref(preset)); + } + RETVAL = newRV_noinc((SV*)av); + OUTPUT: + RETVAL + +%} +}; + + +%name{Slic3r::GUI::PresetBundle} class PresetBundle { + PresetBundle(); + ~PresetBundle(); + + Ref<PresetCollection> prints() %code%{ RETVAL = &THIS->prints; %}; + Ref<PresetCollection> filaments() %code%{ RETVAL = &THIS->filaments; %}; + Ref<PresetCollection> printers() %code%{ RETVAL = &THIS->printers; %}; +}; |