mirror of https://github.com/KLayout/klayout.git
WIP: moved code.
This commit is contained in:
parent
c841b84867
commit
ec7ab8e01d
|
|
@ -26,48 +26,6 @@
|
|||
namespace gsi
|
||||
{
|
||||
|
||||
// TODO: move this to gsiMethods.h
|
||||
|
||||
template <class R>
|
||||
class ConstantValueGetter
|
||||
: public StaticMethodBase
|
||||
{
|
||||
public:
|
||||
ConstantValueGetter (const std::string &name, const R &v, const std::string &doc)
|
||||
: StaticMethodBase (name, doc, true), m_v (v)
|
||||
{
|
||||
}
|
||||
|
||||
void initialize ()
|
||||
{
|
||||
this->clear ();
|
||||
// Note: a constant must not return a reference to an existing object, hence "set_return_new":
|
||||
this->template set_return_new<R> ();
|
||||
}
|
||||
|
||||
virtual MethodBase *clone () const
|
||||
{
|
||||
return new ConstantValueGetter (*this);
|
||||
}
|
||||
|
||||
virtual void call (void *, SerialArgs &, SerialArgs &ret) const
|
||||
{
|
||||
mark_called ();
|
||||
ret.write<R> (m_v);
|
||||
}
|
||||
|
||||
private:
|
||||
R m_v;
|
||||
};
|
||||
|
||||
template <class R>
|
||||
Methods
|
||||
constant (const std::string &name, const R &v, const std::string &doc = std::string ())
|
||||
{
|
||||
return Methods (new ConstantValueGetter <R> (name, v, doc));
|
||||
}
|
||||
|
||||
|
||||
extern Class<db::DeviceClass> decl_dbDeviceClass;
|
||||
|
||||
Class<db::DeviceClassResistor> decl_dbDeviceClassResistor (decl_dbDeviceClass, "db", "DeviceClassResistor",
|
||||
|
|
|
|||
|
|
@ -810,6 +810,49 @@ constant (const std::string &name, R (*m) (), const std::string &doc = std::stri
|
|||
return Methods (new ConstantGetter <R> (name, m, doc));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper class to create a constant (a static method with "const" attribute, not taking any arguments)
|
||||
* This version creates a constant getter from a real constant value.
|
||||
*/
|
||||
template <class R>
|
||||
class ConstantValueGetter
|
||||
: public StaticMethodBase
|
||||
{
|
||||
public:
|
||||
ConstantValueGetter (const std::string &name, const R &v, const std::string &doc)
|
||||
: StaticMethodBase (name, doc, true), m_v (v)
|
||||
{
|
||||
}
|
||||
|
||||
void initialize ()
|
||||
{
|
||||
this->clear ();
|
||||
// Note: a constant must not return a reference to an existing object, hence "set_return_new":
|
||||
this->template set_return_new<R> ();
|
||||
}
|
||||
|
||||
virtual MethodBase *clone () const
|
||||
{
|
||||
return new ConstantValueGetter (*this);
|
||||
}
|
||||
|
||||
virtual void call (void *, SerialArgs &, SerialArgs &ret) const
|
||||
{
|
||||
mark_called ();
|
||||
ret.write<R> (m_v);
|
||||
}
|
||||
|
||||
private:
|
||||
R m_v;
|
||||
};
|
||||
|
||||
template <class R>
|
||||
Methods
|
||||
constant (const std::string &name, const R &v, const std::string &doc = std::string ())
|
||||
{
|
||||
return Methods (new ConstantValueGetter <R> (name, v, doc));
|
||||
}
|
||||
|
||||
struct return_by_value
|
||||
{
|
||||
typedef tl::False is_factory;
|
||||
|
|
|
|||
Loading…
Reference in New Issue