2011-12-29 62 views
0

嗨我创建了一个firebreath项目。添加此方法到默认生成的代码:Firebreath MethodConverter.h无效初始化

在应用程序API头文件(MYAppAPI.h):

FB_JSAPI_EVENT(bgp, 3, (const FB::variant&, bool, int)); 

std::string bgp(std::string& val); 

在应用程序API的源文件(MAppAPI.mm我使用目标c) :

registerMethod("bgp", make_method(this, &MyAppAPI::bgp)); 

std::string MyAppAPI::bgp(std::string& val){...} 

但是当我建立的代码,我收到此错误:

... firebreath/src目录/ ScriptingCore/MethodConverter.h:115:错误:非const refe的无效初始化类型'std :: string &'的类型'std :: basic_string,std :: allocator'的临时类型'

任何想法?

回答

0

应该阅读:

std::string MyAppAPI::bgp(const std::string& val){...} 

注意常量。你不能通过引用将事物传递给一个JS函数,所以它不会让你传递一个非const引用。