[Groonga-commit] groonga/grnxx at 6ac5615 [master] Fix error handling.

Back to archive index

susumu.yata null+****@clear*****
Mon Aug 4 13:21:32 JST 2014


susumu.yata	2014-08-04 13:21:32 +0900 (Mon, 04 Aug 2014)

  New Revision: 6ac561562da886a29e1de0b6ce6bd8d213988378
  https://github.com/groonga/grnxx/commit/6ac561562da886a29e1de0b6ce6bd8d213988378

  Message:
    Fix error handling.

  Modified files:
    lib/grnxx/expression.cpp

  Modified: lib/grnxx/expression.cpp (+7 -5)
===================================================================
--- lib/grnxx/expression.cpp    2014-08-01 16:48:42 +0900 (256b289)
+++ lib/grnxx/expression.cpp    2014-08-04 13:21:32 +0900 (a7c9e3b)
@@ -791,10 +791,10 @@ unique_ptr<ExpressionBuilder> ExpressionBuilder::create(Error *error,
 ExpressionBuilder::~ExpressionBuilder() {}
 
 bool ExpressionBuilder::push_datum(Error *error, const Datum &datum) {
+  // Reserve a space for a new node.
   if (!stack_.reserve(error, stack_.size() + 1)) {
     return false;
   }
-  // TODO: DatumNode::create() should be provided to get error information.
   unique_ptr<ExpressionNode> node;
   switch (datum.type()) {
     case BOOL_DATA: {
@@ -831,11 +831,13 @@ bool ExpressionBuilder::push_datum(Error *error, const Datum &datum) {
     GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
     return false;
   }
-  stack_.push_back(error, std::move(node));
+  // This push_back() must not fail because a space is already reserved.
+  stack_.push_back(nullptr, std::move(node));
   return true;
 }
 
 bool ExpressionBuilder::push_column(Error *error, String name) {
+  // Reserve a space for a new node.
   if (!stack_.reserve(error, stack_.size() + 1)) {
     return false;
   }
@@ -849,7 +851,6 @@ bool ExpressionBuilder::push_column(Error *error, String name) {
     if (!column) {
       return false;
     }
-    // TODO: The following switch should be done in ColumnNode::create() or ...
     switch (column->data_type()) {
       case BOOL_DATA: {
         node.reset(new (nothrow) ColumnNode<Bool>(column));
@@ -876,7 +877,7 @@ bool ExpressionBuilder::push_column(Error *error, String name) {
         break;
       }
       default: {
-        // TODO: Not supported yet.
+        // TODO: Other types are not supported yet.
         GRNXX_ERROR_SET(error, NOT_SUPPORTED_YET, "Not supported yet");
         return false;
       }
@@ -886,7 +887,8 @@ bool ExpressionBuilder::push_column(Error *error, String name) {
     GRNXX_ERROR_SET(error, NO_MEMORY, "Memory allocation failed");
     return false;
   }
-  stack_.push_back(error, std::move(node));
+  // This push_back() must not fail because a space is already reserved.
+  stack_.push_back(nullptr, std::move(node));
   return true;
 }
 
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index