xcode - C++ error EXC_BAD_ACCESS static void assign -
i c++ newbie, can find way through code of time. question might stupid, stuck.
i trying add javascript bindings particlesystem::initwithfile function in cocos2d-x 3.0beta2 , running on ios simulator.
xcode breaks @
_libcpp_inline_visibility static void assign(char_type& __c1, const char_type& __c2) _noexcept {__c1 = __c2;} this function added javascript bindings.
jsbool js_cocos2dx_particlesystem_initwithfile(jscontext *cx, uint32_t argc, jsval *vp) { jsval *argv = js_argv(cx, vp); jsbool ok = js_true; jsobject *obj = js_this_object(cx, vp); js_proxy_t *proxy = jsb_get_js_proxy(obj); cocos2d::particlesystem* cobj = (cocos2d::particlesystem *)(proxy ? proxy->ptr : null); jsb_precondition2( cobj, cx, js_false, "js_cocos2dx_particlesystem_initwithfile : invalid native object"); if (argc == 1) { std::string arg0; ok &= jsval_to_std_string(cx, argv[0], &arg0); jsb_precondition2(ok, cx, js_false, "error processing arguments"); cobj->initwithfile(arg0); js_set_rval(cx, vp, jsval_void); return js_true; } js_reporterror(cx, "js_cocos2dx_particlesystem_setstartradiusvar : wrong number of arguments: %d, expecting %d", argc, 1); return js_false; } and function breaks is
bool particlesystem::initwithfile(const std::string& plistfile) { bool ret = false; _plistfile = fileutils::getinstance()->fullpathforfilename(plistfile); valuemap dict = fileutils::getinstance()->getvaluemapfromfile(_plistfile.c_str()); ccassert( !dict.empty(), "particles: file not found"); // xxx compute path path, should define function somewhere string listfilepath = plistfile; if (listfilepath.find('/') != string::npos) { listfilepath = listfilepath.substr(0, listfilepath.rfind('/') + 1); ret = this->initwithdictionary(dict, listfilepath.c_str()); } else { ret = this->initwithdictionary(dict, ""); } return ret; } problem seems plistfile variable.
update: line in particlesystem::initwithfile method, goes std::string templates
template <class _chart, class _traits, class _allocator> _libcpp_inline_visibility inline basic_string<_chart, _traits, _allocator>& basic_string<_chart, _traits, _allocator>::operator=(basic_string&& __str) _noexcept_(__alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable<allocator_type>::value) { __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>()); return *this; } and to
template <class _chart, class _traits, class _allocator> _libcpp_inline_visibility inline void basic_string<_chart, _traits, _allocator>::__move_assign(basic_string& __str, true_type) _noexcept_(is_nothrow_move_assignable<allocator_type>::value) { clear(); shrink_to_fit(); __r_.first() = __str.__r_.first(); __move_assign_alloc(__str); __str.__zero(); } and then
template <class _chart, class _traits, class _allocator> _libcpp_inline_visibility inline void basic_string<_chart, _traits, _allocator>::clear() _noexcept { __invalidate_all_iterators(); if (__is_long()) { traits_type::assign(*__get_long_pointer(), value_type()); __set_long_size(0); } else { traits_type::assign(*__get_short_pointer(), value_type()); __set_short_size(0); } } and finally
_libcpp_inline_visibility static void assign(char_type& __c1, const char_type& __c2) _noexcept {__c1 = __c2;} here screenshot of xcode 
Comments
Post a Comment