[opengtl-commits] [738] add function to return max/min/unit values for each type |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 738
Author: cyrille
Date: 2009-05-26 15:01:01 +0200 (Tue, 26 May 2009)
Log Message:
-----------
add function to return max/min/unit values for each type
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp 2009-05-26 08:40:10 UTC (rev 737)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST.cpp 2009-05-26 13:01:01 UTC (rev 738)
@@ -19,6 +19,9 @@
#include "TemplateAST_p.h"
+#include <stdint.h>
+#include <float.h>
+
#include <GTLCore/Macros_p.h>
#include <GTLCore/Type.h>
@@ -50,6 +53,74 @@
}
}
+GTLCore::String Node::typeMax(const GTLCore::Type* _type) {
+ switch(_type->dataType()) {
+ case GTLCore::Type::UNSIGNED_INTEGER8:
+ return GTLCore::String::number(UINT8_MAX);
+ case GTLCore::Type::UNSIGNED_INTEGER16:
+ return GTLCore::String::number(UINT16_MAX);
+ case GTLCore::Type::UNSIGNED_INTEGER32:
+ return GTLCore::String::number(UINT32_MAX);
+ case GTLCore::Type::INTEGER8:
+ return GTLCore::String::number(INT8_MAX);
+ case GTLCore::Type::INTEGER16:
+ return GTLCore::String::number(INT16_MAX);
+ case GTLCore::Type::INTEGER32:
+ return GTLCore::String::number(INT32_MAX);
+ case GTLCore::Type::FLOAT:
+ return GTLCore::String::number(FLT_MAX);
+ case GTLCore::Type::HALF:
+ return GTLCore::String::number(FLT_MAX);
+ default:
+ GTL_ABORT("Unsupported: " << _type);
+ }
+}
+
+GTLCore::String Node::typeMin(const GTLCore::Type* _type) {
+ switch(_type->dataType()) {
+ case GTLCore::Type::UNSIGNED_INTEGER8:
+ return GTLCore::String::number(0);
+ case GTLCore::Type::UNSIGNED_INTEGER16:
+ return GTLCore::String::number(0);
+ case GTLCore::Type::UNSIGNED_INTEGER32:
+ return GTLCore::String::number(0);
+ case GTLCore::Type::INTEGER8:
+ return GTLCore::String::number(INT8_MIN);
+ case GTLCore::Type::INTEGER16:
+ return GTLCore::String::number(INT16_MIN);
+ case GTLCore::Type::INTEGER32:
+ return GTLCore::String::number(INT32_MIN);
+ case GTLCore::Type::FLOAT:
+ return GTLCore::String::number(FLT_MIN);
+ case GTLCore::Type::HALF:
+ return GTLCore::String::number(FLT_MIN);
+ default:
+ GTL_ABORT("Unsupported: " << _type);
+ }
+}
+GTLCore::String Node::typeUnit(const GTLCore::Type* _type) {
+ switch(_type->dataType()) {
+ case GTLCore::Type::UNSIGNED_INTEGER8:
+ return GTLCore::String::number(UINT8_MAX);
+ case GTLCore::Type::UNSIGNED_INTEGER16:
+ return GTLCore::String::number(UINT16_MAX);
+ case GTLCore::Type::UNSIGNED_INTEGER32:
+ return GTLCore::String::number(UINT32_MAX);
+ case GTLCore::Type::INTEGER8:
+ return GTLCore::String::number(INT8_MAX);
+ case GTLCore::Type::INTEGER16:
+ return GTLCore::String::number(INT16_MAX);
+ case GTLCore::Type::INTEGER32:
+ return GTLCore::String::number(INT32_MAX);
+ case GTLCore::Type::FLOAT:
+ return GTLCore::String::number(1.0);
+ case GTLCore::Type::HALF:
+ return GTLCore::String::number(1.0);
+ default:
+ GTL_ABORT("Unsupported: " << _type);
+ }
+}
+
NodesList::NodesList( const std::list<Node*>& _nodes) : m_nodes(_nodes)
{
}
@@ -162,10 +233,3 @@
}
_context->append(realname);
}
-
-
-
-
-
-
-
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h 2009-05-26 08:40:10 UTC (rev 737)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/templatecompiler/TemplateAST_p.h 2009-05-26 13:01:01 UTC (rev 738)
@@ -41,6 +41,9 @@
* Utility function that return the string corresponding to the type.
*/
static GTLCore::String typeToString(const GTLCore::Type* _type);
+ static GTLCore::String typeMax(const GTLCore::Type* _type);
+ static GTLCore::String typeMin(const GTLCore::Type* _type);
+ static GTLCore::String typeUnit(const GTLCore::Type* _type);
};
class NodesList : public Node {
public: