Files
OrcaSlicer-bambulab/xs/xsp/StringMap.xsp
Y. Sapir 05b2993769 Translate Model class' storage to C++.
Some code copied from xs-model branch.

Also:
* Generate ::Ref classes programatically.
* Add separate __REGISTER_CLASS macro
    (for use where forward declaration won't work, i.e. typedefs)
2014-05-05 16:30:19 +03:00

60 lines
1.3 KiB
Plaintext

%module{Slic3r::XS};
%{
#include <myinit.h>
#include "StringMap.hpp"
#include "perlglue.hpp"
%}
%name{Slic3r::StringMap} class StringMap {
std::string FETCH(std::string key)
%code%{
StringMap::iterator i = THIS->find(key);
if (i == THIS->end()) {
XSRETURN_UNDEF;
}
RETVAL = i->second;
%};
void STORE(std::string key, std::string val)
%code%{ (*THIS)[key] = val; %};
void DELETE(std::string key)
%code%{ THIS->erase(key); %};
void CLEAR()
%code%{ THIS->clear(); %};
bool EXISTS(std::string key)
%code%{ RETVAL = (THIS->find(key) != THIS->end()); %};
std::string FIRSTKEY()
%code%{
StringMap::iterator i = THIS->begin();
if (i == THIS->end()) {
XSRETURN_UNDEF;
} else {
RETVAL = i->first;
}
%};
std::string NEXTKEY(std::string lastkey)
%code%{
StringMap::iterator i = THIS->find(lastkey);
if (i == THIS->end()) {
XSRETURN_UNDEF;
}
++i;
if (i == THIS->end()) {
XSRETURN_UNDEF;
} else {
RETVAL = i->first;
}
%};
bool SCALAR()
%code%{ RETVAL = !THIS->empty(); %};
};