#include <string.h>#include <stdio.h>#include "machine.h"#include "stack-c.h"#include "scicos_block4.h"Include dependency graph for sciblk4.c:

Go to the source code of this file.
Functions | |
| integer C2F() | scierr () |
| void C2F() | scifunc () |
| int * | listentry (int *header, int i) |
| int | var2sci (void *x, int n, int m, int typ_var) |
| int | createblklist (scicos_block *Blocks, int *ierr, int flag_imp) |
| int | sci2var (void *x, void *y, int typ_var) |
| void | sciblk4 (scicos_block *Blocks, integer flag) |
| int createblklist | ( | scicos_block * | Blocks, | |
| int * | ierr, | |||
| int | flag_imp | |||
| ) |
Definition at line 2456 of file intcscicos.c.
References Blocks, buf, C2F, FREE, g, getscicosvarsfromimport(), scicos_block::insz, label, MALLOC, mklist(), mktlist(), mode, nblk, ng, scicos_block::nin, scicos_block::nout, nout, scicos_block::nrpar, nu, NULL, nv, scicos_block::nz, outptr, scicos_block::outsz, res, scicos_block::rpar, scierr(), str1, str2sci(), type, var2sci(), vvtosci(), scicos_block::work, x, xd, xptr, z, scicos_block::z, and zcptr.
02457 { 02458 /*local variable declaration*/ 02459 int k; 02460 int nu,mu,ny,my; 02461 int u_typ,y_typ; 02462 02463 /*variable used when imp_flag>=0*/ 02464 int nv,mv; /* length of data */ 02465 int nblk,ng; /* to store number of blocks and number of zero cross. */ 02466 void *ptr; /* ptr for data comming from import structure */ 02467 int *ptr_int; /* ptr to store ptr on integer */ 02468 double *ptr_double; /* ptr to store ptr on double */ 02469 int *xptr, *zcptr; /* to retrieve xptr by import and zcptr of scicos_blocks */ 02470 double *x,*xd,*g; /* ptr for x, xd and g for scicos_blocks */ 02471 02472 /* set length of block list -please update me- */ 02473 static int nblklst=31; 02474 /* set string of first element of scilab Blocks tlist -please update me- */ 02475 static char *str_blklst[]={ "scicos_block", "nevprt" , "funpt" , "type" , 02476 "scsptr" , "nz" , "z" , "nx" , 02477 "x" , "xd" , "res" , "nin" , 02478 "insz" , "inptr" , "nout" , "outsz" , 02479 "outptr" , "nevout" , "evout" , "nrpar" , 02480 "rpar" , "nipar" , "ipar" , "ng" , 02481 "g" , "ztyp" , "jroot" , "label" , 02482 "work" , "nmode" , "mode"}; 02483 02484 /* char ptr for str2sci - see below - */ 02485 char **str1; 02486 02487 02488 /* set nblk, x, xd ptr coming from import strucuture, 02489 * if flag_imp >=0 02490 */ 02491 if (flag_imp>=0) 02492 { 02493 /*retrieve nblk by import structure*/ 02494 strcpy(C2F(cha1).buf,"nblk"); 02495 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02496 if (*ierr==0) return 0; 02497 ptr_int = (int *) ptr; 02498 nblk = *ptr_int; 02499 02500 /* retrieve ng by import structure */ 02501 strcpy(C2F(cha1).buf,"ng"); 02502 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02503 ptr_int = (int *) ptr; /* cast void* ptr to int* ptr */ 02504 ng = *ptr_int; 02505 02506 /*retrieve xptr by import structure*/ 02507 strcpy(C2F(cha1).buf,"xptr"); 02508 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02509 if (*ierr==0) return 0; 02510 ptr_int = (int *) ptr; 02511 xptr = ptr_int; 02512 02513 /*retrieve zcptr by import structure*/ 02514 strcpy(C2F(cha1).buf,"zcptr"); 02515 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02516 ptr_int = (int *) ptr; 02517 zcptr = ptr_int; 02518 02519 /*retrieve x and xd by import structure*/ 02520 strcpy(C2F(cha1).buf,"x"); 02521 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02522 if (*ierr==0) return 0; 02523 ptr_double = (double *) ptr; 02524 x = ptr_double; 02525 xd = &x[xptr[nblk]-1]; 02526 02527 /*retrieve g by import structure*/ 02528 strcpy(C2F(cha1).buf,"g"); 02529 *ierr=getscicosvarsfromimport(C2F(cha1).buf,&ptr,&nv,&mv); 02530 ptr_double = (double *) ptr; 02531 g = ptr_double; 02532 } 02533 02534 /**************************** 02535 * create scilab tlist Blocks 02536 ****************************/ 02537 /* 1 - scicos_block */ 02538 str2sci(str_blklst,1,31); 02539 02540 /* 2 - nevprt */ 02541 *ierr=var2sci(&Blocks[0].nevprt,1,1,80); 02542 if (*ierr!=0) return 0; 02543 02544 /* 3 - funpt */ 02545 *ierr=var2sci(&Blocks[0].funpt,0,1,80); /* !!!! */ 02546 if (*ierr!=0) return 0; 02547 02548 /* 4 - type */ 02549 *ierr=var2sci(&Blocks[0].type,1,1,80); /* !!!! */ 02550 if (*ierr!=0) return 0; 02551 02552 /* 5 - scsptr */ 02553 *ierr=var2sci(&Blocks[0].scsptr,0,1,80); /* !!!! */ 02554 if (*ierr!=0) return 0; 02555 02556 /* 6 - nz */ 02557 *ierr=var2sci(&Blocks[0].nz,1,1,80); 02558 if (*ierr!=0) return 0; 02559 02560 /* 7 - z */ 02561 if(Blocks[0].scsptr>0) 02562 { 02563 C2F(vvtosci)(Blocks[0].z,&Blocks[0].nz); 02564 if (C2F(scierr)()!=0) return 0; 02565 } 02566 else 02567 { 02568 *ierr=var2sci(Blocks[0].z,Blocks[0].nz,1,10); 02569 if (*ierr!=0) return 0; 02570 } 02571 02572 /* 8 - nx */ 02573 *ierr=var2sci(&Blocks[0].nx,1,1,80); 02574 if (*ierr!=0) return 0; 02575 02576 /* 9 - x */ 02577 if (flag_imp>=0) *ierr=var2sci(&x[xptr[flag_imp]-1],Blocks[0].nx,1,10); 02578 else *ierr=var2sci(Blocks[0].x,Blocks[0].nx,1,10); 02579 if (*ierr!=0) return 0; 02580 02581 /* 10 - xd */ 02582 if (flag_imp>=0) *ierr=var2sci(&xd[xptr[flag_imp]-1],Blocks[0].nx,1,10); 02583 else *ierr=var2sci(Blocks[0].xd,Blocks[0].nx,1,10); 02584 if (*ierr!=0) return 0; 02585 02586 /* 11 - res */ 02587 *ierr=var2sci(Blocks[0].res,Blocks[0].nx,1,10); 02588 if (*ierr!=0) return 0; 02589 02590 /* 12 - nin */ 02591 *ierr=var2sci(&Blocks[0].nin,1,1,80); 02592 if (*ierr!=0) return 0; 02593 02594 /* 13 - insz */ 02595 *ierr=var2sci(Blocks[0].insz,3*Blocks[0].nin,1,80); 02596 if (*ierr!=0) return 0; 02597 02598 /* 14 - inptr */ 02599 for (k=0;k<Blocks[0].nin;k++) 02600 { 02601 nu=Blocks[0].insz[k]; /* retrieve number of rows */ 02602 mu=Blocks[0].insz[Blocks[0].nin+k]; /* retrieve number of cols */ 02603 u_typ=Blocks[0].insz[2*Blocks[0].nin+k]; /* retrieve type */ 02604 *ierr=var2sci(Blocks[0].inptr[k],nu,mu,u_typ); 02605 if (*ierr!=0) return 0; 02606 } 02607 C2F(mklist)(&Blocks[0].nin); /*create inptr list*/ 02608 02609 /* 15 - nout */ 02610 *ierr=var2sci(&Blocks[0].nout,1,1,80); 02611 if (*ierr!=0) return 0; 02612 02613 /* 16 - outsz */ 02614 *ierr=var2sci(Blocks[0].outsz,3*Blocks[0].nout,1,80); 02615 if (*ierr!=0) return 0; 02616 02617 /* 17 - outptr */ 02618 for (k=0;k<Blocks[0].nout;k++) 02619 { 02620 ny=Blocks[0].outsz[k]; /* retrieve number of rows */ 02621 my=Blocks[0].outsz[Blocks[0].nout+k]; /* retrieve number of cols */ 02622 y_typ=Blocks[0].outsz[2*Blocks[0].nout+k]; /* retrieve type */ 02623 *ierr=var2sci(Blocks[0].outptr[k],ny,my,y_typ); 02624 if (*ierr!=0) return 0; 02625 } 02626 C2F(mklist)(&Blocks[0].nout); /*create outptr list*/ 02627 02628 /* 18 - nevout */ 02629 *ierr=var2sci(&Blocks[0].nevout,1,1,80); 02630 if (*ierr!=0) return 0; 02631 02632 /* 19 - evout */ 02633 *ierr=var2sci(Blocks[0].evout,Blocks[0].nevout,1,10); 02634 if (*ierr!=0) return 0; 02635 02636 /* 20 - nrpar */ 02637 *ierr=var2sci(&Blocks[0].nrpar,1,1,80); 02638 if (*ierr!=0) return 0; 02639 02640 /* 21 - rpar */ 02641 if(Blocks[0].scsptr>0) 02642 { 02643 C2F(vvtosci)(Blocks[0].rpar,&Blocks[0].nrpar); 02644 if (C2F(scierr)()!=0) return 0; 02645 } 02646 else 02647 { 02648 *ierr=var2sci(Blocks[0].rpar,Blocks[0].nrpar,1,10); 02649 if (*ierr!=0) return 0; 02650 } 02651 02652 /* 22 - nipar */ 02653 *ierr=var2sci(&Blocks[0].nipar,1,1,80); 02654 if (*ierr!=0) return 0; 02655 02656 /* 23 - ipar */ 02657 *ierr=var2sci(Blocks[0].ipar,Blocks[0].nipar,1,80); 02658 if (*ierr!=0) return 0; 02659 02660 /* 24 - ng */ 02661 *ierr=var2sci(&Blocks[0].ng,1,1,80); 02662 if (*ierr!=0) return 0; 02663 02664 /* 25 - g */ 02665 if (flag_imp>=0) *ierr=var2sci(&g[zcptr[flag_imp]-1],Blocks[0].ng,1,10); 02666 else *ierr=var2sci(Blocks[0].g,Blocks[0].ng,1,10); 02667 if (*ierr!=0) return 0; 02668 02669 /* 26 - ztyp */ 02670 *ierr=var2sci(&Blocks[0].ztyp,1,1,80); 02671 if (*ierr!=0) return 0; 02672 02673 /* 27 - jroot */ 02674 *ierr=var2sci(Blocks[0].jroot,Blocks[0].ng,1,80); 02675 if (*ierr!=0) return 0; 02676 02677 /* 28 - label */ 02678 if ((str1=MALLOC(sizeof(char*))) ==NULL ) return 0; 02679 if ((str1[0]=MALLOC(sizeof(char)*(strlen(Blocks[0].label)+1))) ==NULL ) return 0; 02680 (str1[0])[strlen(Blocks[0].label)]='\0'; 02681 strncpy(str1[0],Blocks[0].label,strlen(Blocks[0].label)); 02682 str2sci(str1,1,1); 02683 FREE(str1[0]); 02684 FREE(str1); 02685 if (C2F(scierr)()!=0) return 0; 02686 02687 /* 29 - work*/ 02688 C2F(vvtosci)(*Blocks[0].work,(k=0,&k)); 02689 if (C2F(scierr)()!=0) return 0; 02690 02691 /* 30 - nmode*/ 02692 *ierr=var2sci(&Blocks[0].nmode,1,1,80); 02693 if (*ierr!=0) return 0; 02694 02695 /* 31 - mode */ 02696 *ierr=var2sci(Blocks[0].mode,Blocks[0].nmode,1,80); 02697 if (*ierr!=0) return 0; 02698 02699 C2F(mktlist)(&nblklst); /*create Blocks list*/ 02700 if (C2F(scierr)()!=0) return 0; 02701 02702 /*return 1 if succeeded */ 02703 return 1; 02704 }
Here is the call graph for this function:

