From: dooglus Date: Sun, 30 Sep 2007 20:48:39 +0000 (+0000) Subject: Tidying. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=dbd7f22645f08a25197645ba558914fc84c89fa0;p=synfig.git Tidying. git-svn-id: http://svn.voria.com/code@804 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-core/trunk/src/synfig/value.cpp b/synfig-core/trunk/src/synfig/value.cpp index 4a7902d..515087e 100644 --- a/synfig-core/trunk/src/synfig/value.cpp +++ b/synfig-core/trunk/src/synfig/value.cpp @@ -65,50 +65,22 @@ ValueBase::ValueBase(Type x): data(0), loop_(0) { - switch(type) { - case TYPE_BOOL: - data=static_cast(new bool()); - break; - case TYPE_INTEGER: - data=static_cast(new int()); - break; - case TYPE_ANGLE: - data=static_cast(new Angle()); - break; - case TYPE_VECTOR: - data=static_cast(new Vector()); - break; - case TYPE_TIME: - data=static_cast(new Time()); - break; - case TYPE_REAL: - data=static_cast(new Real()); - break; - case TYPE_COLOR: - data=static_cast(new Color()); - break; - case TYPE_SEGMENT: - data=static_cast(new Segment()); - break; - case TYPE_BLINEPOINT: - data=static_cast(new BLinePoint()); - break; - case TYPE_LIST: - data=static_cast(new list_type()); - break; - case TYPE_STRING: - data=static_cast(new String()); - break; - case TYPE_GRADIENT: - data=static_cast(new Gradient()); - break; - case TYPE_CANVAS: - data=static_cast(new etl::handle()); - break; - default: - break; + case TYPE_BOOL: data=static_cast(new bool()); break; + case TYPE_INTEGER: data=static_cast(new int()); break; + case TYPE_ANGLE: data=static_cast(new Angle()); break; + case TYPE_VECTOR: data=static_cast(new Vector()); break; + case TYPE_TIME: data=static_cast(new Time()); break; + case TYPE_REAL: data=static_cast(new Real()); break; + case TYPE_COLOR: data=static_cast(new Color()); break; + case TYPE_SEGMENT: data=static_cast(new Segment()); break; + case TYPE_BLINEPOINT: data=static_cast(new BLinePoint()); break; + case TYPE_LIST: data=static_cast(new list_type()); break; + case TYPE_STRING: data=static_cast(new String()); break; + case TYPE_GRADIENT: data=static_cast(new Gradient()); break; + case TYPE_CANVAS: data=static_cast(new etl::handle()); break; + default: break; } } @@ -123,9 +95,6 @@ ValueBase::get(const char*)const return get(String()).c_str(); } - - - void ValueBase::set(Canvas* x) { @@ -146,13 +115,9 @@ ValueBase::set(etl::loose_handle x) { clear(); if(x && x->is_inline()) - { _set(etl::handle(x)); - } else - { _set(etl::loose_handle(x)); - } assert(get(x)==x); } @@ -161,13 +126,9 @@ ValueBase::set(etl::handle x) { clear(); if(x && x->is_inline()) - { _set(etl::handle(x)); - } else - { _set(etl::loose_handle(x)); - } assert(get(x)==x); } @@ -224,55 +185,25 @@ ValueBase::clear() { switch(type) { - case TYPE_BOOL: - delete static_cast(data); - break; - case TYPE_INTEGER: - delete static_cast(data); - break; - case TYPE_ANGLE: - delete static_cast(data); - break; - case TYPE_VECTOR: - delete static_cast(data); - break; - case TYPE_TIME: - delete static_cast(data); - break; - case TYPE_REAL: - delete static_cast(data); - break; - case TYPE_COLOR: - delete static_cast(data); - break; - case TYPE_SEGMENT: - delete static_cast(data); - break; - case TYPE_BLINEPOINT: - delete static_cast(data); - break; - case TYPE_LIST: - delete static_cast(data); - break; - case TYPE_STRING: - delete static_cast(data); - break; - case TYPE_GRADIENT: - delete static_cast(data); - break; - - + case TYPE_BOOL: delete static_cast(data); break; + case TYPE_INTEGER: delete static_cast(data); break; + case TYPE_ANGLE: delete static_cast(data); break; + case TYPE_VECTOR: delete static_cast(data); break; + case TYPE_TIME: delete static_cast(data); break; + case TYPE_REAL: delete static_cast(data); break; + case TYPE_COLOR: delete static_cast(data); break; + case TYPE_SEGMENT: delete static_cast(data); break; + case TYPE_BLINEPOINT: delete static_cast(data); break; + case TYPE_LIST: delete static_cast(data); break; + case TYPE_STRING: delete static_cast(data); break; + case TYPE_GRADIENT: delete static_cast(data); break; case TYPE_CANVAS: { etl::handle canvas(get(etl::loose_handle())); if(canvas && canvas->is_inline()) - { delete static_cast*>(data); - } else - { delete static_cast*>(data); - } break; } default: @@ -292,34 +223,20 @@ ValueBase::type_name(Type id) // don't internationalize these type names - they're using in .sif files switch(id) { - case TYPE_REAL: - return "real"; - case TYPE_TIME: - return "time"; - case TYPE_INTEGER: - return "integer"; - case TYPE_BOOL: - return "bool"; - case TYPE_ANGLE: - return "angle"; - case TYPE_VECTOR: - return "vector"; - case TYPE_COLOR: - return "color"; - case TYPE_STRING: - return "string"; - case TYPE_CANVAS: - return "canvas"; - case TYPE_LIST: - return "list"; - case TYPE_SEGMENT: - return "segment"; - case TYPE_GRADIENT: - return "gradient"; - case TYPE_BLINEPOINT: - return "bline_point"; - case TYPE_NIL: - return "nil"; + case TYPE_REAL: return "real"; + case TYPE_TIME: return "time"; + case TYPE_INTEGER: return "integer"; + case TYPE_BOOL: return "bool"; + case TYPE_ANGLE: return "angle"; + case TYPE_VECTOR: return "vector"; + case TYPE_COLOR: return "color"; + case TYPE_STRING: return "string"; + case TYPE_CANVAS: return "canvas"; + case TYPE_LIST: return "list"; + case TYPE_SEGMENT: return "segment"; + case TYPE_GRADIENT: return "gradient"; + case TYPE_BLINEPOINT: return "bline_point"; + case TYPE_NIL: return "nil"; default: break; } @@ -331,34 +248,32 @@ ValueBase::type_name(Type id) ValueBase::Type ValueBase::ident_type(const String &str) { - if(str=="nil" || str=="null") - return TYPE_NIL; - else if(str=="time" || str==_("time")) - return TYPE_TIME; - else if(str=="real" || str=="float" || str==_("real")) - return TYPE_REAL; - else if(str=="integer" || str=="int" || str==_("integer")) - return TYPE_INTEGER; - else if(str=="bool" || str==_("bool")) - return TYPE_BOOL; - else if(str=="angle" || str=="degrees" || str=="radians" || str=="rotations") - return TYPE_ANGLE; - else if(str=="vector" || str=="point") - return TYPE_VECTOR; - else if(str=="color") - return TYPE_COLOR; - else if(str=="string") - return TYPE_STRING; - else if(str=="canvas") - return TYPE_CANVAS; - else if(str=="list") - return TYPE_LIST; - else if(str=="segment") - return TYPE_SEGMENT; - else if(str=="gradient") - return TYPE_GRADIENT; - else if(str=="bline_point" || str=="blinepoint") - return TYPE_BLINEPOINT; + if(str=="nil" || + str=="null") return TYPE_NIL; + else if(str=="time" || + str==_("time")) return TYPE_TIME; + else if(str=="real" || + str=="float" || + str==_("real")) return TYPE_REAL; + else if(str=="integer" || + str=="int" || + str==_("integer")) return TYPE_INTEGER; + else if(str=="bool" || + str==_("bool")) return TYPE_BOOL; + else if(str=="angle" || + str=="degrees" || + str=="radians" || + str=="rotations") return TYPE_ANGLE; + else if(str=="vector" || + str=="point") return TYPE_VECTOR; + else if(str=="color") return TYPE_COLOR; + else if(str=="string") return TYPE_STRING; + else if(str=="canvas") return TYPE_CANVAS; + else if(str=="list") return TYPE_LIST; + else if(str=="segment") return TYPE_SEGMENT; + else if(str=="gradient") return TYPE_GRADIENT; + else if(str=="bline_point" || + str=="blinepoint") return TYPE_BLINEPOINT; return TYPE_NIL; } @@ -373,36 +288,21 @@ ValueBase::operator==(const ValueBase& rhs)const switch(get_type()) { - case TYPE_TIME: - return get(Time()).is_equal(rhs.get(Time())); - case TYPE_REAL: - return abs(get(Real())-rhs.get(Real()))<=0.00000000000001; - case TYPE_INTEGER: - return get(int())==rhs.get(int()); - case TYPE_BOOL: - return get(bool())==rhs.get(bool()); - case TYPE_ANGLE: - return get(Angle())==rhs.get(Angle()); - case TYPE_VECTOR: - return get(Vector()).is_equal_to(rhs.get(Vector())); - case TYPE_COLOR: - return get(Color())==rhs.get(Color()); - case TYPE_STRING: - return get(String())==rhs.get(String()); - case TYPE_CANVAS: - return get(Canvas::LooseHandle())==rhs.get(Canvas::LooseHandle()); - case TYPE_LIST: - return get_list()==rhs.get_list(); - case TYPE_SEGMENT: -// return get(Segment())==rhs.get(Segment()); - case TYPE_GRADIENT: -// return get(Gradient())==rhs.get(Gradient()); - case TYPE_BLINEPOINT: -// return get(BLinePoint())==rhs.get(BLinePoint()); + case TYPE_TIME: return get(Time()).is_equal(rhs.get(Time())); + case TYPE_REAL: return abs(get(Real())-rhs.get(Real()))<=0.00000000000001; + case TYPE_INTEGER: return get(int())==rhs.get(int()); + case TYPE_BOOL: return get(bool())==rhs.get(bool()); + case TYPE_ANGLE: return get(Angle())==rhs.get(Angle()); + case TYPE_VECTOR: return get(Vector()).is_equal_to(rhs.get(Vector())); + case TYPE_COLOR: return get(Color())==rhs.get(Color()); + case TYPE_STRING: return get(String())==rhs.get(String()); + case TYPE_CANVAS: return get(Canvas::LooseHandle())==rhs.get(Canvas::LooseHandle()); + case TYPE_LIST: return get_list()==rhs.get_list(); + case TYPE_SEGMENT: // return get(Segment())==rhs.get(Segment()); + case TYPE_GRADIENT: // return get(Gradient())==rhs.get(Gradient()); + case TYPE_BLINEPOINT: // return get(BLinePoint())==rhs.get(BLinePoint()); case TYPE_NIL: - default: - return false; - break; + default: return false; } return false; }