当前位置: 首页>>代码示例>>C++>>正文


C++ CFunctionsScopePtr::getArgumentsLength方法代码示例

本文整理汇总了C++中CFunctionsScopePtr::getArgumentsLength方法的典型用法代码示例。如果您正苦于以下问题:C++ CFunctionsScopePtr::getArgumentsLength方法的具体用法?C++ CFunctionsScopePtr::getArgumentsLength怎么用?C++ CFunctionsScopePtr::getArgumentsLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFunctionsScopePtr的用法示例。


在下文中一共展示了CFunctionsScopePtr::getArgumentsLength方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scTrace

static void scTrace(const CFunctionsScopePtr &c, void * userdata) {
	CTinyJS *js = (CTinyJS*)userdata;
	if(c->getArgumentsLength())
		c->getArgument(0)->trace();
	else
		js->getRoot()->trace("root");
}
开发者ID:ShadovvMoon,项目名称:Electron,代码行数:7,代码来源:TinyJS_Functions.cpp

示例2: scStringConcat

static void scStringConcat(const CFunctionsScopePtr &c, void *userdata) {
	int length = c->getArgumentsLength();
	string str = c->getArgument("this")->getString();
	for(int i=(int)userdata; i<length; i++)
		str.append(c->getArgument(i)->getString());
	c->setReturnVar(c->newScriptVar(str));
}
开发者ID:atesh,项目名称:G42-tiny-js,代码行数:7,代码来源:TinyJS_StringFunctions.cpp

示例3: scStringConcat

static void scStringConcat(const CFunctionsScopePtr &c, void *userdata) {
	int length = c->getArgumentsLength();
	string str = this2string(c);
	for(int32_t i=ptr2int32(userdata); i<length; i++)
		str.append(c->getArgument(i)->toString());
	c->setReturnVar(c->newScriptVar(str));
}
开发者ID:8bitgeek,项目名称:42tiny-js,代码行数:7,代码来源:TinyJS_StringFunctions.cpp

示例4: scArrayPush

static void scArrayPush(const CFunctionsScopePtr &c, void *data) {
	CScriptVarPtr arr = c->getArgument("this");
	int l = arr->getArrayLength();
	int args = c->getArgumentsLength();
	for (int i=0;i<args;i++)
		arr->setArrayIndex(l+i, c->getArgument(i));
}
开发者ID:cgbystrom,项目名称:scriptorium,代码行数:7,代码来源:TinyJS_Functions.cpp

示例5: scArraySort

static void scArraySort(const CFunctionsScopePtr &c, void *data) {
	CScriptVarPtr arr = c->getArgument("this");
	CScriptVarFunctionPtr cmp_fnc; 
	uint32_t len = arr->getLength();
	if(len > 1) {
		int args = c->getArgumentsLength();
		if(args) {
			cmp_fnc = c->getArgument(0);
			if(!cmp_fnc) c->throwError(TypeError, "invalid Array.prototype.sort argument");
		}
		SCRIPTVAR_CHILDS_it begin = lower_bound(arr->Childs.begin(), arr->Childs.end(), "0");
		/* in ECMAScript the sort algorithm is not specified
		 * in some cases sort throws a TypeError e.G. an array element is read-only, non-configurable, getter or setter
		 * this will result in a partially sorted array 
		 * in worst case the sort algorithm results in an endless loop (more getters with constant return value)
		 *
		 * 42TinyJS checks before sort if an element read-only, setter or getter and throws immediately a TypeError
		 */
		for(SCRIPTVAR_CHILDS_it it = begin; it != arr->Childs.end(); ++it) {
			if(!(*it)->isWritable()) c->throwError(TypeError, "property "+(*it)->getName()+" is read-only");
			if(!(*it)->isConfigurable()) c->throwError(TypeError, "property "+(*it)->getName()+" is non-configurable");
			if(!(*it)->getVarPtr()->isAccessor()) c->throwError(TypeError, "property "+(*it)->getName()+" is a getter and/or a setter");
		}
		sort(begin, arr->Childs.end(), ::cmp_fnc(c, cmp_fnc));
		uint32_t idx = 0;
		for(SCRIPTVAR_CHILDS_it it=begin; it != arr->Childs.end(); ++it, ++idx)
			(*it)->reName(int2string(idx));
		sort(begin, arr->Childs.end(), cmp_by_name);
	}
	c->setReturnVar(arr);
}
开发者ID:8bitgeek,项目名称:42tiny-js,代码行数:31,代码来源:TinyJS_Functions.cpp

