/[ascend]/trunk/models/johnpye/extfn/extfntest.c
ViewVC logotype

Annotation of /trunk/models/johnpye/extfn/extfntest.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 466 - (hide annotations) (download) (as text)
Sun Apr 16 15:07:48 2006 UTC (19 years, 7 months ago) by johnpye
File MIME type: text/x-csrc
File size: 1979 byte(s)
Rolled back revision 451, since the DLL loading issue on Windows is now resolved.
Fixed up some #ifdef brackets in slv*.h headers.
Added NSIS functionality to SConstruct file
Renamed default installer to 'ascend-setup.exe' pending a more clever approach to version numbers.
1 johnpye 209 #include <stdio.h>
2    
3 johnpye 380 #include <utilities/error.h>
4    
5 johnpye 209 #include <utilities/ascConfig.h>
6 johnpye 380
7 johnpye 209 #include <compiler/fractions.h>
8     #include <compiler/compiler.h>
9     #include <compiler/dimen.h>
10     #include <compiler/child.h>
11     #include <general/list.h>
12     #include <compiler/module.h>
13     #include <compiler/childinfo.h>
14     #include <compiler/slist.h>
15     #include <compiler/type_desc.h>
16     #include <compiler/packages.h>
17    
18     int addone_prepare(struct Slv_Interp *slv_interp, struct Instance *data, struct gl_list_t *arglist);
19     int addone_calc(struct Slv_Interp *slv_interp, int ninputs, int noutputs, double *inputs, double *outputs, double *jacobian);
20    
21     /**
22 johnpye 381 This is the function called from "IMPORT extfntest"
23 johnpye 209
24     It sets up the functions in this external function library
25     */
26 johnpye 380
27 johnpye 209 extern int
28 johnpye 466 DLEXPORT extfntest_register(){
29 johnpye 209 const char *addone_help = "This is a test of the dynamic user packages functionality";
30     int result = 0;
31    
32 johnpye 381 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Initialising EXTFNTEST...\n");
33 johnpye 209
34 johnpye 466 result += CreateUserFunction("add_one",
35 johnpye 209 (ExtEvalFunc *)addone_prepare,
36     (ExtEvalFunc **)addone_calc,
37     (ExtEvalFunc **)NULL,
38     (ExtEvalFunc **)NULL,
39     1,1,addone_help);
40    
41 johnpye 380 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"CreateUserFunction result = %d\n",result);
42 johnpye 209 return result;
43     }
44    
45     int addone_prepare(struct Slv_Interp *slv_interp,
46     struct Instance *data,
47     struct gl_list_t *arglist
48     ){
49 johnpye 380 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"PREPARING PKG EXTFNTEST...\n");
50 johnpye 209 const char *mystring = "MY STRING IS HERE";
51     slv_interp->user_data = (void *)mystring;
52     }
53    
54     int addone_calc(struct Slv_Interp *slv_interp,
55     int ninputs, int noutputs,
56     double *inputs, double *outputs,
57     double *jacobian
58     ){
59     char *mystring = (char *)slv_interp->user_data;
60    
61 johnpye 380 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"ADDONE_CALC: mystring = %s\n",mystring);
62 johnpye 209
63 johnpye 380 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"NINPUTS = %d, NOUTPUTS = %d\n",ninputs, noutputs);
64 johnpye 209
65     double *x = &(inputs[0]);
66 johnpye 367
67 johnpye 209 double *y = &(outputs[0]);
68    
69     y = x + 1;
70    
71     return 1; /* success */
72     }

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