forked from APrioriInvestments/typed_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyFunctionInstance.hpp
More file actions
40 lines (28 loc) · 1.87 KB
/
Copy pathPyFunctionInstance.hpp
File metadata and controls
40 lines (28 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include "PyInstance.hpp"
class PyFunctionInstance : public PyInstance {
public:
typedef Function modeled_type;
Function* type();
static bool pyValCouldBeOfTypeConcrete(modeled_type* type, PyObject* pyRepresentation) {
return true;
}
static std::pair<bool, PyObject*> tryToCall(const Function* f, PyObject* arg0=nullptr, PyObject* arg1=nullptr, PyObject* arg2=nullptr);
static std::pair<bool, PyObject*> tryToCallOverload(const Function::Overload& f, PyObject* self, PyObject* args, PyObject* kwargs);
//perform a linear scan of all specializations contained in overload and attempt to dispatch to each one.
//returns <true, result or none> if we dispatched.
static std::pair<bool, PyObject*> dispatchFunctionCallToNative(const Function::Overload& overload, PyObject* argTuple, PyObject *kwargs);
//attempt to dispatch to this one exact specialization by converting each arg to the relevant type. if
//we can't convert, then return <false, nullptr>. If we do dispatch, return <true, result or none> and set
//the python exception if native code returns an exception.
static std::pair<bool, PyObject*> dispatchFunctionCallToCompiledSpecialization(
const Function::Overload& overload,
const Function::CompiledSpecialization& specialization,
PyObject* argTuple,
PyObject *kwargs
);
static PyObject* createOverloadPyRepresentation(Function* f);
PyObject* tp_call_concrete(PyObject* args, PyObject* kwargs);
static std::string argTupleTypeDescription(PyObject* args, PyObject* kwargs);
static void mirrorTypeInformationIntoPyTypeConcrete(Function* inType, PyTypeObject* pyType);
};