示例6: scArrayPush

static void scArrayPush(const CFunctionsScopePtr &c, void *data) {
	CScriptVarPtr arr = c->getArgument("this");
	uint32_t len = c->getLength(arr);
	uint32_t args = c->getArgumentsLength();
	for (uint32_t i=0; i<args; ++i)
		c->setProperty(arr, i, c->getArgument(i));
}
开发者ID:8bitgeek,项目名称:42tiny-js,代码行数:7,代码来源:TinyJS_Functions.cpp

示例7: scStringSubstr

static void scStringSubstr(const CFunctionsScopePtr &c, void *userdata) {
	string str = this2string(c);
	int32_t length = c->getArgumentsLength()-ptr2int32(userdata);
	int32_t start = c->getArgument("start")->toNumber().toInt32();
	if(start<0 || start>=(int)str.size()) 
		c->setReturnVar(c->newScriptVar(""));
	else if(length>1) {
		int length = c->getArgument("length")->toNumber().toInt32();
		c->setReturnVar(c->newScriptVar(str.substr(start, length)));
	} else
		c->setReturnVar(c->newScriptVar(str.substr(start)));
}
开发者ID:8bitgeek,项目名称:42tiny-js,代码行数:12,代码来源:TinyJS_StringFunctions.cpp

示例8: scStringSubstr

static void scStringSubstr(const CFunctionsScopePtr &c, void *userdata) {
	string str = c->getArgument("this")->getString();
	int length = c->getArgumentsLength()-(int)userdata;
	int start = c->getArgument("start")->getInt();
	if(start<0 || start>=(int)str.size()) 
		c->setReturnVar(c->newScriptVar(""));
	else if(length>1) {
		int length = c->getArgument("length")->getInt();
		c->setReturnVar(c->newScriptVar(str.substr(start, length)));
	} else
		c->setReturnVar(c->newScriptVar(str.substr(start)));
}
开发者ID:atesh,项目名称:G42-tiny-js,代码行数:12,代码来源:TinyJS_StringFunctions.cpp

示例9: scStringSlice

static void scStringSlice(const CFunctionsScopePtr &c, void *userdata) {
	string str = this2string(c);
	int32_t length = c->getArgumentsLength()-(ptr2int32(userdata) & 1);
	bool slice = (ptr2int32(userdata) & 2) == 0;
	int32_t start = c->getArgument("start")->toNumber().toInt32();
	int32_t end = (int32_t)str.size();
	if(slice && start<0) start = (int32_t)(str.size())+start;
	if(length>1) {
		end = c->getArgument("end")->toNumber().toInt32();
		if(slice && end<0) end = (int32_t)(str.size())+end;
	}
	if(!slice && end < start) { end^=start; start^=end; end^=start; }
	if(start<0) start = 0;
	if(start>=(int)str.size()) 
		c->setReturnVar(c->newScriptVar(""));
	else if(end <= start)
		c->setReturnVar(c->newScriptVar(""));
	else
		c->setReturnVar(c->newScriptVar(str.substr(start, end-start)));
}
开发者ID:8bitgeek,项目名称:42tiny-js,代码行数:20,代码来源:TinyJS_StringFunctions.cpp

示例10: scStringSlice

static void scStringSlice(const CFunctionsScopePtr &c, void *userdata) {
	string str = c->getArgument("this")->getString();
	int length = c->getArgumentsLength()-((int)userdata & 1);
	bool slice = ((int)userdata & 2) == 0;
	int start = c->getArgument("start")->getInt();
	int end = (int)str.size();
	if(slice && start<0) start = str.size()+start;
	if(length>1) {
		end = c->getArgument("end")->getInt();
		if(slice && end<0) end = str.size()+end;
	}
	if(!slice && end < start) { end^=start; start^=end; end^=start; }
	if(start<0) start = 0;
	if(start>=(int)str.size()) 
		c->setReturnVar(c->newScriptVar(""));
	else if(end <= start)
		c->setReturnVar(c->newScriptVar(""));
	else
		c->setReturnVar(c->newScriptVar(str.substr(start, end-start)));
}
开发者ID:atesh,项目名称:G42-tiny-js,代码行数:20,代码来源:TinyJS_StringFunctions.cpp


注:本文中的CFunctionsScopePtr::getArgumentsLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。