hchunhui / librime-lua

Extending RIME with Lua scripts
BSD 3-Clause "New" or "Revised" License
310 stars 43 forks source link

請問如何將 lua table(list) 轉成 ConfigList #101

Open shewer opened 3 years ago

shewer commented 3 years ago

想要新增 ProjectionReg 用途: 調用 xlit xdrive xform 轉置功能 https://github.com/rime/librime/blob/2af37e05ecff5ded7c305609a1cd891d3f7ff5ee/src/rime/algo/algebra.h#L29

namespece ProjectionReg{
  typedef Projection T;
  an<T> make(ConfigList &l){
    an<T> p=New<T> ;
    if (!l) return p;
    else
      p.load(l);
    return p;
  }
  bool load(<T>&t ,ConfigList &l){
    return t.load(l);
  }
  string appyl(<T>&t,string s){
    an<String> res=s;   // bool Projection::Apply(string *)  
       if t.Appyl(res)
          return s;                                                                                                                         
      else                                                                                                                                      
         return NULL;                                                                                                                                                
  }
  static const luaL_Reg funcs[] = {                                                                                                         {"Projection", WRAP(make)},
    { NULL, NULL },
  };
  static const luaL_Reg methods[] = {
    {"load", WRAP(load)},
    {"apply",WRAP(apply)},
    { NULL, NULL },
  };
  static const luaL_Reg vars_get[] = {
    { NULL, NULL },
  };

  static const luaL_Reg vars_set[] = {
    { NULL, NULL },
  };

}
shewer commented 3 years ago

ConfigList ConfigMap 都有提供 begin() end()
要如何實現 :iter() for i,v in configlist for k,v in configmap