Javascript 错误:Can';t访问词法声明
我得到了引用错误:无法在初始化之前访问词法声明textBytes。我无法重现您得到的引用错误,但我认为需要更改Javascript 错误:Can';t访问词法声明,javascript,firefox-addon,jsctypes,nss,Javascript,Firefox Addon,Jsctypes,Nss,我得到了引用错误:无法在初始化之前访问词法声明textBytes。我无法重现您得到的引用错误,但我认为需要更改 let textBytes = ctypes.uint8_t("hello"); let a = new SECItem; a.type = siBuffer; a.data = textBytes.address(); a.len = textBytes.length; 当抛出TypeError:expected type uint8\u t时,得到“hello”to let t
let textBytes = ctypes.uint8_t("hello");
let a = new SECItem;
a.type = siBuffer;
a.data = textBytes.address();
a.len = textBytes.length;
当抛出TypeError:expected type uint8\u t时,得到“hello”
to
let textBytes = ctypes.uint8_t("hello");
这将为您提供一个以null结尾的字符串,长度为6。如果希望它的长度为5,则不使用空终止符,然后执行let textBytes=ctypes.uint8_t.array(5)(“hello”)代码>
正如我所想,改变
let textBytes = ctypes.uint8_t.array()("hello");
到
或设a=new SECItem()代码>它们都是相同的
如果这不能解决问题,请在let textBytes=ctypes.uint8_t.array()上共享SECItem
的结构和siBuffer
(“hello”);它抛出TypeError:需要类型数组,得到“hello”。添加信息常量siBuffer=0;const SECItem=ctypes.StructType(“SECItem”,[{“type”:SECItemType},{“data”:ctypes.uint8_t.ptr},{“len”:ctypes.int}]);改为使用unsigned_char
,如下所示:let textBytes=ctypes.unsigned_char.array()(“hello”)代码>谢谢:)有没有关于jsctypes的推荐书或参考资料?jsctypes的最佳来源是查看其他人是如何做到这一点的。我在gists.github上分享了很多片段,我从这里链接到它们:这是一个很好的学习页面。或者你可以搜索我的GIST:然后在github上有很多东西,比如我的ctypes repos:一定要阅读MDN,它有很多好东西我从其他人那里学到的最好不过是我个人的帮助,如果你需要帮助加入mozilla irc频道获取jsctypes:that's the mibbit link或者如果你有客户:irc://moznet/jsctypes
let a = new SECItem;
let a = SECItem();