1 |
#include "extmethod.h" |
2 |
|
3 |
#include <stdexcept> |
4 |
using namespace std; |
5 |
|
6 |
#ifndef ASCXX_USE_PYTHON |
7 |
# error "Where's ASCXX_USE_PYTHON?" |
8 |
#endif |
9 |
|
10 |
/*--- WARNING --- |
11 |
In the C++ interface I'm trying to make the nomenclature |
12 |
a bit more systematic. 'ExternalFunc' as listed end up |
13 |
being things that you can call like 'asc_free_all_vars' -- |
14 |
they are effectively externally-defined methods on ASCEND |
15 |
models, so I'll call then 'external methods'. |
16 |
|
17 |
Meanwhile, external relations I will call 'ExtRelation'. |
18 |
|
19 |
External functions, if ever implemented, will be for |
20 |
functions like 'sin', 'exp', etc. |
21 |
*/ |
22 |
|
23 |
ExtMethod::ExtMethod(const struct ExternalFunc *e) : e(e) { |
24 |
// nothing else |
25 |
} |
26 |
|
27 |
ExtMethod::ExtMethod(const ExtMethod &old) : e(old.e) { |
28 |
// nothing else |
29 |
} |
30 |
|
31 |
ExtMethod::ExtMethod(){ |
32 |
throw runtime_error("Can't create empty ExtMethod"); |
33 |
} |
34 |
|
35 |
#ifdef ASCXX_USE_PYTHON |
36 |
/** |
37 |
Declare and register a new external script method from Python |
38 |
|
39 |
@TODO not sure if this is the right place for this... problems when creating |
40 |
the method might cause problems. Perhaps it should be in the 'library' |
41 |
object instead? |
42 |
*/ |
43 |
ExtMethod::ExtMethod(PyObject *obj){ |
44 |
throw runtime_error("Not allowed here"); |
45 |
} |
46 |
#endif |
47 |
|
48 |
|
49 |
const char * |
50 |
ExtMethod::getName() const{ |
51 |
return ExternalFuncName(e); |
52 |
} |
53 |
|
54 |
const char * |
55 |
ExtMethod::getHelp() const{ |
56 |
return e->help; |
57 |
} |
58 |
|
59 |
const unsigned long |
60 |
ExtMethod::getNumInputs() const{ |
61 |
return NumberInputArgs(e); |
62 |
} |
63 |
|
64 |
const unsigned long |
65 |
ExtMethod::getNumOutputs() const{ |
66 |
return NumberOutputArgs(e); |
67 |
} |