TODO : comment
| header | ||
| i |
Definition at line 120 of file mexlib.c.
References NULL.
00121 { 00122 /*Usage int *header = header(array_ptr) 00123 * int *headersub = listentry(header, k) 00124 * then headersub[0] ... is the header of the kth object in the 00125 * list array_ptr */ 00126 int n, *ptr; 00127 n = header[1]; 00128 if (i <= n) { 00129 if ( n%2 == 0 ) n++; 00130 /* n = n if n odd, n=n+1 if n even (=> n is odd and ptr even !) */ 00131 ptr = (int *) header + 3 + n + 2*( header[2 + (i - 1) ] -1); 00132 return ptr; 00133 } else { 00134 return NULL; 00135 } 00136 }
Definition at line 434 of file sciblk4.c.
References C2F, err, i, j, m, n, typ, and unsfdcopy().
Referenced by sciblk4().
00435 { 00436 /************************************ 00437 * variables and constants définition 00438 ************************************/ 00439 /* counter and address variable declaration */ 00440 int err,i,j; 00441 00442 /* variables to store n,m and type of scilab object */ 00443 int n,m,nm,typ,sub_typ; 00444 00445 /* define int *header */ 00446 int *header; 00447 00448 /*define all type of accepted ptr */ 00449 double *ptr_d, *y_d; 00450 char *ptr_c, *y_c; 00451 unsigned char *ptr_uc, *y_uc; 00452 short *ptr_s, *y_s; 00453 unsigned short *ptr_us, *y_us; 00454 int *ptr_i, *y_i; 00455 unsigned int *ptr_ui,*y_ui; 00456 long *ptr_l,*y_l; 00457 unsigned long *ptr_ul,*y_ul; 00458 00459 /***************************************** 00460 * get header,n,m and typ of scilab object 00461 *****************************************/ 00462 /* retrieve header address */ 00463 header = (int *) x; 00464 00465 /* retieve number of rows and columns */ 00466 n = header[1]; 00467 m = header[2]; 00468 00469 /* retrieve type of scilab object */ 00470 typ = header[0]; 00471 00472 /* Test if scilab object is a typed scicos 00473 * accepted data */ 00474 if ((typ!=1)&(typ!=8)) 00475 { 00476 err = 1001; 00477 return err; 00478 } 00479 00480 /* retrieve sub_type of scilab object */ 00481 sub_typ = header[3]; 00482 00483 /* cross type of data checking 00484 * and copy scilab object in 00485 * scicos blocks array structure 00486 */ 00487 switch (typ) 00488 { 00489 case 1 : 00490 {/*check type of double matrix*/ 00491 if ((sub_typ!=0)&(sub_typ!=1)) 00492 { 00493 err = 1002; 00494 return err; 00495 } 00496 if ((sub_typ==0)&(typ_var!=10)) 00497 { 00498 err = 1004; 00499 return err; 00500 } 00501 if ((sub_typ==1)&(typ_var!=11)) 00502 { 00503 err = 1004; 00504 return err; 00505 } 00506 00507 /*copy double matrix*/ 00508 switch (sub_typ) 00509 { 00510 case 0 : nm=n*m; 00511 ptr_d = (double *) (header+4); 00512 y_d = (double *) y; 00513 C2F(unsfdcopy)(&nm,ptr_d,(i=-1,&i),y_d,(j=-1,&j)); 00514 break; 00515 00516 case 1 : nm=2*n*m; 00517 ptr_d = (double *) (header+4); 00518 y_d = (double *) y; 00519 C2F(unsfdcopy)(&nm,ptr_d,(i=-1,&i),y_d,(j=-1,&j)); 00520 break; 00521 } 00522 } 00523 break; 00524 00525 case 8 : 00526 {/*check type of integer matrix*/ 00527 if ((sub_typ!=1) & (sub_typ!=2) &(sub_typ!=4) / 00528 (sub_typ!=11) & (sub_typ!=12)&(sub_typ!=14)) 00529 { 00530 err = 1003; 00531 return err; 00532 } 00533 if ((sub_typ==1)&(typ_var!=81)) 00534 { 00535 err = 1004; 00536 return err; 00537 } 00538 if ((sub_typ==2)&(typ_var!=82)) 00539 { 00540 err = 1004; 00541 return err; 00542 } 00543 if ((sub_typ==4)&(typ_var!=80)&(typ_var!=84)) 00544 { 00545 err = 1004; 00546 return err; 00547 } 00548 if ((sub_typ==11)&(typ_var!=811)) 00549 { 00550 err = 1004; 00551 return err; 00552 } 00553 if ((sub_typ==12)&(typ_var!=812)) 00554 { 00555 err = 1004; 00556 return err; 00557 } 00558 if ((sub_typ==14)&(typ_var!=800)&(typ_var!=814)) 00559 { 00560 err = 1004; 00561 return err; 00562 } 00563 00564 /*copy integer matrix*/ 00565 switch (typ_var) 00566 { 00567 case 80 : ptr_i = (int *) (header+4); 00568 y_i = (int *) y; 00569 for(i=0;i<n*m;i++) y_i[i] = ptr_i[i]; 00570 break; 00571 00572 case 81 : ptr_c = (char *) (header+4); 00573 y_c = (char *) y; 00574 for(i=0;i<n*m;i++) y_c[i] = ptr_c[i]; 00575 break; 00576 00577 case 82 : ptr_s = (short *) (header+4); 00578 y_s = (short *) y; 00579 for(i=0;i<n*m;i++) y_s[i] = ptr_s[i]; 00580 break; 00581 00582 case 84 : ptr_l = (long *) (header+4); 00583 y_l = (long *) y; 00584 for(i=0;i<n*m;i++) y_l[i] = ptr_l[i]; 00585 break; 00586 00587 case 800 : ptr_ui = (unsigned int *) (header+4); 00588 y_ui = (unsigned int *) y; 00589 for(i=0;i<n*m;i++) y_ui[i] = ptr_ui[i]; 00590 break; 00591 00592 case 811 : ptr_uc = (unsigned char *) (header+4); 00593 y_uc = (unsigned char *) y; 00594 for(i=0;i<n*m;i++) y_uc[i] = ptr_uc[i]; 00595 break; 00596 00597 case 812 : ptr_us = (unsigned short *) (header+4); 00598 y_us = (unsigned short *) y; 00599 for(i=0;i<n*m;i++) y_us[i] = ptr_us[i]; 00600 break; 00601 00602 case 814 : ptr_ul = (unsigned long *) (header+4); 00603 y_ul = (unsigned long *) y; 00604 for(i=0;i<n*m;i++) y_ul[i] = ptr_ul[i]; 00605 break; 00606 } 00607 } 00608 break; 00609 } 00610 00611 /* return error flag = 0 */ 00612 err = 0; 00613 return 0; 00614 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void sciblk4 | ( | scicos_block * | Blocks, | |
| integer | flag | |||
| ) |
Definition at line 81 of file sciblk4.c.
References C2F, createblklist(), err, g, i, ierr, j, listentry(), Lstk, mlhs, mode, mrhs, nout, outptr, res, sci2var(), scierr(), scifunc(), set_block_error(), stk, Top, unsfdcopy(), var2sci(), x, xd, and z.
Referenced by scicos().
00084 { 00085 /*counter and address variable declaration*/ 00086 int i,j,topsave; 00087 int ierr = 0; 00088 00089 int *header,ne1; 00090 double *le111; 00091 00092 int *il_xd, *il_res, *il_out, *il_outptr, *il_z, *il_x; 00093 int *il_mode, *il_evout, *il_g; 00094 00095 /* variable for output typed port */ 00096 int nout; 00097 00098 /* set number of left and right hand side parameters */ 00099 int mlhs=1,mrhs=2; 00100 00101 /* Save Top counter */ 00102 topsave=Top; 00103 00104 /**************************** 00105 * create scilab tlist Blocks 00106 ****************************/ 00107 if((createblklist(&Blocks[0], &ierr,(i=-1)))==0) goto err; 00108 00109 /* * flag * */ 00110 ierr=var2sci(&flag,1,1,80); 00111 if (ierr!=0) goto err; 00112 00113 /********************** 00114 * Call scilab function 00115 **********************/ 00116 C2F(scifunc)(&mlhs,&mrhs); 00117 if (C2F(scierr)()!=0) goto err; 00118 00119 /*************************** 00120 * Update C block structure 00121 **************************/ 00122 /* get header of output variable Blocks of sciblk4 */ 00123 header = (int *) stk(*Lstk(Top)); 00124 00125 /* switch to appropriate flag */ 00126 switch (flag) 00127 { 00128 case 0 : /* update continuous state */ 00129 { 00130 if (Blocks[0].nx != 0) 00131 { 00132 /* 10 - xd */ 00133 il_xd = (int *) listentry(header,10); 00134 ierr=sci2var(il_xd,Blocks[0].xd,10); /* double */ 00135 if (ierr!=0) goto err; 00136 00137 /* 11 - res */ 00138 il_res = (int *) listentry(header,11); 00139 ierr=sci2var(il_res,Blocks[0].res,10); /* double */ 00140 if (ierr!=0) goto err; 00141 } 00142 } 00143 break; 00144 00145 case 1 : /* update output state */ 00146 { 00147 /* 17 - outptr */ 00148 if (Blocks[0].nout!=0) 00149 { 00150 il_out = (int*) listentry(header,17); 00151 nout = il_out[1]; 00152 00153 for (j=0;j<nout;j++) 00154 { 00155 il_outptr = (int *) listentry(il_out,j+1); 00156 ierr=sci2var(il_outptr,Blocks[0].outptr[j],Blocks[0].outsz[2*nout+j]); 00157 if (ierr!=0) goto err; 00158 } 00159 } 00160 } 00161 break; 00162 00163 case 2 : /* update state */ 00164 { 00165 /* 7 - z */ 00166 if (Blocks[0].nz != 0) 00167 { 00168 il_z = (int *) listentry(header,7); 00169 if(Blocks[0].scsptr>0) 00170 { 00171 le111=(double *) listentry(header,7); 00172 ne1=header[7+2]-header[7+1]; 00173 C2F(unsfdcopy)(&ne1,le111,(i=-1,&i),Blocks[0].z,(j=-1,&j)); 00174 } 00175 else 00176 { 00177 ierr=sci2var(il_z,Blocks[0].z,10); /* double */ 00178 if (ierr!=0) goto err; 00179 } 00180 } 00181 00182 if (Blocks[0].nx != 0) 00183 { 00184 /* 9 - x */ 00185 il_x = (int *) listentry(header,9); 00186 ierr=sci2var(il_x,Blocks[0].x,10); /* double */ 00187 if (ierr!=0) goto err; 00188 00189 /* 10 - xd */ 00190 il_xd = (int *) listentry(header,10); 00191 ierr=sci2var(il_xd,Blocks[0].xd,10); /* double */ 00192 if (ierr!=0) goto err; 00193 } 00194 00195 /* 31 - mode */ 00196 il_mode = (int *) listentry(header,31); 00197 ierr=sci2var(il_mode,Blocks[0].mode,80); /* int */ 00198 if (ierr!=0) goto err; 00199 } 00200 break; 00201 00202 case 3 : /* update event output state */ 00203 { 00204 /* 19 - evout */ 00205 il_evout = (int *) listentry(header,19); 00206 ierr=sci2var(il_evout,Blocks[0].evout,10); /* double */ 00207 if (ierr!=0) goto err; 00208 } 00209 break; 00210 00211 case 4 : /* state initialisation */ 00212 { 00213 /* 7 - z */ 00214 if (Blocks[0].nz != 0) 00215 { 00216 il_z = (int *) listentry(header,7); 00217 if(Blocks[0].scsptr>0) 00218 { 00219 le111=(double *) listentry(header,7); 00220 ne1=header[7+2]-header[7+1]; 00221 C2F(unsfdcopy)(&ne1,le111,(i=-1,&i),Blocks[0].z,(j=-1,&j)); 00222 } 00223 else 00224 { 00225 ierr=sci2var(il_z,Blocks[0].z,10); /* double */ 00226 if (ierr!=0) goto err; 00227 } 00228 } 00229 00230 if (Blocks[0].nx != 0) 00231 { 00232 /* 9 - x */ 00233 il_x = (int *) listentry(header,9); 00234 ierr=sci2var(il_x,Blocks[0].x,10); /* double */ 00235 if (ierr!=0) goto err; 00236 00237 /* 10 - xd */ 00238 il_xd = (int *) listentry(header,10); 00239 ierr=sci2var(il_xd,Blocks[0].xd,10); /* double */ 00240 if (ierr!=0) goto err; 00241 } 00242 } 00243 break; 00244 00245 case 5 : /* finish */ 00246 { 00247 /* 7 - z */ 00248 if (Blocks[0].nz != 0) 00249 { 00250 il_z = (int *) listentry(header,7); 00251 if(Blocks[0].scsptr>0) 00252 { 00253 le111=(double *) listentry(header,7); 00254 ne1=header[7+2]-header[7+1]; 00255 C2F(unsfdcopy)(&ne1,le111,(i=-1,&i),Blocks[0].z,(j=-1,&j)); 00256 } 00257 else 00258 { 00259 ierr=sci2var(il_z,Blocks[0].z,10); /* double */ 00260 if (ierr!=0) goto err; 00261 } 00262 } 00263 00264 if (Blocks[0].nx != 0) 00265 { 00266 /* 9 - x */ 00267 il_x = (int *) listentry(header,9); 00268 ierr=sci2var(il_x,Blocks[0].x,10); /* double */ 00269 if (ierr!=0) goto err; 00270 00271 /* 10 - xd */ 00272 il_xd = (int *) listentry(header,10); /* double */ 00273 ierr=sci2var(il_xd,Blocks[0].xd,10); 00274 if (ierr!=0) goto err; 00275 } 00276 } 00277 break; 00278 00279 case 6 : /* output state initialisation */ 00280 { 00281 /* 7 - z */ 00282 if (Blocks[0].nz != 0) 00283 { 00284 il_z = (int *) listentry(header,7); 00285 if(Blocks[0].scsptr>0) 00286 { 00287 le111=(double *) listentry(header,7); 00288 ne1=header[7+2]-header[7+1]; 00289 C2F(unsfdcopy)(&ne1,le111,(i=-1,&i),Blocks[0].z,(j=-1,&j)); 00290 } 00291 else 00292 { 00293 ierr=sci2var(il_z,Blocks[0].z,10); /* double */ 00294 if (ierr!=0) goto err; 00295 } 00296 } 00297 00298 if (Blocks[0].nx != 0) 00299 { 00300 /* 9 - x */ 00301 il_x = (int *) listentry(header,9); 00302 ierr=sci2var(il_x,Blocks[0].x,10); /* double */ 00303 if (ierr!=0) goto err; 00304 00305 /* 10 - xd */ 00306 il_xd = (int *) listentry(header,10); 00307 ierr=sci2var(il_xd,Blocks[0].xd,10); /* double */ 00308 if (ierr!=0) goto err; 00309 } 00310 00311 /* 17 - outptr */ 00312 if (Blocks[0].nout!=0) 00313 { 00314 il_out = (int *) listentry(header,17); 00315 nout = il_out[1]; 00316 for (j=0;j<nout;j++) 00317 { 00318 il_outptr = (int *) listentry(il_out,j+1); 00319 ierr=sci2var(il_outptr,Blocks[0].outptr[j],Blocks[0].outsz[2*nout+j]); 00320 if (ierr!=0) goto err; 00321 } 00322 } 00323 } 00324 break; 00325 00326 case 7 : /* */ 00327 { 00328 /* 10 - xd */ 00329 if (Blocks[0].nx != 0) 00330 { 00331 il_xd = (int *) listentry(header,10); 00332 ierr=sci2var(il_xd,Blocks[0].xd,10); /* double */ 00333 if (ierr!=0) goto err; 00334 } 00335 00336 /* 31 - mode */ 00337 il_mode = (int *) listentry(header,31); 00338 ierr=sci2var(il_mode,Blocks[0].mode,80); /* int */ 00339 if (ierr!=0) goto err; 00340 } 00341 break; 00342 00343 case 9 : /* */ 00344 { 00345 /* 25 - g */ 00346 il_g = (int *) listentry(header,25); 00347 ierr=sci2var(il_g,Blocks[0].g,10); /* double */ 00348 if (ierr!=0) goto err; 00349 00350 /* 31 - mode */ 00351 il_mode = (int *) listentry(header,31); 00352 ierr=sci2var(il_mode,Blocks[0].mode,80); /* int */ 00353 if (ierr!=0) goto err; 00354 } 00355 break; 00356 } 00357 00358 /* Restore initial position Top */ 00359 Top=topsave; 00360 return; 00361 00362 /* if error then restore initial position Top 00363 * and set_block_error with flag -1 */ 00364 err: 00365 Top=topsave; 00366 if (ierr!=0) /*var2sci or sci2var error*/ 00367 { 00368 /* Please update me !*/ 00369 if (ierr < 1000) /*var2sci error*/ 00370 { 00371 switch (ierr) 00372 { 00373 case 1 : Scierror(888,"var2sci : error %d. Stack is full.\n",ierr); 00374 break; 00375 00376 case 2 : Scierror(888,"var2sci : error %d. No more space on the stack for new data.\n",ierr); 00377 break; 00378 00379 default : Scierror(888,"var2sci : error %d. Undefined error.\n",ierr); 00380 break; 00381 } 00382 } 00383 else /*sci2var error*/ 00384 { 00385 switch (ierr) 00386 { 00387 case 1001 : Scierror(888,"sci2var : error %d. Only integer or double object are accepted.\n",ierr); 00388 break; 00389 00390 case 1002 : Scierror(888,"sci2var : error %d. Bad double object sub_type.\n",ierr); 00391 break; 00392 00393 case 1003 : Scierror(888,"sci2var : error %d. Bad integer object sub_type.\n",ierr); 00394 break; 00395 00396 case 1004 : Scierror(888,"sci2var : error %d. A type of a scilab object has changed.\n",ierr); 00397 break; 00398 00399 default : Scierror(888,"sci2var : error %d. Undefined error.\n",ierr); 00400 break; 00401 } 00402 } 00403 } 00404 set_block_error(-1); 00405 }
Here is the call graph for this function:

Here is the caller graph for this function:

| integer C2F() scierr | ( | ) |
| void C2F() scifunc | ( | ) |
Definition at line 2224 of file intcscicos.c.
References Bot, err, iadr, int, istk, j, l, Lstk, sadr, stk, and Top.
02225 { 02226 /************************************ 02227 * variables and constants définition 02228 ************************************/ 02229 /*counter and address variable declaration*/ 02230 int nm,il,l,j,err; 02231 02232 /*define all type of accepted ptr */ 02233 double *x_d,*ptr_d; 02234 char *x_c,*ptr_c; 02235 unsigned char *x_uc,*ptr_uc; 02236 short *x_s,*ptr_s; 02237 unsigned short *x_us,*ptr_us; 02238 int *x_i,*ptr_i; 02239 unsigned int *x_ui,*ptr_ui; 02240 long *x_l,*ptr_l; 02241 unsigned long *x_ul,*ptr_ul; 02242 02243 /* Check if the stack is not full */ 02244 if (Top >= Bot) 02245 { 02246 err = 1; 02247 return err; 02248 } 02249 else 02250 { 02251 Top = Top + 1; 02252 il = iadr(*Lstk(Top)); 02253 l = sadr(il+4); 02254 } 02255 02256 /* set number of double needed to store data */ 02257 if (typ_var==10) nm=n*m; /*double real matrix*/ 02258 else if (typ_var==11) nm=n*m*2; /*double real matrix*/ 02259 else if (typ_var==80) nm=(int)(ceil((n*m)/2)+1); /*int*/ 02260 else if (typ_var==81) nm=(int)(ceil((n*m)/8)+1); /*int8*/ 02261 else if (typ_var==82) nm=(int)(ceil((n*m)/4)+1); /*int16*/ 02262 else if (typ_var==84) nm=(int)(ceil((n*m)/2)+1); /*int32*/ 02263 else if (typ_var==800) nm=(int)(ceil((n*m)/2)+1); /*uint*/ 02264 else if (typ_var==811) nm=(int)(ceil((n*m)/8)+1); /*uint8*/ 02265 else if (typ_var==812) nm=(int)(ceil((n*m)/4)+1); /*uint16*/ 02266 else if (typ_var==814) nm=(int)(ceil((n*m)/2)+1); /*uint32*/ 02267 else nm=n*m; /*double real matrix*/ 02268 02269 /*check if there is free space for new data*/ 02270 err = l + nm - *Lstk(Bot); 02271 if (err > 0) 02272 { 02273 err = 2; 02274 return err; 02275 } 02276 02277 /************************** 02278 * store data on the stack 02279 *************************/ 02280 switch (typ_var) /*for each type of data*/ 02281 { 02282 case 10 : /* set header */ 02283 *istk(il) = 1; /*double real matrix*/ 02284 *istk(il+1) = n; 02285 *istk(il+2) = m; 02286 *istk(il+3) = 0; 02287 x_d = (double *) x; 02288 ptr_d = (double *) stk(l); 02289 for (j=0;j<m*n;j++) ptr_d[j] = x_d[j]; 02290 break; 02291 02292 case 11 : /* set header */ 02293 *istk(il) = 1; /*double complex matrix*/ 02294 *istk(il+1) = n; 02295 *istk(il+2) = m; 02296 *istk(il+3) = 1; 02297 x_d = (double *) x; 02298 ptr_d = (double *) stk(l); 02299 for (j=0;j<2*m*n;j++) ptr_d[j] = x_d[j]; 02300 break; 02301 02302 case 80 : /* set header */ 02303 *istk(il) = 8; /*int*/ 02304 *istk(il+1) = n; 02305 *istk(il+2) = m; 02306 *istk(il+3) = 4; 02307 x_i = (int *) x; 02308 for (j=0;j<m*n;j++) 02309 { 02310 ptr_i = (int *) istk(il+4); 02311 ptr_i[j] = x_i[j]; 02312 } 02313 break; 02314 02315 case 81 : /* set header */ 02316 *istk(il) = 8; /*int8*/ 02317 *istk(il+1) = n; 02318 *istk(il+2) = m; 02319 *istk(il+3) = 1; 02320 x_c = (char *) x; 02321 for (j=0;j<m*n;j++) 02322 { 02323 ptr_c = (char *) istk(il+4); 02324 ptr_c[j] = x_c[j]; 02325 } 02326 break; 02327 02328 case 82 : /* set header */ 02329 *istk(il) = 8; /*int16*/ 02330 *istk(il+1) = n; 02331 *istk(il+2) = m; 02332 *istk(il+3) = 2; 02333 x_s = (short *) x; 02334 for (j=0;j<m*n;j++) 02335 { 02336 ptr_s = (short *) istk(il+4); 02337 ptr_s[j] = x_s[j]; 02338 } 02339 break; 02340 02341 case 84 : /* set header */ 02342 *istk(il) = 8; /*int32*/ 02343 *istk(il+1) = n; 02344 *istk(il+2) = m; 02345 *istk(il+3) = 4; 02346 x_l = (long *) x; 02347 for (j=0;j<m*n;j++) 02348 { 02349 ptr_l = (long *) istk(il+4); 02350 ptr_l[j] = x_l[j]; 02351 } 02352 break; 02353 02354 case 800 : /* set header */ 02355 *istk(il) = 8; /*uint*/ 02356 *istk(il+1) = n; 02357 *istk(il+2) = m; 02358 *istk(il+3) = 14; 02359 x_ui = (unsigned int *) x; 02360 for (j=0;j<m*n;j++) 02361 { 02362 ptr_ui = (unsigned int *) istk(il+4); 02363 ptr_ui[j] = x_ui[j]; 02364 } 02365 break; 02366 02367 case 811 : /* set header */ 02368 *istk(il) = 8; /*uint8*/ 02369 *istk(il+1) = n; 02370 *istk(il+2) = m; 02371 *istk(il+3) = 11; 02372 x_uc = (unsigned char *) x; 02373 for (j=0;j<m*n;j++) 02374 { 02375 ptr_uc = (unsigned char *) istk(il+4); 02376 ptr_uc[j] = x_uc[j]; 02377 } 02378 break; 02379 02380 case 812 : /* set header */ 02381 *istk(il) = 8; /*uint16*/ 02382 *istk(il+1) = n; 02383 *istk(il+2) = m; 02384 *istk(il+3) = 12; 02385 x_us = (unsigned short *) x; 02386 for (j=0;j<m*n;j++) 02387 { 02388 ptr_us = (unsigned short *) istk(il+4); 02389 ptr_us[j] = x_us[j]; 02390 } 02391 break; 02392 02393 case 814 : /* set header */ 02394 *istk(il) = 8; /*uint32*/ 02395 *istk(il+1) = n; 02396 *istk(il+2) = m; 02397 *istk(il+3) = 14; 02398 x_ul = (unsigned long *) x; 02399 for (j=0;j<m*n;j++) 02400 { 02401 ptr_ul = (unsigned long *) istk(il+4); 02402 ptr_ul[j] = x_ul[j]; 02403 } 02404 break; 02405 02406 default : /* set header */ 02407 *istk(il) = 1; /*double real matrix*/ 02408 *istk(il+1) = n; 02409 *istk(il+2) = m; 02410 *istk(il+3) = 0; 02411 x_d = (double *) x; 02412 for (j=0;j<m*n;j++) 02413 { 02414 ptr_d = (double *) stk(il+4); 02415 ptr_d[j] = x_d[j]; 02416 } 02417 break; 02418 } 02419 02420 /* set value in lstk */ 02421 *Lstk(Top+1) = l + nm; 02422 02423 /*return error flag = 0 */ 02424 err = 0; 02425 return 0; 02426 }
1.5.1