/[ascend]/trunk/pygtk/extmethod.cpp
ViewVC logotype

Contents of /trunk/pygtk/extmethod.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 893 - (show annotations) (download) (as text)
Sun Oct 22 05:18:36 2006 UTC (16 years, 7 months ago) by johnpye
File MIME type: text/x-c++src
File size: 1705 byte(s)
Better plot points in moody diagram model.
Attempt to get rid of some compiler warnings in extmethod.
Better handling of LD_LIBRARY_PATH and ASCENDLIBRARY in ascdev.
Changed default documentation path (to avoid warnings, seems like a scons bug?)
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 CONSOLE_DEBUG("CREATING EXTERNAL PYTHON METHOD");
45
46 ExtMethodRun *runfn;
47 runfn = (ExtMethodRun *)importhandler_getsharedpointer("extpy.method");
48
49 CreateUserFunctionMethod("myextpyfn",runfn,0,"external python function",(void *)obj);
50 e = LookupExtFunc("myextpyfn");
51 }
52 #endif
53
54
55 const char *
56 ExtMethod::getName() const{
57 return ExternalFuncName(e);
58 }
59
60 const char *
61 ExtMethod::getHelp() const{
62 return e->help;
63 }
64
65 const unsigned long
66 ExtMethod::getNumInputs() const{
67 return NumberInputArgs(e);
68 }
69
70 const unsigned long
71 ExtMethod::getNumOutputs() const{
72 return NumberOutputArgs(e);
73 }

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22