Example #1
0
ff::Signature ff::SignatureParser::parse2(const std::string &str, std::string::size_type pos)
{
    Signature sign;

    string::size_type rpos, lpos;

    if ((rpos = str.rfind(')', pos)) == string::npos) {
        return sign;
    }

    if ((lpos = str.find('(')) == string::npos) {
        return sign;
    }

    sign.arg_list = parseArgument(str, lpos, rpos);

    {// return type
        string rt = cc::trim(str.substr(pos + 2));

        sign.return_type = rt.empty() ? ReturnType(ff::T_Any) : ReturnType(rt);
    }
    {// function name
        string fn = cc::trim(str.substr(0, lpos));

        sign.func_name = fn.empty() ? FuncName(ff::T_Any) : FuncName(fn);
    }

    return sign;
}
        ReturnType operator()(A1... a1) const
        {
                typename FuncMap::const_iterator it = m_funcs.find(typeid(ReturnType(A1...)));

                if (it != m_funcs.end())
                {
                        ReturnType(*f)(A1...) = (ReturnType(*)(A1...))(it->second);
                        (*f)(a1...);
                }
        }
Example #3
0
ReturnType Function<ReturnType, Arguments...>::operator()(Arguments&... arguments) const
{
    auto myAddress = address();

    if (myAddress != nullptr)
    {
        if (isAnyEnabled(CallbackMask::Before | CallbackMask::After | CallbackMask::Logging))
        {
            return FunctionHelper<ReturnType, Arguments...>().call(this, std::forward<Arguments>(arguments)...);
        }
        else
        {
            return FunctionHelper<ReturnType, Arguments...>().basicCall(this, std::forward<Arguments>(arguments)...);
        }
    }
    else
    {
         if (isEnabled(CallbackMask::Unresolved))
         {
            unresolved();
         }

         return ReturnType();
    }
}
Example #4
0
 static inline ReturnType sum_interior_rings(Rings const& rings, Strategy const& strategy)
 {
     ReturnType sum = ReturnType();
     for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
     {
         sum += Policy::apply(*it, strategy);
     }
     return sum;
 }
Example #5
0
ReturnType reduce(Iterator begin, Iterator end, Func fn) {
    // if range is empty, return a default-constructed element
    if (begin == end)
        return ReturnType();
    ReturnType t = *(begin++);
    for (; begin != end; ++begin) {
        t = fn(t, *begin);
    }
    return t;
}
Example #6
0
ReturnType type_punning(OriginalType variable) noexcept
{
    union Both {
        OriginalType in;
        ReturnType out;
    };
    Both both;
    both.out = ReturnType(); // Clear all bits in case ReturnType is larger than OriginalType
    both.in = variable;
    return both.out;
}
ReturnType IntegratorFunction::call(std::vector<Program::Parameter> &params) {

    for (int i = 0; i < m_returnValues.size(); ++i) {
        params.push_back(m_returnValues[i]->getParameter());
    }
    ProgramLauncher::launch(m_program, params, false);

    if(m_returnValues.size() == 1)
        return ReturnType(m_returnValues[0]);
    else
        return Collection::glob(m_returnValues);
}
Example #8
0
ff::Signature ff::SignatureParser::parse1(const std::string &str)
{
    Signature sign;

    string::size_type rpos, lpos;

    if ((rpos = str.rfind(')')) == string::npos) {
        return sign;
    }

    if ((lpos = str.find('(')) == string::npos) {
        return sign;
    }

    sign.arg_list = parseArgument(str, lpos, rpos);

    {// parse return and name
        string rn = str.substr(0, lpos);

        string::size_type space_pos = 0;

        if ((space_pos = rn.rfind(' ')) == string::npos) {
            sign.func_name      = rn.empty() ? FuncName(ff::T_Any) : FuncName(rn);
        } else {
            string rnt = cc::trim(rn.substr(0, space_pos));

            sign.return_type    = rnt.empty() ? ReturnType(ff::T_Any) : ReturnType(rnt);

            string fn = cc::trim(rn.substr(space_pos));

            sign.func_name      = fn.empty() ? FuncName(ff::T_Any) : FuncName(fn);
        }

        if (sign.return_type.name == string("void")) {
            sign.return_type.type = ff::T_Void;
        }
    }

    return sign;
}
Example #9
0
 ReturnType transmit (ArgumentTypes ... arguments) {
   HandlerNode * cursor = m_head;
   while (cursor != nullptr) {
     if (cursor == m_tail) {
       return cursor->handler(std::forward<ArgumentTypes>(arguments)...);
     }
     
     cursor->handler(std::forward<ArgumentTypes>(arguments)...);
     cursor = cursor->next;
   }
   
   return ReturnType();
 }
