]> Nishi Git Mirror - gwion.git/commitdiff
:shirt: More clean
authorfennecdjay <astor.jeremie@wanadoo.fr>
Wed, 6 Mar 2019 09:37:11 +0000 (10:37 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Wed, 6 Mar 2019 09:37:11 +0000 (10:37 +0100)
17 files changed:
Makefile
include/arg.h
include/array.h
include/driver.h
include/func.h
include/plug.h
src/arg.c
src/emit/emit.c
src/gwion.c
src/lib/vec.c
src/main.c
src/parse/check.c
src/parse/scan1.c
src/parse/scan2.c
src/plug.c
tests/sh/opt.sh
tests/sh/plugin.sh

index 07923bdcd2c5176bacc9b4605b7501fd96100e2a..8cdf23148096d27175c4725f81b8a5b4ce0ba5b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,9 +45,6 @@ CFLAGS += -DVMBENCH
 LDFLAGS += -lbsd
 endif
 
-# add definitions
-CFLAGS+= -DD_FUNC=${D_FUNC}
-
 # add directories
 CFLAGS+=-DGWPLUG_DIR=\"${GWPLUG_DIR}\"
 
index 46f488c377601ae05685c34f925f4b211d7087c3..fb74eb5a4fe6a5ee5b16a4de3b374a24b027df1f 100644 (file)
@@ -4,12 +4,11 @@ typedef struct {
   int argc;
   char** argv;
   struct Vector_ add;
-  struct Vector_ rem;
   struct Vector_ lib;
   struct Vector_ mod;
   m_bool loop;
 } Arg;
 
-ANN void arg_release(Arg* arg);
-ANN uint parse_args(Arg*, DriverInfo*);
+ANN void arg_release(Arg*);
+ANN void arg_parse(Arg*, DriverInfo*);
 #endif
index b19786eba3e0dd67f22026e9935fcbeb750a37b8..1cc83b1112a91066a3f52ce8ed77c45eb985ef3a 100644 (file)
@@ -14,12 +14,12 @@ typedef struct ArrayInfo_ {
   unsigned is_obj : 1;
 } ArrayInfo;
 
-ANN m_uint     m_vector_size(const M_Vector v);
-ANN void       m_vector_set(const M_Vector v,  const m_uint i, const void* data);
-ANN void       m_vector_get(const M_Vector v,  const m_uint i, void* data);
-ANN void       m_vector_add(const M_Vector v,  const void* data);
-ANN m_bit*      m_vector_addr(const M_Vector v, const m_uint i);
-ANN void m_vector_rem(const M_Vector v, const m_uint index);
+ANN m_uint m_vector_size(const M_Vector);
+ANN void   m_vector_set(const M_Vector,  const m_uint, const void*);
+ANN void   m_vector_get(const M_Vector,  const m_uint, void*);
+ANN void   m_vector_add(const M_Vector,  const void*);
+ANN m_bit* m_vector_addr(const M_Vector, const m_uint);
+ANN void m_vector_rem(const M_Vector,  const m_uint);
 ANEW M_Vector new_m_vector(const m_uint);
-void free_m_vector(M_Vector);
+ANN void free_m_vector(M_Vector);
 #endif
index e5e6509b409855630dee09083a6232f5d2892147..1d8724db3ec2c7705c2847beb3d98a8c16d9d210 100644 (file)
@@ -1,20 +1,27 @@
 #ifndef __DRIVER
 #define __DRIVER
+struct Driver_;
+
+typedef void (*f_drvset)(struct Driver_*);
+typedef void (*f_run)(const VM*);
 
-struct _driver;
 typedef struct DriverInfo_ {
   uint32_t   sr;
   m_str arg;
-  void (*func)(struct _driver*);
-  void (*run)(const VM*);
+  f_drvset func;
+  f_run run;
   void* data;
   uint8_t in, out;
 } DriverInfo;
 
-typedef struct _driver {
-  m_bool (*ini)(VM* vm, DriverInfo*);
-  void   (*run)(VM* vm, struct DriverInfo_*);
-  void   (*del)(VM* vm, struct DriverInfo_*);
+typedef m_bool (*f_drvini)(VM*, DriverInfo*);
+typedef void   (*f_drvrun)(VM* vm, struct DriverInfo_*);
+typedef void   (*f_drvdel)(VM* vm, struct DriverInfo_*);
+
+typedef struct Driver_ {
+  f_drvini ini;
+  f_drvrun run;
+  f_drvdel del;
 } Driver;
 
 void dummy_driver(Driver*);
index 42468ea3d22c07ab124784f784d4dab3f68508f8..ef7992a35577461509e940503003c6c9a8b0aaf5 100644 (file)
@@ -12,8 +12,7 @@ struct Func_ {
   HAS_OBJ
 };
 
-ANEW ANN Func new_func(const m_str name, const Func_Def def);
+ANEW ANN Func new_func(const m_str, const Func_Def);
 ANN2(1,2) Symbol func_symbol(const m_str, const m_str, const m_str, const m_uint);
-
-ANN2(1,3,4) m_bool check_lambda(const Env, const Type, Exp_Lambda *lambda, const Func_Def);
+ANN2(1,3,4) m_bool check_lambda(const Env, const Type, Exp_Lambda*, const Func_Def);
 #endif
index 4d11d435359a34ee9c3abf8603fb88844efe18c4..96653fd523dfcd2a704c6b0a08cddb163b3b9f9e 100644 (file)
@@ -23,7 +23,7 @@ void plug_end(const Gwion gwion);
 #define GWMODSTR(a) m_str GWMODSTR_NAME() { return #a; }
 #define GWMODINI(a)  ANN void* GWMODINI_NAME(const Gwion gwion, const Vector args)
 #define GWMODEND(a)  ANN void  GWMODEND_NAME(const Gwion gwion, void* self)
-#define GWDRIVER(a)  ANN void  GWDRIVER_NAME(struct _driver* d)
+#define GWDRIVER(a)  ANN void  GWDRIVER_NAME(Driver* d)
 
 ANN void plug_ini(const Gwion gwion, const Vector);
 ANN Vector split_args(const m_str str);
index fb255a2b695f3eb3d6e9bed76597dedd9ea9b2fa..009476cbf62200f6b8f688c250df78a05a086e1b 100644 (file)
--- a/src/arg.c
+++ b/src/arg.c
@@ -1,5 +1,4 @@
 #include <getopt.h>
-#include <string.h>
 #include "gwion_util.h"
 #include "oo.h"
 #include "vm.h"
@@ -8,7 +7,6 @@
 
 ANN static void arg_init(Arg* arg) {
   vector_init(&arg->add);
-  vector_init(&arg->rem);
   vector_init(&arg->lib);
   vector_init(&arg->mod);
   vector_add(&arg->lib, (vtype)GWPLUG_DIR);
@@ -16,21 +14,19 @@ ANN static void arg_init(Arg* arg) {
 
 ANN void arg_release(Arg* arg) {
   vector_release(&arg->add);
-  vector_release(&arg->rem);
   vector_release(&arg->lib);
   vector_release(&arg->mod);
 }
 
 static const struct option long_option[] = {
-  { "pludir",   0, NULL, 'P' },
+  { "pludir",   0, NULL, 'p' },
   { "driver",   1, NULL, 'd' },
   { "sr",       1, NULL, 's' },
   { "in",       1, NULL, 'i' },
   { "out",      1, NULL, 'o' },
   { "loop",     1, NULL, 'l' },
-  { "help",     0, NULL, '?' },
-  { "version",  0, NULL, 'v' },
-  { "config",   0, NULL, 'C' },
+  { "help",     0, NULL, 'h' },
+  { "config",   0, NULL, 'c' },
   { "module",   0, NULL, 'm' },
   { NULL,       0, NULL, 0   }
 };
@@ -39,67 +35,51 @@ static const char usage[] =
 "usage: Gwion <options>\n"
 "\toption can be any of:\n"
 "GLOBAL options:  <argument>  : description\n"
-"\t--help,      -?\t             : this help\n"
-"\t--version    -v\t             : this help\n"
-"VM     options:\n"
+"\t--help,      -h\t             : this help\n"
 "\t--plugdir,   -P\t <directory> : add a plugin directory\n"
-"DRIVER options:\n"
-"\t--driver     -d\t  <string>   : set the driver (one of: alsa jack soundio portaudio file dummy silent raw)\n"
+"\t--driver     -d\t  <string>   : set the driver\n"
+"\t--module     -m\t  <string>   : module setting\n"
 "\t--sr         -s\t  <number>   : set samplerate\n"
 ;
 
-ANN static void arg_add(Arg* arg) {
-  Vector ref = &arg->add;
-  while(optind < arg->argc) {
-    m_str str = arg->argv[optind++];
-    if(!strcmp(str, "-")) {
-      ref = &arg->rem;
-      str = arg->argv[optind++];
-    } else if(!strcmp(str, "+")) {
-      ref = &arg->add;
-      str = arg->argv[optind++];
-    }
-    vector_add(ref, (vtype)str);
-  }
+ANN static inline void arg_add(Arg* arg) {
+  while(optind < arg->argc)
+    vector_add(&arg->add, (vtype)arg->argv[optind++]);
 }
 
 ANN static void arg_drvr(DriverInfo* di, const int i) {
-    switch(i) {
-      case 'i':
-        di->in       = (m_uint)strtol(optarg, NULL, 10);
-        break;
-      case 'o':
-        di->out      = (m_uint)strtol(optarg, NULL, 10);
-        break;
-      case 's':
-        di->sr       = (uint)strtol(optarg, NULL, 10);
-        break;
-      case 'd':
-        di->arg = optarg;
-        break;
-    default:
-      gw_err("Unknown argument '%c'\n", i);
+  switch(i) {
+    case 'i':
+      di->in  = (m_uint)strtol(optarg, NULL, 10);
+      break;
+    case 'o':
+      di->out = (m_uint)strtol(optarg, NULL, 10);
+      break;
+    case 's':
+      di->sr  = (uint)strtol(optarg, NULL, 10);
+      break;
+    case 'd':
+      di->arg = optarg;
+      break;
   }
 }
 
-ANN uint parse_args(Arg* arg, DriverInfo* di) {
-  uint quit = 0;
-  int i, index;
+ANN void arg_parse(Arg* arg, DriverInfo* di) {
+  int i, idx;
   arg_init(arg);
-  while((i = getopt_long(arg->argc, arg->argv, "?vl:i:o:s:d:m:P:C ",
-      long_option, &index)) != -1) {
+  while((i = getopt_long(arg->argc, arg->argv, "hl:i:o:s:d:m:p:c",
+      long_option, &idx)) != -1) {
     switch(i) {
-      case '?':
+      case 'h':
         gw_err(usage);
-        exit(0);
-      case 'C':
+        break;
+      case 'c':
         gw_err("CFLAGS: %s\nLDFLAGS: %s\n", CFLAGS, LDFLAGS);
-        exit(1);
         break;
       case 'l':
         arg->loop = strtol(optarg, NULL, 10) > 0 ? 1 : -1;
         break;
-      case 'P':
+      case 'p':
         vector_add(&arg->lib, (vtype)optarg);
         break;
       case 'm':
@@ -110,5 +90,4 @@ ANN uint parse_args(Arg* arg, DriverInfo* di) {
     }
   }
   arg_add(arg);
-  return quit;
 }
index 00297a4752fe387238e3d058cbf322a5cd8b42c2..d52bb5ac2ba6f16b3a8aa9e99055a97861ef722d 100644 (file)
@@ -733,7 +733,7 @@ static m_bool emit_template_code(const Emitter emit, const Func f) {
     CHECK_BB(traverse_template(emit->env, f->value_ref->owner_class->def))
   const Value v = f->value_ref;
   size_t scope = emit_push(emit, v->owner_class, v->owner);
-  CHECK_BB(emit_func_def(emit, f->def)) // orig
+  CHECK_BB(emit_func_def(emit, f->def))
   emit_pop(emit, scope);
   return push_func_code(emit, f);
 }
@@ -746,8 +746,7 @@ ANN static Instr emit_call(const Emitter emit, const Func f) {
        FuncMember : FuncStatic : FuncUsr;
     return emit_add_instr(emit, exec);
   }
-  /*const Instr ex = */emit_add_instr(emit, GWOP_EXCEPT);
-//  ex->m_val = -SZ_INT;
+  emit_add_instr(emit, GWOP_EXCEPT);
   return emit_add_instr(emit, FuncPtr);
 }
 
@@ -1282,7 +1281,7 @@ ANN static m_bool emit_stmt_union(const Emitter emit, const Stmt_Union stmt) { G
     if(!stmt->value->type->p)
       stmt->value->type->p = mp_ini((uint32_t)stmt->value->type->size);
     Type_Decl *type_decl = new_type_decl(new_id_list(stmt->xid, stmt->self->pos),
-        emit->env->class_def ? ae_flag_member : 0); // or zero ?
+        emit->env->class_def ? ae_flag_member : 0);
     type_decl->flag = stmt->flag;
     const Var_Decl var_decl = new_var_decl(stmt->xid, NULL, 0);
     const Var_Decl_List var_decl_list = new_var_decl_list(var_decl, NULL);
@@ -1356,7 +1355,7 @@ ANN static m_bool emit_stmt_list(const Emitter emit, Stmt_List l) { GWDEBUG_EXE
 }
 
 ANN static m_bool emit_dot_static_import_data(const Emitter emit, const Value v, const uint emit_addr) { GWDEBUG_EXE
-  if(v->d.ptr && GET_FLAG(v, builtin)) { // from C
+  if(v->d.ptr && GET_FLAG(v, builtin)) {
     if(GET_FLAG(v, enum)) {
       const Instr func_i = emit_add_instr(emit, RegPushImm);
       func_i->m_val = (m_uint)v->d.ptr;
@@ -1378,7 +1377,7 @@ ANN static m_bool emit_complex_member(const Emitter emit, const Exp_Dot* member)
   CHECK_BB(emit_exp(emit, base, 0))
   const m_bool is_complex = !strcmp((isa(base->type, t_complex) > 0  ? "re" : "phase") ,
         s_name(member->xid));
-  if(is_complex && member->self->emit_var) // skip
+  if(is_complex && member->self->emit_var)
     return GW_OK;
   const Instr instr = emit_add_instr(emit, is_complex ? ComplexReal : ComplexImag);
   instr->m_val = member->self->emit_var;
@@ -1398,7 +1397,7 @@ ANN static m_bool emit_VecMember(const Emitter emit, const Exp_Dot* member) {
     emit_vec_func(emit, v);
     return GW_OK;
   }
-  if(!v->offset && member->self->emit_var) // skip
+  if(!v->offset && member->self->emit_var)
     return GW_OK;
   const Instr instr = emit_add_instr(emit, VecMember);
   instr->m_val2 = v->offset;
@@ -1453,22 +1452,15 @@ ANN static m_bool emit_exp_dot_special(const Emitter emit, const Exp_Dot* member
 }
 
 ANN static m_bool emit_dot_static_func(const Emitter emit, const Func func) { GWDEBUG_EXE
-//  if(func->code) {
-//    const Instr func_i = emit_add_instr(emit, RegPushImm);
-//    func_i->m_val = (m_uint)func->code;
-//  } else {
-    // TODO: improve me
-    const Instr func_i = emit_add_instr(emit, PushStaticCode);
-    func_i->m_val = (m_uint)func;
-//  }
+  const Instr func_i = emit_add_instr(emit, PushStaticCode);
+  func_i->m_val = (m_uint)func;
   return GW_OK;
 }
 
 ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, const Func func) { GWDEBUG_EXE
   if(emit_exp(emit, member->base, 0) < 0)
     ERR_B(member->self->pos, "... in member function") // LCOV_EXCL_LINE
-  /*const Instr ex = */emit_add_instr(emit, GWOP_EXCEPT);
-  //ex->m_val = -SZ_INT;
+  emit_add_instr(emit, GWOP_EXCEPT);
   if(GET_FLAG(member->base->type, force)) {
     const Instr func_i = emit_add_instr(emit, RegPushImm);
     func_i->m_val = (m_uint)func->code;
@@ -1484,8 +1476,7 @@ ANN static m_bool emit_member_func(const Emitter emit, const Exp_Dot* member, co
 }
 
 ANN static inline void emit_member(const Emitter emit, const Value v, const uint emit_addr) {
-  /*const Instr ex = */emit_add_instr(emit, GWOP_EXCEPT);
-  //ex->m_val = -SZ_INT;
+  emit_add_instr(emit, GWOP_EXCEPT);
   const m_uint size = v->type->size;
   const Instr instr = emit_kind(emit, size, emit_addr, dotmember);
   instr->m_val = v->offset;
@@ -1496,8 +1487,8 @@ ANN static m_bool emit_exp_dot_instance(const Emitter emit, const Exp_Dot* membe
   const Type t_base = member->t_base;
   const Value value = find_value(t_base, member->xid);
   const uint emit_addr = member->self->emit_var;
-  if(isa(member->self->type, t_fptr) > 0) { // function pointer
-    if(GET_FLAG(value, member)) { // member
+  if(isa(member->self->type, t_fptr) > 0) {
+    if(GET_FLAG(value, member)) {
       if(emit_exp(emit, member->base, 0) < 0)
         ERR_B(member->self->pos, "... in member function") // LCOV_EXCL_LINE
       emit_member(emit, value, emit_addr);
@@ -1506,12 +1497,12 @@ ANN static m_bool emit_exp_dot_instance(const Emitter emit, const Exp_Dot* membe
       return emit_dot_static_data(emit, value, emit_addr);
   } else if(isa(member->self->type, t_function) > 0)
     return emit_member_func(emit, member, value->d.func_ref);
-  else { // variable
-    if(GET_FLAG(value, member)) { // member
+  else {
+    if(GET_FLAG(value, member)) {
       CHECK_BB(emit_exp(emit, member->base, 0))
       emit_member(emit, value, emit_addr);
       return GW_OK;
-    } else // static
+    } else
       CHECK_BB(emit_dot_static_import_data(emit, value, emit_addr))
   }
   return GW_OK;
@@ -1601,8 +1592,9 @@ ANN static m_bool emit_func_def_body(const Emitter emit, const Func_Def func_def
 
 ANN static m_bool emit_func_def(const Emitter emit, const Func_Def func_def) { GWDEBUG_EXE
   const Func func = get_func(emit->env, func_def);
-  if(func->code)return GW_OK;
-  if(tmpl_list_base(func_def->tmpl)) { // don't check template definition
+  if(func->code)
+    return GW_OK;
+  if(tmpl_list_base(func_def->tmpl)) {
     UNSET_FLAG(func_def, template);
     return GW_OK;
   }
index 014803db5922f52286e273afc9e11759e37553d9..e760a12fe388ae645d8ef4e9da5086f3c29258d6 100644 (file)
@@ -43,7 +43,7 @@ ANN m_bool gwion_audio(const Gwion gwion, DriverInfo* di) {
       const m_str name = (m_str)VKEY(&gwion->plug->drv, i);
       const size_t len = strlen(name);
       if(!strncmp(name, di->arg, len)) {
-        di->func = (void (*)(struct _driver*))VVAL(&gwion->plug->drv, i);
+        di->func = (f_drvset)VVAL(&gwion->plug->drv, i);
         break;
       }
     }
index 045c336fd796c9064da6bb94b8a8257d9e2a610c..b0757b23abb359213385255f8e005234b50aad8b 100644 (file)
@@ -236,7 +236,7 @@ static MFUN(vec4_magnitude) {
 
 static MFUN(vec4_normalize) {
   m_vec4* v =  *(m_vec4**)MEM(0);
-  m_float mag = sqrt(v->x * v->x + v->y * v->y + v->z * v->z + v->w * v->w);
+  const m_float mag = sqrt(v->x * v->x + v->y * v->y + v->z * v->z + v->w * v->w);
   if(mag  > 0)
     vec_Div((m_bit*)v, 4, mag);
 }
index eb8d347be5f63969750eeff44548032e1a160d2f..ec57e85cd26a94f4fe9536781b328af867b28285 100644 (file)
@@ -17,12 +17,8 @@ static void sig(int unused __attribute__((unused))) {
 
 int main(int argc, char** argv) {
   Arg arg = { .argc = argc, .argv=argv, .loop=-1 };
-  DriverInfo di = { .in=2, .out=2, /* .chan=2, */ .sr=48000, /* .bufsize=256,
-    .bufnum=3, .card="default:CARD=CODEC",*/ .func=D_FUNC, .run=vm_run };
-  if(parse_args(&arg, &di)) {
-    arg_release(&arg);
-    return 0;
-  }
+  DriverInfo di = { .in=2, .out=2, .sr=48000, .func=dummy_driver, .run=vm_run };
+  arg_parse(&arg, &di);
   gwion_init(&gwion, &arg.lib);
   signal(SIGINT, sig);
   signal(SIGTERM, sig);
index 8ea37542ff9f5b923c1f511ac5aaf5629645302a..359b2a21f37b6a4f726dfcde96f304eeeb4f3a0e 100644 (file)
@@ -71,8 +71,7 @@ ANN static m_bool check_fptr_decl(const Env env, const Var_Decl var) {
       ERR_B(var->pos, "can't use static variables for member function.")
     if(!GET_FLAG(v, member))
       ERR_B(var->pos, "can't use member variables for static function.")
-  } //else if(GET_FLAG(v, member))
-    //ERR_B(var->pos, "can't use member variables for static function.")
+  }
   return GW_OK;
 }
 
@@ -172,7 +171,6 @@ ANN static Type prim_id_non_res(const Env env, const Exp_Primary* primary) {
   ((Exp_Primary*)primary)->value = v;
   if(GET_FLAG(v, const) || !strcmp(s_name(primary->d.var), "maybe"))
     primary->self->meta = ae_meta_value;
-//  OPTIMIZE_PRIM_CONST(primary, v->d.ptr)
   return v->type;
 }
 
@@ -507,7 +505,7 @@ ANN static Func get_template_func(const Env env, const Exp_Call* func, const Exp
     tmpl->base = v->d.func_ref->def->tmpl->list;
     if(base->exp_type == ae_exp_call)
       base->d.exp_call.tmpl = tmpl;
-    else // if(base->exp_type == ae_exp_binary)
+    else /* if(base->exp_type == ae_exp_binary) */
       base->d.exp_binary.tmpl = tmpl;
     return f;
   }
@@ -552,7 +550,7 @@ ANN static Type check_exp_call_template(const Env env, const Exp_Call *exp) {
   const Func func = get_template_func(env, &tmp_func, base, value);
   if(base->exp_type == ae_exp_call)
     base->d.exp_call.m_func = func;
-  else // if(base->exp_type == ae_exp_binary)
+  else /* if(base->exp_type == ae_exp_binary) */
     base->d.exp_binary.func = func;
   return func ? func->def->ret_type : NULL;
 }
@@ -568,7 +566,7 @@ ANN static m_bool check_exp_call1_check(const Env env, const Exp exp) {
 ANN static inline void set_call(const Exp e, const Func f) {
   if(e->exp_type == ae_exp_call)
     e->d.exp_call.m_func = f;
-  else // if(e->exp_type == ae_exp_binary)
+  else /* if(e->exp_type == ae_exp_binary) */
     e->d.exp_binary.func = f;
 }
 
@@ -1003,8 +1001,7 @@ ANN static m_bool check_stmt_list(const Env env, Stmt_List l) { GWDEBUG_EXE
 }
 
 ANN static m_bool check_signature_match(const Func_Def f, const Func parent) { GWDEBUG_EXE
-//  if(GET_FLAG(parent->def, static) || GET_FLAG(f, static)) {
-  if(GET_FLAG(parent->def, static) != GET_FLAG(f, static)) { // wath me
+  if(GET_FLAG(parent->def, static) != GET_FLAG(f, static)) {
     const m_str c_name  = f->func->value_ref->owner_class->name;
     const m_str p_name = parent->value_ref->owner_class->name;
     const m_str f_name = s_name(f->name);
@@ -1014,9 +1011,7 @@ ANN static m_bool check_signature_match(const Func_Def f, const Func parent) { G
           c_name, f_name, p_name, c_name,
           GET_FLAG(f, static) ? c_name : p_name, f_name)
   }
-  if(!f->tmpl) // ???
-    return isa(f->ret_type, parent->def->ret_type);
-  return GW_OK;
+  return !f->tmpl ? isa(f->ret_type, parent->def->ret_type) : GW_OK;
 }
 
 ANN static m_bool parent_match_actual(const Env env, const restrict Func_Def f,
@@ -1046,12 +1041,10 @@ ANN static m_bool check_parent_match(const Env env, const Func_Def f) { GWDEBUG_
         return match;
     }
   }
-//  if(GET_FLAG(func, member)) {
   if(!env->curr->vtable.ptr)
     vector_init(&env->curr->vtable);
   func->vt_index = vector_size(&env->curr->vtable);
   vector_add(&env->curr->vtable, (vtype)func);
-//  }
   return GW_OK;
 }
 
@@ -1070,7 +1063,7 @@ ANN static m_bool check_func_args(const Env env, Arg_List arg_list) { GWDEBUG_EX
 
 ANN static inline Func get_overload(const Env env, const Func_Def def, const m_uint i) {
   const Symbol sym = func_symbol(env->curr->name, s_name(def->name), NULL, i);
-  return nspc_lookup_func1(env->curr, sym); // was lookup2
+  return nspc_lookup_func1(env->curr, sym);
 }
 
 ANN static m_bool check_func_overload(const Env env, const Func_Def f) {
index 7511fef1c4c07110df7452dbd225eb10a203b43a..3faddf51368c6814ad114f612a8469268407ea28 100644 (file)
@@ -33,6 +33,8 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) {
     ERR_O(decl->self->pos, "can't use private type %s", t->name)
   if(GET_FLAG(t, protect) && (!env->class_def || isa(t, env->class_def) < 0))
     ERR_O(decl->self->pos, "can't use protected type %s", t->name)
+  if(GET_FLAG(decl->td, global) && env->class_def)
+    ERR_O(decl->self->pos, "can't declare variable global inside class.")
   if(env->class_def) {
     if(!env->scope->depth) {
       if(!env->func && !GET_FLAG(decl->td, static))
@@ -40,10 +42,7 @@ ANN static Type scan1_exp_decl_type(const Env env, Exp_Decl* decl) {
       if(!GET_FLAG(decl->td, ref) && t == env->class_def)
         ERR_O(decl->self->pos, "...(note: object of type '%s' declared inside itself)", t->name)
     }
-    if(GET_FLAG(decl->td, global) && env->class_def) // forbid this ?
-      UNSET_FLAG(decl->td, global);
   }
-  // for template
   decl->base = t->def;
   decl->type = t;
   return t;
@@ -202,7 +201,7 @@ ANN static m_bool scan1_args(const Env env, Arg_List list) { GWDEBUG_EXE
     const Var_Decl var = list->var_decl;
     if(var->xid)
       CHECK_BB(isres(var->xid))
-    if(list->td) // lambda
+    if(list->td)
       CHECK_OB((list->type = void_type(env, list->td, var->pos)))
   } while((list = list->next));
   return GW_OK;
@@ -280,7 +279,7 @@ ANN m_bool scan1_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
   ++env->scope->depth;
   if(GET_FLAG(f, dtor) && !env->class_def)
     ERR_B(f->td->xid->pos, "dtor must be in class def!!")
-  if(f->td)//lambda
+  if(f->td)
     CHECK_OB((f->ret_type = known_type(env, f->td)))
   if(f->arg_list)
     CHECK_BB(scan1_args(env, f->arg_list))
index 4f6449591fa677277e5c0256958c528604cab4b9..8ba8711ea11ada4172f56f27e612b8fc374de0be 100644 (file)
@@ -53,7 +53,7 @@ ANN static Value arg_value(const Env env, const Arg_List list) {
   if(!var->value) {
     const Value v = new_value(env->gwion, list->type,
       var->xid ? s_name(var->xid) : s_name(insert_symbol((m_str)var)));
-    if(list->td) // lambda
+    if(list->td)
       v->flag = list->td->flag | ae_flag_arg;
     return v;
   }
@@ -475,7 +475,6 @@ ANN2(1,2,4) static Value func_create(const Env env, const Func_Def f,
   scan2_func_def_flag(f);
   if(GET_FLAG(f, builtin))
     CHECK_BO(scan2_func_def_builtin(func, func->name))
-//  if(GET_FLAG(func, member) && !GET_FLAG(func->def, func))
   if(GET_FLAG(func, member))
     f->stack_depth += SZ_INT;
   if(GET_FLAG(func->def, variadic))
@@ -507,7 +506,6 @@ ANN m_bool scan2_func_def(const Env env, const Func_Def f) { GWDEBUG_EXE
     const Func func = nspc_lookup_func1(env->curr, insert_symbol(func_name));
     if(func) {
       f->ret_type = type_decl_resolve(env, f->td);
-      // check arg_list->type for lambdas
       return (f->arg_list && f->arg_list->type) ? scan2_args(env, f) : GW_OK;
     }
   }
index 9259b8894c05b9c85efd5f8eec683d64f9baee72..663405512434cd6c2b5a94f89d8c26c3e6b053fb 100644 (file)
@@ -22,7 +22,7 @@ typedef m_str  (*modstr)(void);
 typedef void*  (*modini)(const Gwion, const Vector);
 typedef void*  (*modend)(const Gwion, void*);
 typedef void*  (*modend)(const Gwion, void*);
-typedef void   (*driver)(struct _driver*);
+
 struct Plug_ {
   m_str name;
   modini ini;
@@ -49,7 +49,7 @@ ANN static void plug_get(PlugInfo* p, const m_str c) {
       plug->end  = DLFUNC(dl, modend, GWMODEND_NAME);
       vector_add(&p->vec[GWPLUG_MODULE], (vtype)plug);
     }
-    const driver drv = DLFUNC(dl, driver, GWDRIVER_NAME);
+    const f_drvset drv = DLFUNC(dl, f_drvset, GWDRIVER_NAME);
     if(drv) {
       const modstr str = DLFUNC(dl, modstr, GWMODSTR_NAME);
       map_set(&p->drv, (vtype)str(), (vtype)drv);
@@ -95,8 +95,7 @@ void plug_end(const Gwion gwion) {
 
 ANN Vector split_args(const m_str str) {
   const m_str arg = strchr(str, '=');
-  m_str c, d = strdup(arg+1);
-  c = d;
+  m_str d = strdup(arg+1), c = d;
   const Vector args = new_vector();
   while(d)
     vector_add(args, (vtype)strdup(strsep(&d, ",")));
index 337b63b8fa606ce6ac7bba4a8b17e32324fecbeb..c2a773310d6141ba37b675a8c9d978ba5ce3e7c0 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# [test] #39
+# [test] #17
 n=0
 [ "$1" ] && n="$1"
 [ "$n" -eq 0 ] && n=1
@@ -37,36 +37,6 @@ run "$n" "help (short)" "-?" "file"
 n=$((n+1))
 run "$n" "help (long)" "--help" "file"
 
-# host
-n=$((n+1))
-run "$n" "config (short)" "-v" "file"
-n=$((n+1))
-run "$n" "config (long)" "--version" "file"
-
-# port
-n=$((n+1))
-run "$n" "port invalid (short)" "-p 1" "file"
-n=$((n+1))
-run "$n" "port invalid (long)" "--port 1" "file"
-
-# card default
-n=$((n+1))
-run "$n" "card default (short)" "-c default" "file"
-n=$((n+1))
-run "$n" "card default (long)" "--card default" "file"
-
-# card invalid
-n=$((n+1))
-run "$n" "card invalid (short)" "-c invalid" "file"
-n=$((n+1))
-run "$n" "card invalid (long)" "--card invalid" "file"
-
-# channels
-n=$((n+1))
-run "$n" "channels (short)" "-g 2" "file"
-n=$((n+1))
-run "$n" "channels (long)" "--chan 2" "file"
-
 # in channels
 n=$((n+1))
 run "$n" "in channels (short)" "-i 2" "file"
@@ -79,57 +49,20 @@ run "$n" "out channels (short)" "-o 2" "file"
 n=$((n+1))
 run "$n" "out channels (long)" "--out 2" "file"
 
-# bufnum
-n=$((n+1))
-run "$n" "bufnum (short)" "-n 2" "file"
-n=$((n+1))
-run "$n" "bufnum (long)" "--bufnum 3" "file"
-
-# bufsize
-n=$((n+1))
-run "$n" "bufsize (short)" "-b 256" "file"
-n=$((n+1))
-run "$n" "bufsize (long)" "--bufsize 256" "file"
-
-# raw
-n=$((n+1))
-run "$n" "raw (short)" "-r" "file"
-n=$((n+1))
-run "$n" "raw (long)" "--raw" "file"
-
 # samplerate
 n=$((n+1))
 run "$n" "samplerate (short)" "-s 44100" "file"
 n=$((n+1))
 run "$n" "samplerate (long)" "--sr 44100" "file"
 
-# standalone
-n=$((n+1))
-run "$n" "standalone (short)" "-a" "file"
-n=$((n+1))
-run "$n" "standalone (long)" "--alone" "file"
-
-# format
-n=$((n+1))
-run "$n" "format (short)" "-f test_format" "file"
-n=$((n+1))
-run "$n" "format (long)" "--format test_format" "file"
-
-# backend
-n=$((n+1))
-run "$n" "backend (short)" "-e test_backend" "file"
-n=$((n+1))
-run "$n" "backend (long)" "--backend test_backend" "file"
-
 # wrong file
 n=$((n+1))
 run "$n" "wrong file" "non_existant_file" "file"
 
 # plug_dir
 n=$((n+1))
-run "$n" "plugin directory" "-P non_existant_dir" "file"
+run "$n" "plugin directory" "-p non_existant_dir" "file"
 
 # config
 n=$((n+1))
-run "$n" "config" "-C" "file"
-
+run "$n" "config" "-c" "file"
index bc6ded3dee675e0037add4ca738562619cba9a2a..3dd0f2e61c3de346e833f4657ef19c068920e78a 100644 (file)
@@ -13,7 +13,7 @@ export GWION_ADD_DIR
 test_plugin() {
        export NAME=$"$1"
        make
-       ../../gwion -P. "$NAME.gw" &> /dev/null
+       ../../gwion -p. "$NAME.gw" &> /dev/null
     NAME="$1" make clean
        N=$(printf "% 4i" "$n")
        echo "ok $N plugin test: '$NAME'"
@@ -22,7 +22,7 @@ test_plugin() {
 
 # empty plug file
 touch "empty.so"
-./gwion -P. &> /dev/null
+./gwion -p. &> /dev/null
 N=$(printf "% 4i" "$n")
 echo "ok $N plugin test: 'empty'"
 n=$((n+1))