librime-lua icon indicating copy to clipboard operation
librime-lua copied to clipboard

types.cc 增加 TableTranslatorReg error

Open shewer opened this issue 3 years ago • 2 comments

想要增加 TableTranslatorREG, 无法完成 目的; 把 tabletranslator 包入 lua_translator

    function translator_init(env)
          --    Ticket ticket(Engine *engine,string ns, "") 
          --   return  New<TableTranslator>( ticket  )
          env.tran= Table_translator(env.engine, ns) 

    end
    function translator_func(input,segment,env)

         local  translation=  env.tran:query(input,segment)
         for  cand in iter(translation) do 
              yiled(cand)
         end 
    end 

/usr/include/c++/10.2.0/bits/unique_ptr.h: In instantiation of 「void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = rime::Poet]」: /usr/include/c++/10.2.0/bits/unique_ptr.h:361:17: required from 「std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = rime::Poet; _Dp = std::default_deleterime::Poet]」 /home/shewer/proj/librime/src/rime/gear/table_translator.h:25:7: required from 「static int LuaType<T>::gc(lua_State*) [with T = rime::TableTranslator; lua_State = lua_State]」 /home/shewer/proj/librime/plugins/lua/src/types.cc:955:3: required from here /usr/include/c++/10.2.0/bits/unique_ptr.h:83:16: 錯誤:invalid application of 「sizeof」 to incomplete type 「rime::Poet」 83 | static_assert(sizeof(_Tp)>0, | ^~~~~~~~~~~ /usr/include/c++/10.2.0/bits/unique_ptr.h: In instantiation of 「void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = rime::UnityTableEncoder]」: /usr/include/c++/10.2.0/bits/unique_ptr.h:361:17: required from 「std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = rime::UnityTableEncoder; _Dp = std::default_deleterime::UnityTableEncoder]」 /home/shewer/proj/librime/src/rime/gear/table_translator.h:25:7: required from 「static int LuaType<T>::gc(lua_State*) [with T = rime::TableTranslator; lua_State = lua_State]」 /home/shewer/proj/librime/plugins/lua/src/types.cc:955:3: required from here /usr/include/c++/10.2.0/bits/unique_ptr.h:83:16: 錯誤:invalid application of 「sizeof」 to incomplete type 「rime::UnityTableEncoder」 make[3]: *** [plugins/lua/CMakeFiles/rime-lua-objs.dir/build.make:108:plugins/lua/CMakeFiles/rime-lua-objs.dir/src/types.cc.o] 錯誤 1 make[3]: 離開目錄「/home/shewer/proj/librime/build」 make[2]: *** [CMakeFiles/Makefile2:280:plugins/lua/CMakeFiles/rime-lua-objs.dir/all] 錯誤 2 make[2]: 離開目錄「/home/shewer/proj/librime/build」 make[1]: *** [Makefile:160:all] 錯誤 2 make[1]: 離開目錄「/home/shewer/proj/librime/build」 make: *** [Makefile:51:merged-plugins] 錯誤 2


--- a/src/types.cc +++ b/src/types.cc @@ -7,6 +7,7 @@ #include <rime/schema.h> #include <rime/config.h> #include <rime/gear/translator_commons.h> +#include <rime/gear/table_translator.h> #include <rime/dict/reverse_lookup_dictionary.h> #include <rime/key_event.h> #include <rime/switcher.h> @@ -852,6 +853,26 @@ namespace RimeApiReg { lua_setglobal(L, "rime_api"); } } +namespace TableTranslatorReg {

  • typedef TableTranslator T;
  • static const luaL_Reg funcs[] = {
  • { NULL, NULL },
  • };
  • static const luaL_Reg methods[] = {
  • { NULL, NULL },
  • };
  • static const luaL_Reg vars_get[] = {
  • { "tag", WRAPMEM(T::tag)} ,
  • { NULL, NULL },
  • };
  • static const luaL_Reg vars_set[] = {
  • { NULL, NULL },
  • }; +}

namespace SwitcherReg { typedef Switcher T; @@ -931,7 +952,8 @@ void types_init(lua_State *L) { EXPORT(PropertyUpdateNotifierReg, L); EXPORT(KeyEventNotifierReg, L); EXPORT(ConnectionReg, L);

  • EXPORT(SwitcherReg, L);
  • EXPORT(TableTranslatorReg , L); // error types.cc:955:3:
  • //EXPORT(SwitcherReg, L); LogReg::init(L); RimeApiReg::init(L); }

shewer avatar Mar 22 '21 03:03 shewer

错误是报在 Poet 上,试试 include rime/gear/poet.h

hchunhui avatar Mar 27 '21 07:03 hchunhui

試過 each_translator /switch_translator /schema_list_translator typedef EachTranslator , SwitchTranslator SchemaListTranslator build ok

typedef ScriptTranslator/ TableTranslator 且 script_translator.c tabletranslator.c 有include poet

在從下述位置 include 的檔案: /usr/include/c++/10.2.0/memory:83,
                 來自 /home/shewer/proj/librime/src/rime/common.h:15,
                 來自 /home/shewer/proj/librime/src/rime/candidate.h:10,
                 來自 /home/shewer/proj/librime/src/rime/translation.h:12,
                 來自 /home/shewer/proj/librime/plugins/lua/src/types.cc:1:
/usr/include/c++/10.2.0/bits/unique_ptr.h: In instantiation of 「void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = rime::Corrector]」:
/usr/include/c++/10.2.0/bits/unique_ptr.h:361:17:   required from 「std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = rime::Corrector; _Dp = std::default_delete<rime::Corrector>]」
/home/shewer/proj/librime/src/rime/gear/script_translator.h:27:7:   required from 「static int LuaType<T>::gc(lua_State*) [with T = rime::ScriptTranslator; lua_State = lua_State]」
/home/shewer/proj/librime/plugins/lua/src/types.cc:980:3:   required from here
/usr/include/c++/10.2.0/bits/unique_ptr.h:83:16: 錯誤:invalid application of 「sizeof」 to incomplete type 「rime::Corrector」
   83 |  static_assert(sizeof(_Tp)>0,
      |                ^~~~~~~~~~~
/usr/include/c++/10.2.0/bits/unique_ptr.h: In instantiation of 「void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = rime::Poet]」:
/usr/include/c++/10.2.0/bits/unique_ptr.h:361:17:   required from 「std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = rime::Poet; _Dp = std::default_delete<rime::Poet>]」
/home/shewer/proj/librime/src/rime/gear/script_translator.h:27:7:   required from 「static int LuaType<T>::gc(lua_State*) [with T = rime::ScriptTranslator; lua_State = lua_State]」
/home/shewer/proj/librime/plugins/lua/src/types.cc:980:3:   required from here
/usr/include/c++/10.2.0/bits/unique_ptr.h:83:16: 錯誤:invalid application of 「sizeof」 to incomplete type 「rime::Poet」
make[3]: *** [plugins/lua/CMakeFiles/rime-lua-objs.dir/build.make:108:plugins/lua/CMakeFiles/rime-lua-objs.dir/src/types.cc.o] 錯誤 1
make[3]: 離開目錄「/home/shewer/proj/librime/build」
make[2]: *** [CMakeFiles/Makefile2:280:plugins/lua/CMakeFiles/rime-lua-objs.dir/all] 錯誤 2
make[2]: 離開目錄「/home/shewer/proj/librime/build」
make[1]: *** [Makefile:160:all] 錯誤 2
make[1]: 離開目錄「/home/shewer/proj/librime/build」
make: *** [Makefile:51:merged-plugins] 錯誤 2

shewer avatar Mar 28 '21 18:03 shewer