Example #10
0
 static inline ReturnType apply(MultiGeometry const& geometry, Strategy const& strategy)
 {
     ReturnType sum = ReturnType();
     for (typename pdalboost::range_iterator
             <
                 MultiGeometry const
             >::type it = pdalboost::begin(geometry);
         it != pdalboost::end(geometry);
         ++it)
     {
         sum += Policy::apply(*it, strategy);
     }
     return sum;
 }
Example #11
0
bool
FunctionType::canCastTo (Type* dest_ty) const
{
   if (!st::isa<st::FunctionType>(dest_ty)) return false;

   st::FunctionType* dest = st::cast<st::FunctionType>(dest_ty);
   if (dest->ArgumentCount() != ArgumentCount()) return false;
   if (dest->ReturnType() != ReturnType()) return false;

   for (size_t i = 0; i < ArgumentCount(); ++i)
   {
      if (!getArgument(i)->canCastTo(dest->getArgument(i))) return false;
   }
   return true;
}
Example #12
0
	void Load()
	{
		constexpr auto LIBNAME = "OpenAL32.dll";
		static void* handle = dlopen(LIBNAME, RTLD_LAZY);
		if(!handle)
		{
			throw WeakLinkingError(std::string("Could not open ") + LIBNAME + ".");
		}
		ReturnType (*symbol)(Args...);
		*reinterpret_cast<void**>(&symbol) = dlsym(handle, name_.c_str());
		function_ = symbol;
		if(!function_)
		{
			throw WeakLinkingError(std::string("Could not find ") + name_ + " in " + LIBNAME + ".");
		}
	}
 void single(char *dst, char *const *DYND_UNUSED(src)) {
   *reinterpret_cast<ReturnType *>(dst) = ReturnType(d_real(g), d_imag(g));
 }
Example #14
0
 static inline ReturnType apply(Geometry const& , Strategy const&)
 {
     return ReturnType();
 }
Example #15
0
 inline ReturnType unserialize()
 {
     ReturnType ret = ReturnType();
     unserialize(ret);
     return ret;
 }
 VariadicFuncMap<ReturnType> add (ReturnType(*f)(A1...))
 {
         m_funcs[typeid(ReturnType(A1...))] = (ReturnType(*)()) f;
         return *this;
 }
Example #17
0
 static ReturnType onUnknownVisitor(VisitableType&, AcyclicBaseVisitor&)
 { return ReturnType(); }
Example #18
0
 ReturnType handle (const gtp::Command<t, ReturnType, Params...>& cmd)
 {
     commands_.push_back(cmd);
     return ReturnType();
 }
 inline ReturnType operator()( Boolean const & arg ) const
 {
     return ReturnType(arg.value() ? 1.0 : 0.0);
 }
 inline ReturnType operator()( Integer const & arg ) const
 {
     return ReturnType(arg.value()*1.0);
 }
 inline ReturnType operator()( Double const & arg ) const
 {
     return ReturnType(arg.value() ? 1 : 0);
 }
Example #22
0
 static ReturnType on_parse_error(const char *string, size_t index)
 {
   static_assert(std::is_same<ReturnType, float>::value, "math_eval: the return type must be <float>");
   std::cerr << "Could not parse the string: " << (string + index) << std::endl;
   return ReturnType(-1);
 }