File: structcreate.c

package info (click to toggle)
scilab 4.0-12
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 100,640 kB
  • ctags: 57,333
  • sloc: ansic: 377,889; fortran: 242,862; xml: 179,819; tcl: 42,062; sh: 10,593; ml: 9,441; makefile: 4,377; cpp: 1,354; java: 621; csh: 260; yacc: 247; perl: 130; lex: 126; asm: 72; lisp: 30
file content (175 lines) | stat: -rw-r--r-- 3,675 bytes parent folder | download | duplicates (2)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include "../stack-c.h"
/*
int C2F(test)()
{
  int sz[3],nz,nf,retval;
  char* fnames[2];
  
  printf("ici\n");
  sz[0]=2;
  sz[1]=3;
  sz[2]=2;
  nz=3;

  fnames[0]="A";
  fnames[1]="Foo";
  nf=2;
  Top = Top +1;
  C2F(structcreate)(&Top, &nz, sz, &nf, fnames, &retval);
printf("la\n");
}
*/

#define memused(it,mn) ((((mn)*( it % 10))/sizeof(int))+1)

#include "../stack-c.h"
/* Table of constant values */

static integer c17 = 17;
static integer c1 = 1;
static integer c4 = 4;

int C2F(structcreate)(lw, nz, sz, nf, fnames,retval)
integer *lw, *nz, *sz, *nf, *retval;
char *fnames[];
{
    integer next,k,lr;

    static integer l;
    static integer l0, n1, il;

    *retval = 0;
    l0 = *Lstk(*lw);

    C2F(intersci).ntypes[*lw -Top + Rhs - 1] = '$';
    C2F(intersci).iwhere[*lw -Top + Rhs - 1] = *Lstk(*lw);

    if (*lw > intersiz) {
      Scierror(998,"Too many arguments in the stack edit stack.h and enlarge intersiz\r\n");
	return 1;
    }
/*     size of first entry of the mlist (type) */
    structtyp(&n1, "size");

    *retval = 1;

/*     create the mlist header */
    il = iadr(l0);
    Err = sadr(il+6) + n1 - *Lstk(Bot);
    if (Err > 0) {
	C2F(error)(&c17);
	return 1;
    }
    *istk(il) = 17;
    *istk(il+1) = 3+*nf;
    *istk(il + 2) = 1;

/*     set mlist type entry */
    l = sadr(il+6+*nf);
    structtyp(istk(iadr(l)), "set");
    *istk(il + 3) = *istk(il + 2) + n1;
    l += n1;
/*     set dims entry (int32 matrix) */
    if (!C2F(creimati)("structcreate", &l, &c4, nz, &c1, &lr, &c1,  12L)) return 1;
    C2F(icopy)(nz,sz,&c1,istk(lr),&c1);
    n1 = sadr(iadr(l)+4) + memused(c4,*nz) - l;
    *istk(il + 4) = *istk(il + 3) + n1;
    l += n1;
/*     set fields names entry (vector of strings)*/
    if (!cre_smat_from_str_i("structcreate", &l, nf, &c1, fnames, 12L ,&next)) return 1;
    n1 = next - l;
    *istk(il + 5) = *istk(il + 4) + n1;
    l += n1;
/*     set struct fields (empty lists)*/
    for (k=0;k<*nf;k++)
      {
	creemptylist(&l,&next);
	n1 = next - l;
	l += n1;
	*istk(il + 6 + k) = *istk(il + 5 + k) + n1;
      }
    *Lstk(*lw+1)=l;
} 


int creemptylist(slw,lw)
     integer *slw, *lw;
{
  integer ix1;
  integer il;
  il = iadr(*slw);
  *istk(il ) = 15;
  *istk(il + 1) = 0;
  *istk(il + 2) = 1;
  ix1 = il +  + 3;
  *lw = sadr(ix1);
  return 0;
}
int structtyp(ivt, job)
integer *ivt;
char *job;
{

    /* Local variables */
    static integer l;

/*     definition of first field  of tlist's type: struct */
/*     tlist fields are: */
/*     dims */
/*     fields */


    /* Parameter adjustments */
    --ivt;

    if (strcmp(job, "size") == 0) {
/*        size of the data structure */
	ivt[1] = 24;
    } else if (strcmp(job, "nchar") == 0) {
/*        number of chars defining the type field */
	ivt[1] = 16;
    } else if (strcmp(job, "nfield") == 0) {
/*        number of fields in the tlist */
	ivt[1] = 3;
    } else if (strcmp(job, "ptr") == 0) {
/*        pointers on individual strings */
	ivt[1] = 1;
	ivt[2] = 7;
	ivt[3] = 11;
	ivt[4] = 17;
    } else {
/*        Character string Variable header */
	ivt[1] = 10;
	ivt[2] = 1;
	ivt[3] = 3;
	ivt[4] = 0;
	ivt[5] = 1;
	l = 8;
/*        entry (1,1) = "struct" */
	ivt[l + 1] = 28;
	ivt[l + 2] = 29;
	ivt[l + 3] = 27;
	ivt[l + 4] = 30;
	ivt[l + 5] = 12;
	ivt[l + 6] = 29;
	ivt[6] = ivt[5] + 6;
	l += 6;
/*        entry (2,1) = "dims" */
	ivt[l + 1] = 13;
	ivt[l + 2] = 18;
	ivt[l + 3] = 22;
	ivt[l + 4] = 28;
	ivt[7] = ivt[6] + 4;
	l += 4;
/*        entry (3,1) = "fields" */
	ivt[l + 1] = 15;
	ivt[l + 2] = 18;
	ivt[l + 3] = 14;
	ivt[l + 4] = 21;
	ivt[l + 5] = 13;
	ivt[l + 6] = 28;
	ivt[8] = ivt[7] + 6;
	l += 6;
    }
    return 0;
} /* structtyp_ */