cocos2dx lua向c++传字符串问题

版本 cocos2dx 3.13

之前写过一篇c++向lua传字符串的问题 http://blog.csdn.net/klyhssrs/article/details/52684784 

现在发现反过来也有同样的问题,

自动生成的lua接口代码中使用的是luaval_to_std_string函数从lua中取传过来的字符串参数,不支持含0的字符串,字符串含0时将被截断。

修复方法:

//cocos2d-x\cocos\scripting\lua-bindings\manual\LuaBasicConversions.cpp
bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue, const char* funcName)
{
    //...
	//...
    if (ok)
    {
		//修改部分 start
        //*outValue = tolua_tocppstring(L,lo,NULL,&len); ==>
		size_t len = 0;
		const char* buf = tolua_tocppstring(L, lo, NULL, &len);
		(*outValue).clear();
		(*outValue).append(buf, len);
		//end
    }

    return ok;
}

//cocos2d-x\external\lua\tolua\tolua++.h
//增加len参数
static inline const char* tolua_tocppstring (lu
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值