c5e7291999-03-31Mirar (Pontus Hagland) /*
c186d22001-07-15Per Hedbor  * $Id: math_module.c,v 1.6 2001/07/15 20:20:44 per Exp $
c5e7291999-03-31Mirar (Pontus Hagland)  */ #include "global.h" #include "config.h" #include "program.h"
02eb461999-03-31Mirar (Pontus Hagland) #include "math_module.h"
c5e7291999-03-31Mirar (Pontus Hagland) 
6dc2772000-07-28Fredrik Hübinette (Hubbe) /* must be included last */ #include "module_magic.h"
c5e7291999-03-31Mirar (Pontus Hagland) /*** module init & exit & stuff *****************************************/ /* add other parsers here */
6a33fa1999-03-31Mirar (Pontus Hagland) struct program *math_matrix_program;
c186d22001-07-15Per Hedbor struct program *math_imatrix_program; struct program *math_fmatrix_program; struct program *math_smatrix_program; struct program *math_lmatrix_program;
6a33fa1999-03-31Mirar (Pontus Hagland) 
c5e7291999-03-31Mirar (Pontus Hagland) static struct math_class { char *name; void (*func)(void);
6a33fa1999-03-31Mirar (Pontus Hagland)  struct program **pd;
c5e7291999-03-31Mirar (Pontus Hagland) } sub[] = {
6a33fa1999-03-31Mirar (Pontus Hagland)  {"Matrix",init_math_matrix,&math_matrix_program},
c186d22001-07-15Per Hedbor  {"IMatrix",init_math_imatrix,&math_imatrix_program}, {"LMatrix",init_math_lmatrix,&math_lmatrix_program}, {"FMatrix",init_math_fmatrix,&math_fmatrix_program}, {"SMatrix",init_math_smatrix,&math_smatrix_program},
c5e7291999-03-31Mirar (Pontus Hagland) }; void pike_module_exit(void) {
6a33fa1999-03-31Mirar (Pontus Hagland)  int i; for (i=0; i<(int)(sizeof(sub)/sizeof(sub[0])); i++) if (sub[i].pd && sub[i].pd[0]) free_program(sub[i].pd[0]);
cfada31999-11-08Henrik Grubbström (Grubba)  exit_math_matrix();
c186d22001-07-15Per Hedbor  exit_math_imatrix(); exit_math_fmatrix(); exit_math_smatrix();
c5e7291999-03-31Mirar (Pontus Hagland) } void pike_module_init(void) { int i; for (i=0; i<(int)(sizeof(sub)/sizeof(sub[0])); i++) { struct program *p; start_new_program(); sub[i].func(); p=end_program(); add_program_constant(sub[i].name,p,0);
6a33fa1999-03-31Mirar (Pontus Hagland)  if (sub[i].pd) sub[i].pd[0]=p; else free_program(p);
c5e7291999-03-31Mirar (Pontus Hagland)  }
405beb1999-10-25Mirar (Pontus Hagland)  add_float_constant("pi",3.14159265358979323846 ,0); add_float_constant("e", 2.7182818284590452354 ,0);
c5e7291999-03-31Mirar (Pontus Hagland) }
cc56ad1999-05-07Fredrik Hübinette (Hubbe)