예제 #1
0
파일: object.cpp 프로젝트: Bonfi96/godot
void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid) {

#ifdef TOOLS_ENABLED

	_edited = true;
#endif

	if (script_instance) {

		if (script_instance->set(p_name, p_value)) {
			if (r_valid)
				*r_valid = true;
			return;
		}
	}

	//try built-in setgetter
	{
		if (ClassDB::set_property(this, p_name, p_value, r_valid)) {
			/*
			if (r_valid)
				*r_valid=true;
			*/
			return;
		}
	}

	if (p_name == CoreStringNames::get_singleton()->_script) {
		set_script(p_value);
		if (r_valid)
			*r_valid = true;
		return;

	} else if (p_name == CoreStringNames::get_singleton()->_meta) {
		//set_meta(p_name,p_value);
		metadata = p_value;
		if (r_valid)
			*r_valid = true;
		return;
#ifdef TOOLS_ENABLED
	} else if (p_name == CoreStringNames::get_singleton()->_sections_unfolded) {
		Array arr = p_value;
		for (int i = 0; i < arr.size(); i++) {
			editor_section_folding.insert(arr[i]);
		}
		if (r_valid)
			*r_valid = true;
		return;
#endif
	} else {
		//something inside the object... :|
		bool success = _setv(p_name, p_value);
		if (success) {
			if (r_valid)
				*r_valid = true;
			return;
		}
		setvar(p_name, p_value, r_valid);
	}
}
예제 #2
0
void Object::set(const StringName& p_name, const Variant& p_value, bool *r_valid) {

#ifdef TOOLS_ENABLED

	_edited=true;
#endif

	if (script_instance) {

		if (script_instance->set(p_name,p_value)) {
			if (r_valid)
				*r_valid=true;
			return;
		}

	}

	//try built-in setgetter
	{
		if (ObjectTypeDB::set_property(this,p_name,p_value,r_valid)) {
			//if (r_valid)
			//	*r_valid=true;
			return;
		}
	}


	if (p_name==CoreStringNames::get_singleton()->_script) {
		set_script(p_value);
		if (r_valid)
			*r_valid=true;
		return;

	} else if (p_name==CoreStringNames::get_singleton()->_meta) {
		//set_meta(p_name,p_value);
		metadata=p_value;
		if (r_valid)
			*r_valid=true;
		return;
	} else {
		//something inside the object... :|
		bool success = _setv(p_name,p_value);
		if (success) {
			if (r_valid)
				*r_valid=true;
			return;
		}
		setvar(p_name,p_value,r_valid);
	}

}
예제 #3
0
void Object::set(const String& p_name, const Variant& p_value) {

	_setv(p_name,p_value);

	//if (!_use_builtin_script())
//		return;

	bool success;
	ObjectTypeDB::set_property(this,p_name,p_value,success);
	if (success) {
		return;
	}

	if (p_name=="__meta__") {
		metadata=p_value;
	} else if (p_name=="script/script") {
		set_script(p_value);
	} else if (script_instance) {
		script_instance->set(p_name,p_value);
	}


}
예제 #4
0
파일: Diff.cpp 프로젝트: 6e6f36/DarunGrim
static int _find_middle_snake(const void *a,int aoff,int n,
		const void *b,int boff,int m,
		MatchContext *ctx,
		MiddleSnake *ms)
{
	int delta,odd,mid,d;

	delta=n - m;
	odd=delta & 1;
	mid=(n+m) / 2;
	mid += odd;

	_setv(ctx,1,0,0);
	_setv(ctx,delta - 1,1,n);

	for(d=0; d <= mid; d++)
	{
		int k,x,y;

		if((2 * d - 1) >= ctx->dmax) {
			return ctx->dmax;
		}

		for(k=d; k >= -d; k -= 2) {
			if(k==-d ||(k != d && FV(k - 1)<FV(k+1))) {
				x=FV(k+1);
			} else {
				x=FV(k - 1)+1;
			}
			y=x - k;

			ms->x=x;
			ms->y=y;
			const unsigned char *a0=(const unsigned char *)a+aoff;
			const unsigned char *b0=(const unsigned char *)b+boff;
			while(x<n && y<m && a0[x]==b0[y]) {
				x++; y++;
			}
			_setv(ctx,k,0,x);

			if(odd && k >=(delta -(d - 1)) && k <=(delta +(d - 1))) {
				if(x >= RV(k)) {
					ms->u=x;
					ms->v=y;
					return 2 * d - 1;
				}
			}
		}
		for(k=d; k >= -d; k -= 2) {
			int kr=(n - m)+k;

			if(k==d ||(k != -d && RV(kr - 1)<RV(kr+1))) {
				x=RV(kr - 1);
			} else {
				x=RV(kr+1) - 1;
			}
			y=x - kr;

			ms->u=x;
			ms->v=y;
			const unsigned char *a0=(const unsigned char *)a+aoff;
			const unsigned char *b0=(const unsigned char *)b+boff;
			while(x > 0 && y > 0 && a0[x - 1]==b0[y - 1]) {
				x--; y--;
			}
			_setv(ctx,kr,1,x);

			if(!odd && kr >= -d && kr <= d) {
				if(x <= FV(kr)) {
					ms->x=x;
					ms->y=y;
					return 2 * d;
				}
			}
		}
	}

	errno=EFAULT;

	return -1;
}