// $Id$ #ifndef __rf_func_ih__ #define __rf_func_ih__ #include "rf_func.hh" #include "rf_retval.ih" #include "rf_symbol.ih" #include "rf_char.ih" namespace rftype { using namespace rfrt ; namespace FuncInternals { RF_DECL (Codes2Rfp); } inline Func::Func (rf_func_t _func, wchar_t* _name) : func (_func), name (_name), length (0) {} inline RetVal Func::operator () () const { return func(); } inline void Func::name_to_rfp () { if (length) return; // Expr e = Expr::create(name); // RF_CALL(refal::CppMangle::Cpp2Rfp, e, e); Expr e = Expr::create_seq(name, wcslen(name)); RF_CALL(FuncInternals::Codes2Rfp, e, e); pxx::WString str = e; length = str.get_length() + 1; name = static_cast(malloc((length + 1) * sizeof(wchar_t))); if (!name) FATAL("Out of memory"); wmemcpy(name + 1, str.get_data(), length); name[0] = L'&'; } inline size_t Func::get_name (wchar_t const** _name) { name_to_rfp(); *_name = name + 1; return length - 1; } inline pxx::WString Func::to_string () { name_to_rfp(); return pxx::WString(name, length, pxx::const_data); } RF_NEW_SYMBOL(Func, StaticTerm); template <> inline size_t RF_SYMBOL(Func)::get_name ( RF_SYMBOL(Func) const* _s, wchar_t const** _name ) { return _s->get_obj_ptr()->get_name(_name); } template <> inline pxx::WString RF_SYMBOL(Func)::to_string (RF_SYMBOL(Func) const* _s) { return _s->get_obj_ptr()->to_string(); } } #endif // __rf_func_ih__