Callable and Function
| 221 | |
| 222 | // Callable and Function |
| 223 | class callable final { |
| 224 | public: |
| 225 | using function_type = std::function<var(vector &)>; |
| 226 | enum class types { |
| 227 | normal, |
| 228 | request_fold, |
| 229 | member_fn, |
| 230 | member_visitor, |
| 231 | force_regular |
| 232 | }; |
| 233 | |
| 234 | private: |
| 235 | function_type mFunc; |
| 236 | types mType = types::normal; |
| 237 | |
| 238 | public: |
| 239 | callable() = delete; |
| 240 | |
| 241 | callable(const callable &) = default; |
| 242 | |
| 243 | explicit callable(function_type func, types type = types::normal) : mFunc(std::move(func)), mType(type) {} |
| 244 | |
| 245 | bool is_request_fold() const |
| 246 | { |
| 247 | return mType == types::request_fold; |
| 248 | } |
| 249 | |
| 250 | bool is_member_fn() const |
| 251 | { |
| 252 | return mType == types::member_fn; |
| 253 | } |
| 254 | |
| 255 | types type() const |
| 256 | { |
| 257 | return mType; |
| 258 | } |
| 259 | |
| 260 | var call(vector &args) const |
| 261 | { |
| 262 | return mFunc(args); |
| 263 | } |
| 264 | |
| 265 | const function_type &get_raw_data() const |
| 266 | { |
| 267 | return mFunc; |
| 268 | } |
| 269 | }; |
| 270 | |
| 271 | enum class fiber_state { |
| 272 | ready, |
nothing calls this directly
no outgoing calls
no test coverage detected