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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 367 - (show annotations) (download) (as text)
Fri Mar 10 07:44:59 2006 UTC (19 years, 9 months ago) by johnpye
File MIME type: text/x-csrc
File size: 2142 byte(s)
Trying to fix up johnpye/extfn/extfntest.c to work on Windows (MinGW)
(ie to fix linking problems).
1 #include <stdio.h>
2
3 #include <utilities/ascConfig.h>
4 #include <utilities/error.h>
5 #include <compiler/fractions.h>
6 #include <compiler/compiler.h>
7 #include <compiler/dimen.h>
8 #include <compiler/child.h>
9 #include <general/list.h>
10 #include <compiler/module.h>
11 #include <compiler/childinfo.h>
12 #include <compiler/slist.h>
13 #include <compiler/type_desc.h>
14 #include <compiler/packages.h>
15
16 int addone_prepare(struct Slv_Interp *slv_interp, struct Instance *data, struct gl_list_t *arglist);
17 int addone_calc(struct Slv_Interp *slv_interp, int ninputs, int noutputs, double *inputs, double *outputs, double *jacobian);
18
19 /**
20 This is the function called from "IMPORT extfntest_register FROM extfntest"
21
22 It sets up the functions in this external function library
23 */
24 extern int
25 DLEXPORT extfntest_register(struct Slv_Interp *dummy1,
26 struct Instance *root,
27 struct gl_list_t *arglist,
28 unsigned long dummy4
29 ){
30 const char *addone_help = "This is a test of the dynamic user packages functionality";
31 int result = 0;
32
33 (void)dummy1;(void)root;(void)arglist;(void)dummy4;
34
35 ERROR_REPORTER_HERE(ASC_PROG_NOTE,"Initialising EXTFNTEST...\n");
36
37 result += CreateUserFunction("add_one",
38 (ExtEvalFunc *)addone_prepare,
39 (ExtEvalFunc **)addone_calc,
40 (ExtEvalFunc **)NULL,
41 (ExtEvalFunc **)NULL,
42 1,1,addone_help);
43
44 FPRINTF(ASCERR,"CreateUserFunction result = %d\n",result);
45 return result;
46 }
47
48 int addone_prepare(struct Slv_Interp *slv_interp,
49 struct Instance *data,
50 struct gl_list_t *arglist
51 ){
52 FPRINTF(ASCERR,"PREPARING PKG EXTFNTEST...\n");
53 const char *mystring = "MY STRING IS HERE";
54 slv_interp->user_data = (void *)mystring;
55 }
56
57 int addone_calc(struct Slv_Interp *slv_interp,
58 int ninputs, int noutputs,
59 double *inputs, double *outputs,
60 double *jacobian
61 ){
62 char *mystring = (char *)slv_interp->user_data;
63
64 FPRINTF(ASCERR,"ADDONE_CALC: mystring = %s\n",mystring);
65
66 FPRINTF(ASCERR,"NINPUTS = %d, NOUTPUTS = %d\n",ninputs, noutputs);
67
68 double *x = &(inputs[0]);
69
70 double *y = &(outputs[0]);
71
72 y = x + 1;
73
74 return 1; /* success */
75 }

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