THRIFT-807 JavaScript: Initialization of Base Types with 0 instead of null
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@1023073 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_js_generator.cc b/compiler/cpp/src/generate/t_js_generator.cc
index 19ec156..921cbb4 100644
--- a/compiler/cpp/src/generate/t_js_generator.cc
+++ b/compiler/cpp/src/generate/t_js_generator.cc
@@ -1342,29 +1342,23 @@
case t_base_type::TYPE_VOID:
break;
case t_base_type::TYPE_STRING:
- result += " = ''";
- break;
case t_base_type::TYPE_BOOL:
- result += " = false";
- break;
case t_base_type::TYPE_BYTE:
case t_base_type::TYPE_I16:
case t_base_type::TYPE_I32:
case t_base_type::TYPE_I64:
- result += " = 0";
- break;
case t_base_type::TYPE_DOUBLE:
- result += " = 0.0";
+ result += " = null";
break;
default:
throw "compiler error: no JS initializer for base type " + t_base_type::t_base_name(tbase);
}
} else if (type->is_enum()) {
- result += " = 0";
+ result += " = null";
} else if (type->is_map()){
- result += " = {}";
+ result += " = null";
} else if (type->is_container()) {
- result += " = []";
+ result += " = null";
} else if (type->is_struct() || type->is_xception()) {
if (obj) {
result += " = new " +js_namespace(type->get_program()) + type->get_name() + "()";