THRIFT-5233: Handle I/O timeouts in go library (#2181)
Client: go
As discussed in the JIRA ticket, this commit changes how we handle I/O
timeouts in the go library.
This is a breaking change that adds context to all Read*, Write*, and
Skip functions to TProtocol, along with the compiler change to support
that, and also adds context to TStandardClient.Recv, TDeserializer,
TStruct, and a few others.
Along with the function signature changes, this commit also implements
context cancellation check in the following TProtocol's ReadMessageBegin
implementations:
- TBinaryProtocol
- TCompactProtocol
- THeaderProtocol
In those ReadMessageBegin implementations, if the passed in context
object has a deadline attached, it will keep retrying the I/O timeout
errors, until the deadline on the context object passed. They won't
retry I/O timeout errors if the passed in context does not have a
deadline attached (still return on the first error).
diff --git a/compiler/cpp/src/thrift/generate/t_as3_generator.cc b/compiler/cpp/src/thrift/generate/t_as3_generator.cc
index dd4d166..fa2967b 100644
--- a/compiler/cpp/src/thrift/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_as3_generator.cc
@@ -286,7 +286,7 @@
// For each type check if it is from a differnet namespace
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_program* program = (*m_iter)->get_type()->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("as3");
if (!package.empty()) {
if (imports.find(package + "." + (*m_iter)->get_type()->get_name()) == string::npos) {
@@ -311,7 +311,7 @@
// For each type check if it is from a differnet namespace
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_program* program = (*f_iter)->get_returntype()->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("as3");
if (!package.empty()) {
if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) {
@@ -482,13 +482,13 @@
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
@@ -753,7 +753,7 @@
indent(out) << "public function " << tstruct->get_name() << "() {" << endl;
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
indent(out) << "this._" << (*m_iter)->get_name() << " = "
<< (*m_iter)->get_value()->get_integer() << ";" << endl;
}
@@ -1432,7 +1432,7 @@
f_service_ << endl << as3_type_imports() << as3_thrift_imports()
<< as3_thrift_gen_imports(tservice);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = parent->get_program()->get_namespace("as3");
if (!parent_namespace.empty() && parent_namespace != package_name_) {
@@ -1458,7 +1458,7 @@
f_service_ << endl << as3_type_imports() << as3_thrift_imports()
<< as3_thrift_gen_imports(tservice);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = parent->get_program()->get_namespace("as3");
if (!parent_namespace.empty() && parent_namespace != package_name_) {
@@ -1515,7 +1515,7 @@
*/
void t_as3_generator::generate_service_interface(t_service* tservice) {
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends_iface = " extends " + tservice->get_extends()->get_name();
}
@@ -1566,7 +1566,7 @@
void t_as3_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = tservice->get_extends()->get_name();
extends_client = " extends " + extends + "Impl";
}
@@ -1729,7 +1729,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_processor = " extends " + extends + "Processor";
}
@@ -1765,7 +1765,7 @@
// Generate the server implementation
string override = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
override = "override ";
}
indent(f_service_) << override
@@ -2335,7 +2335,7 @@
// Check for namespacing
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("as3");
if (!package.empty()) {
return package + "." + ttype->get_name();
@@ -2389,7 +2389,7 @@
string result = "var " + tfield->get_name() + ":" + type_name(tfield->get_type());
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
- if (ttype->is_base_type() && tfield->get_value() != NULL) {
+ if (ttype->is_base_type() && tfield->get_value() != nullptr) {
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
@@ -2580,7 +2580,7 @@
std::string t_as3_generator::get_enum_class_name(t_type* type) {
string package = "";
t_program* program = type->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
package = program->get_namespace("as3") + ".";
}
return package + type->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
index f1531cc..098cdb4 100644
--- a/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_c_glib_generator.cc
@@ -471,7 +471,7 @@
// if we are inheriting from another service, include its header
t_service* extends_service = tservice->get_extends();
- if (extends_service != NULL) {
+ if (extends_service != nullptr) {
f_header_ << "#include \"" << this->nspace_lc
<< to_lower_case(initial_caps_to_underscores(extends_service->get_name())) << ".h\""
<< endl;
@@ -1012,7 +1012,7 @@
// initialize any constants that may be referenced by this initializer
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
string field_name = "";
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1022,7 +1022,7 @@
break;
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field "
+ v_iter->first->get_string();
}
@@ -1054,7 +1054,7 @@
scope_down(f_types_impl_);
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
string field_name = "";
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
@@ -1064,7 +1064,7 @@
break;
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field "
+ v_iter->first->get_string();
}
@@ -1171,7 +1171,7 @@
<< indent() << "if (constant == NULL)" << endl;
scope_up(f_types_impl_);
f_types_impl_ << initializers.str() << endl
- << indent() << "constant = " << generate_new_hash_from_type(etype, NULL) << endl
+ << indent() << "constant = " << generate_new_hash_from_type(etype, nullptr) << endl
<< appenders.str();
scope_down(f_types_impl_);
f_types_impl_ << indent() << "return constant;" << endl;
@@ -1273,7 +1273,7 @@
string parent_class_name = "GObject";
string parent_type_name = "G_TYPE_OBJECT";
- // The service this service extends, or NULL if it extends no
+ // The service this service extends, or nullptr if it extends no
// service
t_service* extends_service = tservice->get_extends();
if (extends_service) {
@@ -1851,7 +1851,7 @@
string args_indent;
- // The service this service extends, or NULL if it extends no service
+ // The service this service extends, or nullptr if it extends no service
t_service* extends_service = tservice->get_extends();
// Determine the name of our parent service (if any) and the handler class'
@@ -2081,7 +2081,7 @@
string function_name;
string args_indent;
- // The service this service extends, or NULL if it extends no service
+ // The service this service extends, or nullptr if it extends no service
t_service* extends_service = tservice->get_extends();
// Determine the name of our parent service (if any) and the
@@ -3096,7 +3096,7 @@
t_field* member = *m_iter;
t_const_value* member_value = member->get_value();
- if (member_value != NULL) {
+ if (member_value != nullptr) {
string member_name = member->get_name();
t_type* member_type = get_true_type(member->get_type());
@@ -3145,7 +3145,7 @@
dval += "(" + type_name(t) + ")";
}
t_const_value* cv = (*m_iter)->get_value();
- if (cv != NULL) {
+ if (cv != nullptr) {
dval += constant_value("", t, cv);
} else {
dval += t->is_string() ? "NULL" : "0";
@@ -3167,7 +3167,7 @@
} else if (t->is_container()) {
string name = (*m_iter)->get_name();
string init_function;
- t_type* etype = NULL;
+ t_type* etype = nullptr;
if (t->is_map()) {
t_type* key = ((t_map*)t)->get_key_type();
@@ -3175,7 +3175,7 @@
init_function = generate_new_hash_from_type(key, value);
} else if (t->is_set()) {
etype = ((t_set*)t)->get_elem_type();
- init_function = generate_new_hash_from_type(etype, NULL);
+ init_function = generate_new_hash_from_type(etype, nullptr);
} else if (t->is_list()) {
etype = ((t_list*)t)->get_elem_type();
init_function = generate_new_array_from_type(etype);
@@ -3412,7 +3412,7 @@
break;
}
- if (member_value != NULL) {
+ if (member_value != nullptr) {
default_value << (base_type == t_base_type::TYPE_DOUBLE ? member_value->get_double()
: member_value->get_integer());
} else {
@@ -3431,8 +3431,8 @@
} else if (member_type->is_enum()) {
t_enum_value* enum_min_value = ((t_enum*)member_type)->get_min_value();
t_enum_value* enum_max_value = ((t_enum*)member_type)->get_max_value();
- int min_value = (enum_min_value != NULL) ? enum_min_value->get_value() : 0;
- int max_value = (enum_max_value != NULL) ? enum_max_value->get_value() : 0;
+ int min_value = (enum_min_value != nullptr) ? enum_min_value->get_value() : 0;
+ int max_value = (enum_max_value != nullptr) ? enum_max_value->get_value() : 0;
args_indent += string(18, ' ');
f_types_impl_ << "g_param_spec_int (\"" << member_name << "\"," << endl << args_indent
@@ -4338,7 +4338,7 @@
}
string t_c_glib_generator::generate_free_func_from_type(t_type* ttype) {
- if (ttype == NULL)
+ if (ttype == nullptr)
return "NULL";
if (ttype->is_base_type()) {
@@ -4404,7 +4404,7 @@
}
string t_c_glib_generator::generate_hash_func_from_type(t_type* ttype) {
- if (ttype == NULL)
+ if (ttype == nullptr)
return "NULL";
if (ttype->is_base_type()) {
@@ -4442,7 +4442,7 @@
}
string t_c_glib_generator::generate_cmp_func_from_type(t_type* ttype) {
- if (ttype == NULL)
+ if (ttype == nullptr)
return "NULL";
if (ttype->is_base_type()) {
diff --git a/compiler/cpp/src/thrift/generate/t_cl_generator.cc b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
index ad7c0ef..06b6b65 100644
--- a/compiler/cpp/src/thrift/generate/t_cl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cl_generator.cc
@@ -314,13 +314,13 @@
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -396,7 +396,7 @@
out << endl << indent() << " ";
}
out << "(" << prefix((*m_iter)->get_name()) << " " <<
- ( (NULL != value) ? render_const_value(type, value) : "nil" ) <<
+ ( (nullptr != value) ? render_const_value(type, value) : "nil" ) <<
" :id " << (*m_iter)->get_key();
if ( type->is_base_type() && "string" == typespec(type) )
if ( ((t_base_type*)type)->is_binary() )
@@ -441,7 +441,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends_client = type_name(tservice->get_extends());
}
@@ -540,7 +540,7 @@
string prefix = "";
t_program* program = ttype->get_program();
- if (program != NULL && program != program_)
+ if (program != nullptr && program != program_)
prefix = package_of(program) == package() ? "" : package_of(program) + ":";
string name = ttype->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
index b657038..ceaa11f 100644
--- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc
@@ -606,7 +606,7 @@
<< "_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(" << constants.size() << ", _k"
<< tenum->get_name() << "Values"
<< ", _k" << tenum->get_name() << "Names), "
- << "::apache::thrift::TEnumIterator(-1, NULL, NULL));" << endl << endl;
+ << "::apache::thrift::TEnumIterator(-1, nullptr, nullptr));" << endl << endl;
generate_enum_ostream_operator_decl(f_types_, tenum);
generate_enum_ostream_operator(f_types_impl_, tenum);
@@ -781,7 +781,7 @@
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
bool is_nonrequired_field = false;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
is_nonrequired_field = false;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
@@ -789,7 +789,7 @@
is_nonrequired_field = (*f_iter)->get_req() != t_field::T_REQUIRED;
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
@@ -1081,7 +1081,7 @@
if ((*m_iter)->get_req() == t_field::T_REQUIRED) {
continue;
}
- string isSet = ((*m_iter)->get_value() != NULL) ? "true" : "false";
+ string isSet = ((*m_iter)->get_value() != nullptr) ? "true" : "false";
if (first) {
first = false;
out << ": " << (*m_iter)->get_name() << "(" << isSet << ")";
@@ -1142,7 +1142,7 @@
}
dval += (t->is_string() || is_reference(*m_iter)) ? "" : "0";
t_const_value* cv = (*m_iter)->get_value();
- if (cv != NULL) {
+ if (cv != nullptr) {
dval = render_const_value(out, (*m_iter)->get_name(), t, cv);
}
if (!init_ctor) {
@@ -1163,7 +1163,7 @@
if (!t->is_base_type()) {
t_const_value* cv = (*m_iter)->get_value();
- if (cv != NULL) {
+ if (cv != nullptr) {
print_const_value(out, (*m_iter)->get_name(), t, cv);
}
}
@@ -1264,7 +1264,7 @@
if (is_user_struct && !has_custom_ostream(tstruct)) {
out << indent() << "virtual ";
- generate_struct_print_method_decl(out, NULL);
+ generate_struct_print_method_decl(out, nullptr);
out << ";" << endl;
}
@@ -1830,7 +1830,7 @@
<< endl;
t_service* extends_service = tservice->get_extends();
- if (extends_service != NULL) {
+ if (extends_service != nullptr) {
f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program()))
<< extends_service->get_name() << ".h\"" << endl;
}
@@ -1977,7 +1977,7 @@
}
string extends = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " : virtual public " + type_name(tservice->get_extends()) + style + "If";
if (style == "CobCl" && gen_templates_) {
// TODO(simpkins): If gen_templates_ is enabled, we currently assume all
@@ -2042,7 +2042,7 @@
// type. Implementations can use dynamic_cast to cast the pointer to the
// subclass type if desired.
t_service* base_service = tservice;
- while (base_service->get_extends() != NULL) {
+ while (base_service->get_extends() != nullptr) {
base_service = base_service->get_extends();
}
string base_if_name = type_name(base_service) + style + "If";
@@ -2050,7 +2050,7 @@
// Generate the abstract factory class
string factory_name = service_if_name + "Factory";
string extends;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " : virtual public " + type_name(tservice->get_extends()) + style + "IfFactory";
}
@@ -2092,7 +2092,7 @@
*/
void t_cpp_generator::generate_service_null(t_service* tservice, string style) {
string extends = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " , virtual public " + type_name(tservice->get_extends()) + style + "Null";
}
f_header_ << "class " << service_name_ << style << "Null : virtual public " << service_name_
@@ -2278,7 +2278,7 @@
string extends = "";
string extends_multiface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_multiface = ", public " + extends + "Multiface";
}
@@ -2399,7 +2399,7 @@
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
// TODO(simpkins): If gen_templates_ is enabled, we currently assume all
// parent services were also generated with templates enabled.
extends = type_name(tservice->get_extends());
@@ -3055,7 +3055,7 @@
factory_class_name_ += "T";
}
- if (service_->get_extends() != NULL) {
+ if (service_->get_extends() != nullptr) {
extends_ = type_name(service_->get_extends()) + pstyle_ + "Processor";
if (generator_->gen_templates_) {
// TODO(simpkins): If gen_templates_ is enabled, we currently assume all
@@ -3071,7 +3071,7 @@
vector<t_function*>::iterator f_iter;
string parent_class;
- if (service_->get_extends() != NULL) {
+ if (service_->get_extends() != nullptr) {
parent_class = extends_;
} else {
if (style_ == "Cob") {
@@ -3122,7 +3122,7 @@
<< " ProcessFunctions(ProcessFunction g, "
<< "SpecializedProcessFunction s) :" << endl << indent() << " generic(g)," << endl
<< indent() << " specialized(s) {}" << endl << indent()
- << " ProcessFunctions() : generic(NULL), specialized(NULL) "
+ << " ProcessFunctions() : generic(nullptr), specialized(nullptr) "
<< "{}" << endl << indent() << "};" << endl << indent()
<< "typedef std::map<std::string, ProcessFunctions> "
<< "ProcessMap;" << endl;
@@ -3183,7 +3183,7 @@
if (generator_->gen_templates_) {
f_header_ << "ProcessFunctions(" << endl;
if (generator_->gen_templates_only_) {
- indent(f_header_) << " NULL," << endl;
+ indent(f_header_) << " nullptr," << endl;
} else {
indent(f_header_) << " &" << class_name_ << "::process_" << (*f_iter)->get_name() << ","
<< endl;
@@ -3445,18 +3445,18 @@
out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl;
}
- out << indent() << "void* ctx = NULL;" << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "void* ctx = nullptr;" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " ctx = this->eventHandler_->getContext(" << service_func_name << ", callContext);"
<< endl << indent() << "}" << endl << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
<< "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
- << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent()
<< "}" << endl << endl << indent() << argsname << " args;" << endl << indent()
<< "args.read(iprot);" << endl << indent() << "iprot->readMessageEnd();" << endl << indent()
<< "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl
<< indent() << "}" << endl << endl;
@@ -3524,7 +3524,7 @@
}
indent_up();
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl;
@@ -3542,7 +3542,7 @@
// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl << endl << indent() << "return;" << endl;
indent_down();
@@ -3551,14 +3551,14 @@
}
// Serialize the result into a struct
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl << indent()
<< "}" << endl << endl << indent() << "oprot->writeMessageBegin(\"" << tfunction->get_name()
<< "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl << indent()
<< "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();" << endl
<< indent() << "bytes = oprot->getTransport()->writeEnd();" << endl << indent()
<< "oprot->getTransport()->flush();" << endl << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
<< indent() << "}" << endl;
@@ -3597,32 +3597,32 @@
}
out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << endl
- << indent() << "void* ctx = NULL;" << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", NULL);" << endl
+ << indent() << "void* ctx = nullptr;" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
<< indent() << "}" << endl << indent() << "::apache::thrift::TProcessorContextFreer freer("
<< "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
<< indent() << "try {" << endl;
indent_up();
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->preRead(ctx, " << service_func_name << ");" << endl << indent()
<< "}" << endl << indent() << "args.read(iprot);" << endl << indent()
<< "iprot->readMessageEnd();" << endl << indent()
<< "uint32_t bytes = iprot->getTransport()->readEnd();" << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->postRead(ctx, " << service_func_name << ", bytes);" << endl
<< indent() << "}" << endl;
scope_down(out);
// TODO(dreiss): Handle TExceptions? Expose to server?
out << indent() << "catch (const std::exception&) {" << endl << indent()
- << " if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << " if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
<< indent() << " }" << endl << indent() << " return cob(false);" << endl << indent()
<< "}" << endl;
if (tfunction->is_oneway()) {
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->asyncComplete(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl;
}
@@ -3715,19 +3715,19 @@
<< "*>(&_return);" << endl << indent() << "result.__isset.success = true;" << endl;
}
// Serialize the result into a struct
- out << endl << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", NULL);" << endl
+ out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
<< indent() << "}" << endl << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
<< "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl
- << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\""
<< tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl
<< indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();"
<< endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl
<< indent() << "oprot->getTransport()->flush();" << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
<< indent() << "}" << endl << indent() << "return cob(true);" << endl;
scope_down(out);
@@ -3756,8 +3756,8 @@
}
// Get the event handler context
- out << endl << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
- << " ctx = this->eventHandler_->getContext(" << service_func_name << ", NULL);" << endl
+ out << endl << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
+ << " ctx = this->eventHandler_->getContext(" << service_func_name << ", nullptr);" << endl
<< indent() << "}" << endl << indent()
<< "::apache::thrift::TProcessorContextFreer freer("
<< "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl;
@@ -3783,7 +3783,7 @@
// Handle the case where an undeclared exception is thrown
out << " catch (std::exception& e) {" << endl;
indent_up();
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->handlerError(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl << endl << indent()
<< "::apache::thrift::TApplicationException x(e.what());" << endl << indent()
@@ -3799,14 +3799,14 @@
scope_down(out);
// Serialize the result into a struct
- out << indent() << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ out << indent() << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->preWrite(ctx, " << service_func_name << ");" << endl
<< indent() << "}" << endl << endl << indent() << "oprot->writeMessageBegin(\""
<< tfunction->get_name() << "\", ::apache::thrift::protocol::T_REPLY, seqid);" << endl
<< indent() << "result.write(oprot);" << endl << indent() << "oprot->writeMessageEnd();"
<< endl << indent() << "uint32_t bytes = oprot->getTransport()->writeEnd();" << endl
<< indent() << "oprot->getTransport()->flush();" << endl << indent()
- << "if (this->eventHandler_.get() != NULL) {" << endl << indent()
+ << "if (this->eventHandler_.get() != nullptr) {" << endl << indent()
<< " this->eventHandler_->postWrite(ctx, " << service_func_name << ", bytes);" << endl
<< indent() << "}" << endl << indent() << "return cob(true);" << endl;
scope_down(out);
@@ -4389,7 +4389,7 @@
// Check if it needs to be namespaced
string pname;
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
pname = class_prefix + namespace_prefix(program->get_namespace("cpp")) + ttype->get_name();
} else {
pname = class_prefix + ttype->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_d_generator.cc b/compiler/cpp/src/thrift/generate/t_d_generator.cc
index 65f4b44..afae5b5 100644
--- a/compiler/cpp/src/thrift/generate/t_d_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_d_generator.cc
@@ -219,7 +219,7 @@
f_service << "import " << suffix_if_reserved(render_package(*get_program())) << program_name_ << "_types;" << endl;
t_service* extends_service = tservice->get_extends();
- if (extends_service != NULL) {
+ if (extends_service != nullptr) {
f_service << "import " << suffix_if_reserved(render_package(*(extends_service->get_program())))
<< suffix_if_reserved(extends_service->get_name()) << ";" << endl;
}
@@ -227,7 +227,7 @@
f_service << endl;
string extends = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " : " + suffix_if_reserved(render_type_name(tservice->get_extends()));
}
@@ -299,7 +299,7 @@
meta << "TParamMeta(`" << suffix_if_reserved((*p_iter)->get_name()) << "`, " << (*p_iter)->get_key();
t_const_value* cv = (*p_iter)->get_value();
- if (cv != NULL) {
+ if (cv != nullptr) {
meta << ", q{" << render_const_value((*p_iter)->get_type(), cv) << "}";
}
meta << ")";
@@ -475,7 +475,7 @@
t_const_value* cv = (*m_iter)->get_value();
t_field::e_req req = (*m_iter)->get_req();
out << ", " << render_req(req);
- if (cv != NULL) {
+ if (cv != nullptr) {
out << ", q{" << render_const_value((*m_iter)->get_type(), cv) << "}";
}
out << ")";
@@ -568,13 +568,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "Type error: " + type->get_name() + " has no field "
+ v_iter->first->get_string();
}
diff --git a/compiler/cpp/src/thrift/generate/t_dart_generator.cc b/compiler/cpp/src/thrift/generate/t_dart_generator.cc
index fbbb9e6..65d0f53 100644
--- a/compiler/cpp/src/thrift/generate/t_dart_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_dart_generator.cc
@@ -599,13 +599,13 @@
out << type_name(type) << " " << name << " = new " << type_name(type) << "()";
indent_up();
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
@@ -827,7 +827,7 @@
scope_up(out);
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
print_const_value(out,
"this." + get_member_name((*m_iter)->get_name()),
t,
@@ -1409,7 +1409,7 @@
*/
void t_dart_generator::generate_service_interface(t_service* tservice) {
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends_iface = " extends " + get_ttype_class_name(tservice->get_extends());
}
@@ -1454,7 +1454,7 @@
void t_dart_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = get_ttype_class_name(tservice->get_extends());
extends_client = " extends " + extends + "Client";
}
@@ -1587,7 +1587,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = get_ttype_class_name(tservice->get_extends());
extends_processor = " extends " + extends + "Processor";
}
@@ -2193,7 +2193,7 @@
string result = type_name(tfield->get_type()) + " " + field_name;
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
- if (ttype->is_base_type() && tfield->get_value() != NULL) {
+ if (ttype->is_base_type() && tfield->get_value() != nullptr) {
std:: ofstream dummy;
result += " = " + render_const_value(dummy, field_name, ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
index e5bd81a..4ffdc82 100644
--- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
@@ -115,7 +115,7 @@
t_field* tfield,
bool isPublic,
std::string fieldPrefix = "");
- void generate_delphi_isset_reader_definition(ostream& out, t_field* tfield, bool is_xception);
+ void generate_delphi_isset_reader_writer_definition(ostream& out, t_field* tfield, bool is_xception);
void generate_delphi_property_reader_definition(ostream& out,
t_field* tfield,
bool is_xception_class);
@@ -149,7 +149,7 @@
bool is_union,
bool is_xception_factory,
std::string xception_factory_name);
- void generate_delphi_isset_reader_impl(ostream& out,
+ void generate_delphi_isset_reader_writer_impl(ostream& out,
std::string cls_prefix,
std::string name,
t_type* type,
@@ -956,9 +956,9 @@
}
bool t_delphi_generator::is_fully_defined_type(t_type* ttype) {
- if ((NULL != ttype->get_program()) && (ttype->get_program() != program_)) {
+ if ((nullptr != ttype->get_program()) && (ttype->get_program() != program_)) {
t_scope* scope = ttype->get_program()->scope();
- if (NULL != scope->get_type(ttype->get_name())) {
+ if (nullptr != scope->get_type(ttype->get_name())) {
// printf("type %s found in included scope %s\n", ttype->get_name().c_str(),
// ttype->get_program()->get_name().c_str());
return true;
@@ -1230,13 +1230,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(vars, out, name, field_type, v_iter->second);
@@ -1466,7 +1466,7 @@
while (t->is_typedef()) {
t = ((t_typedef*)t)->get_type();
}
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
initialize_field(vars,
code,
"F" + prop_name((*m_iter)->get_name(), is_exception),
@@ -1612,7 +1612,7 @@
is_x_factory,
exception_factory_name);
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
- generate_delphi_isset_reader_impl(out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
+ generate_delphi_isset_reader_writer_impl(out, cls_prefix, cls_nm, t, *m_iter, "F", is_exception);
}
}
@@ -1744,7 +1744,7 @@
out << endl;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
- generate_delphi_isset_reader_definition(out, *m_iter, is_exception);
+ generate_delphi_isset_reader_writer_definition(out, *m_iter, is_exception);
}
}
}
@@ -1754,7 +1754,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
- indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << ";"
+ indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";"
<< endl;
}
}
@@ -1827,6 +1827,7 @@
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
indent(out) << "function Get" << isset_name << ": System.Boolean;" << endl;
+ indent(out) << "procedure Set" << isset_name << "( const value : System.Boolean);" << endl;
}
}
}
@@ -1890,7 +1891,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
if ((*m_iter)->get_req() != t_field::T_REQUIRED) {
isset_name = "__isset_" + prop_name(*m_iter, is_exception);
- indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << ";"
+ indent(out) << "property " << isset_name << ": System.Boolean read Get" << isset_name << " write Set" << isset_name << ";"
<< endl;
}
}
@@ -1934,7 +1935,7 @@
indent_up();
generate_delphi_doc(s_service, tservice);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends(), true, true);
extends_iface = extends + "." + iface_name;
generate_delphi_doc(s_service, tservice);
@@ -1996,7 +1997,7 @@
string implements = async_ ? "Iface, IAsync" : "Iface";
generate_delphi_doc(s_service, tservice);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends(), true, true);
extends_client = extends + ".TClient";
}
@@ -2281,7 +2282,7 @@
string full_cls = normalize_clsnm(service_name_, "T") + ".TProcessorImpl";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends(), true, true);
extends_processor = extends + ".TProcessorImpl";
indent(s_service) << "TProcessorImpl = class(" << extends_processor << ", IProcessor)" << endl;
@@ -2298,13 +2299,13 @@
indent_impl(s_service_impl) << "constructor " << full_cls << ".Create( iface_: Iface );" << endl;
indent_impl(s_service_impl) << "begin" << endl;
indent_up_impl();
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
indent_impl(s_service_impl) << "inherited Create( iface_);" << endl;
} else {
indent_impl(s_service_impl) << "inherited Create;" << endl;
}
indent_impl(s_service_impl) << "Self.iface_ := iface_;" << endl;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
indent_impl(s_service_impl) << "ASSERT( processMap_ <> nil); // inherited" << endl;
} else {
indent_impl(s_service_impl)
@@ -2330,7 +2331,7 @@
indent(s_service) << "iface_: Iface;" << endl;
indent_down();
- if (tservice->get_extends() == NULL) {
+ if (tservice->get_extends() == nullptr) {
indent(s_service) << "protected" << endl;
indent_up();
indent(s_service) << "type" << endl;
@@ -3078,7 +3079,7 @@
if (ttype->is_typedef()) {
t_typedef* tdef = (t_typedef*)ttype;
if (tdef->is_forward_typedef()) { // forward types according to THRIFT-2421
- if (tdef->get_type() != NULL) {
+ if (tdef->get_type() != nullptr) {
return type_name(tdef->get_type(),
b_cls,
b_no_postfix,
@@ -3459,10 +3460,11 @@
<< type_name(ftype, false, true, is_xception, true) << ";" << endl;
}
-void t_delphi_generator::generate_delphi_isset_reader_definition(ostream& out,
+void t_delphi_generator::generate_delphi_isset_reader_writer_definition(ostream& out,
t_field* tfield,
bool is_xception) {
indent(out) << "function Get__isset_" << prop_name(tfield, is_xception) << ": System.Boolean;" << endl;
+ indent(out) << "procedure Set__isset_" << prop_name(tfield, is_xception) << "( const value : System.Boolean);" << endl;
}
void t_delphi_generator::generate_delphi_clear_union_value(ostream& out,
@@ -3557,7 +3559,7 @@
indent_impl(out) << "end;" << endl << endl;
}
-void t_delphi_generator::generate_delphi_isset_reader_impl(ostream& out,
+void t_delphi_generator::generate_delphi_isset_reader_writer_impl(ostream& out,
std::string cls_prefix,
std::string name,
t_type* type,
@@ -3567,6 +3569,7 @@
(void)type;
string isset_name = "__isset_" + prop_name(tfield, is_xception);
+
indent_impl(out) << "function " << cls_prefix << name << "."
<< "Get" << isset_name << ": System.Boolean;" << endl;
indent_impl(out) << "begin" << endl;
@@ -3574,6 +3577,14 @@
indent_impl(out) << "Result := " << fieldPrefix << isset_name << ";" << endl;
indent_down_impl();
indent_impl(out) << "end;" << endl << endl;
+
+ indent_impl(out) << "procedure " << cls_prefix << name << "."
+ << "Set" << isset_name << "( const value: System.Boolean);" << endl;
+ indent_impl(out) << "begin" << endl;
+ indent_up_impl();
+ indent_impl(out) << fieldPrefix << isset_name << " := value;" << endl;
+ indent_down_impl();
+ indent_impl(out) << "end;" << endl << endl;
}
void t_delphi_generator::generate_delphi_create_exception_impl(ostream& out,
diff --git a/compiler/cpp/src/thrift/generate/t_erl_generator.cc b/compiler/cpp/src/thrift/generate/t_erl_generator.cc
index 910a38a..c96c1b2 100644
--- a/compiler/cpp/src/thrift/generate/t_erl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_erl_generator.cc
@@ -625,13 +625,13 @@
bool first = true;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -909,7 +909,7 @@
hrl_header(f_service_hrl_, service_name_);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_hrl_ << "-include(\""
<< make_safe_for_module_name(tservice->get_extends()->get_name())
<< "_thrift.hrl\"). % inherit " << endl;
@@ -1013,7 +1013,7 @@
}
// Inheritance - pass unknown functions to base class
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
indent(f_service_) << "function_info(Function, InfoType) ->" << endl;
indent_up();
indent(f_service_) << make_safe_for_module_name(tservice->get_extends()->get_name())
diff --git a/compiler/cpp/src/thrift/generate/t_generator.cc b/compiler/cpp/src/thrift/generate/t_generator.cc
index ca3f5dd..3059fb1 100644
--- a/compiler/cpp/src/thrift/generate/t_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_generator.cc
@@ -234,8 +234,15 @@
gen_map_t& the_map = get_generator_map();
gen_map_t::iterator iter = the_map.find(language);
+ if ((language == "csharp") || (language == "netcore")) {
+ failure("The '%s' target is no longer available. Use 'netstd' instead.", language.c_str());
+ }
+ else if (language == "as3") {
+ pwarning(1, "The '%s' target is deprecated and will be removed in future Thrift versions.", language.c_str());
+ }
+
if (iter == the_map.end()) {
- return NULL;
+ return nullptr;
}
return iter->second->get_generator(program, parsed_options, options);
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index b89052b..6f73819 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -1193,7 +1193,7 @@
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
bool is_optional = false;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
@@ -1202,7 +1202,7 @@
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
out << endl << indent() << publicize(v_iter->first->get_string()) << ": "
@@ -1303,7 +1303,7 @@
string publicized_name;
t_const_value* def_value;
get_publicized_name_and_def_value(member, &publicized_name, &def_value);
- if (!pointer_field && def_value != NULL && !omit_initialization(member)) {
+ if (!pointer_field && def_value != nullptr && !omit_initialization(member)) {
out << endl << indent() << publicized_name << ": "
<< render_field_initial_value(member, member->get_name(), pointer_field) << ","
<< endl;
@@ -1441,7 +1441,7 @@
string def_var_name = tstruct_name + "_" + publicized_name + "_DEFAULT";
if ((*m_iter)->get_req() == t_field::T_OPTIONAL || is_pointer_field(*m_iter)) {
out << indent() << "var " << def_var_name << " " << goType;
- if (def_value != NULL) {
+ if (def_value != nullptr) {
out << " = " << render_const_value(fieldType, def_value, (*m_iter)->get_name());
}
out << endl;
@@ -1913,7 +1913,7 @@
string serviceName(publicize(tservice->get_name()));
string interfaceName = serviceName;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
size_t index = extends.rfind(".");
@@ -1956,7 +1956,7 @@
string extends_client_new = "";
string serviceName(publicize(tservice->get_name()));
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
size_t index = extends.rfind(".");
@@ -2149,7 +2149,7 @@
// collect all functions including inherited functions
t_service* parent = tservice;
- while (parent != NULL) {
+ while (parent != nullptr) {
vector<t_function*> p_functions = parent->get_functions();
functions.insert(functions.end(), p_functions.begin(), p_functions.end());
@@ -2639,7 +2639,7 @@
string extends_processor_new = "";
string serviceName(publicize(tservice->get_name()));
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
size_t index = extends.rfind(".");
@@ -3446,7 +3446,7 @@
std::ostringstream result;
result << publicize(tfield->get_name()) << "=";
- if (tfield->get_value() != NULL) {
+ if (tfield->get_value() != nullptr) {
result << "thrift_spec[" << tfield->get_key() << "][4]";
} else {
result << "nil";
@@ -3458,7 +3458,7 @@
/**
* Renders a struct field initial value.
*
- * @param tfield The field, which must have `tfield->get_value() != NULL`
+ * @param tfield The field, which must have `tfield->get_value() != nullptr`
*/
string t_go_generator::render_field_initial_value(t_field* tfield,
const string& name,
@@ -3560,7 +3560,7 @@
string t_go_generator::module_name(t_type* ttype) {
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
if (program->get_namespace("go").empty() ||
program_->get_namespace("go").empty() ||
program->get_namespace("go") != program_->get_namespace("go")) {
diff --git a/compiler/cpp/src/thrift/generate/t_gv_generator.cc b/compiler/cpp/src/thrift/generate/t_gv_generator.cc
index 2c0acf9..724a927 100644
--- a/compiler/cpp/src/thrift/generate/t_gv_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_gv_generator.cc
@@ -314,7 +314,7 @@
for (; arg_iter != args.end(); arg_iter++) {
f_out_ << "|<param_" << (*arg_iter)->get_name() << ">";
f_out_ << (*arg_iter)->get_name();
- if ((*arg_iter)->get_value() != NULL) {
+ if ((*arg_iter)->get_value() != nullptr) {
f_out_ << " = ";
print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
diff --git a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
index 13f2cd1..7f1bb6f 100644
--- a/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_haxe_generator.cc
@@ -319,7 +319,7 @@
// For each type check if it is from a different namespace
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_program* program = (*m_iter)->get_type()->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("haxe");
if (!package.empty()) {
if (imports.find(package + "." + (*m_iter)->get_type()->get_name()) == string::npos) {
@@ -344,7 +344,7 @@
// For each type check if it is from a different namespace
for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
t_program* program = (*f_iter)->get_returntype()->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("haxe");
if (!package.empty()) {
if (imports.find(package + "." + (*f_iter)->get_returntype()->get_name()) == string::npos) {
@@ -514,13 +514,13 @@
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
@@ -788,7 +788,7 @@
indent(out) << "super();" << endl;
}
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
indent(out) << "this." << (*m_iter)->get_name() << " = "
<< (*m_iter)->get_value()->get_integer() << ";" << endl;
}
@@ -1483,7 +1483,7 @@
f_service_ << endl << haxe_type_imports() << haxe_thrift_imports()
<< haxe_thrift_gen_imports(tservice);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = parent->get_program()->get_namespace("haxe");
if (!parent_namespace.empty() && parent_namespace != package_name_) {
@@ -1504,7 +1504,7 @@
f_service_ << autogen_comment() << haxe_package() << ";" << endl << endl << haxe_type_imports()
<< haxe_thrift_imports() << haxe_thrift_gen_imports(tservice) << endl;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
t_type* parent = tservice->get_extends();
string parent_namespace = parent->get_program()->get_namespace("haxe");
if (!parent_namespace.empty() && parent_namespace != package_name_) {
@@ -1629,7 +1629,7 @@
*/
void t_haxe_generator::generate_service_interface(t_service* tservice) {
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends_iface = " extends " + tservice->get_extends()->get_name();
}
@@ -1674,7 +1674,7 @@
void t_haxe_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = get_cap_name(tservice->get_extends()->get_name());
extends_client = " extends " + extends + "Impl";
}
@@ -1891,7 +1891,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = get_cap_name(type_name(tservice->get_extends()));
extends_processor = " extends " + extends + "Processor";
}
@@ -1932,7 +1932,7 @@
// Generate the server implementation
string override = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
override = "override ";
}
indent(f_service_) << override
@@ -2606,7 +2606,7 @@
// Check for namespacing
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("haxe");
if (!package.empty()) {
return package + "." + ttype->get_name();
@@ -2660,7 +2660,7 @@
string result = "var " + tfield->get_name() + " : " + type_name(tfield->get_type());
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
- if (ttype->is_base_type() && tfield->get_value() != NULL) {
+ if (ttype->is_base_type() && tfield->get_value() != nullptr) {
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
@@ -2966,7 +2966,7 @@
std::string t_haxe_generator::get_enum_class_name(t_type* type) {
string package = "";
t_program* program = type->get_program();
- if (program != NULL /*&& program != program_*/) {
+ if (program != nullptr /*&& program != program_*/) {
package = program->get_namespace("haxe") + ".";
}
return package + type->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_hs_generator.cc b/compiler/cpp/src/thrift/generate/t_hs_generator.cc
index 00c01a1..d314b8f 100644
--- a/compiler/cpp/src/thrift/generate/t_hs_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_hs_generator.cc
@@ -367,7 +367,7 @@
* validate_types method in main.cc
*/
string t_hs_generator::render_const_value(t_type* type, t_const_value* value) {
- if (value == NULL)
+ if (value == nullptr)
return type_to_default(type);
type = get_true_type(type);
@@ -411,7 +411,7 @@
int val = constant->get_value();
if (val == value->get_integer()) {
t_program* prog = type->get_program();
- if (prog != NULL && prog != program_)
+ if (prog != nullptr && prog != program_)
out << capitalize(prog->get_name()) << "_Types.";
out << capitalize(constant->get_name());
break;
@@ -427,13 +427,13 @@
bool first = true;
for (auto v_iter : val) {
- t_field* field = NULL;
+ t_field* field = nullptr;
for (auto f_iter : fields)
if (f_iter->get_name() == v_iter.first->get_string())
field = f_iter;
- if (field == NULL)
+ if (field == nullptr)
throw "type error: " + cname + " has no field " + v_iter.first->get_string();
string fname = v_iter.first->get_string();
@@ -676,7 +676,7 @@
out << "P.error \"Missing required field: " << fname << "\"";
} else {
if ((field->get_req() == t_field::T_OPTIONAL
- || ((t_type*)field->get_type())->is_xception()) && field->get_value() == NULL) {
+ || ((t_type*)field->get_type())->is_xception()) && field->get_value() == nullptr) {
out << "P.Nothing";
} else {
out << field_name(sname, fname) << " default_" << sname;
@@ -941,7 +941,7 @@
indent(out) << field_name(name, mname) << " = ";
if (field->get_req() == t_field::T_OPTIONAL
|| ((t_type*)field->get_type())->is_xception()) {
- if (value == NULL) {
+ if (value == nullptr) {
out << "P.Nothing";
} else {
out << "P.Just " << render_const_value(type, value);
@@ -973,7 +973,7 @@
f_iface_ << endl;
string sname = capitalize(service_name_);
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
string extends = type_name(tservice->get_extends());
indent(f_iface_) << "import " << extends << "_Iface" << endl;
@@ -1026,7 +1026,7 @@
string sname = capitalize(service_name_);
indent(f_client_) << "module " << sname << "_Client(" << exports << ") where" << endl;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
indent(f_client_) << "import " << extends << "_Client" << endl;
}
@@ -1156,7 +1156,7 @@
}
indent(f_service_) << "_ -> ";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_ << type_name(tservice->get_extends())
<< ".proc_ handler (iprot,oprot) (name,typ,seqid)" << endl;
@@ -1510,7 +1510,7 @@
string prefix = "";
t_program* program = ttype->get_program();
- if (program != NULL && program != program_)
+ if (program != nullptr && program != program_)
if (!ttype->is_service())
prefix = capitalize(program->get_name()) + "_Types.";
diff --git a/compiler/cpp/src/thrift/generate/t_html_generator.cc b/compiler/cpp/src/thrift/generate/t_html_generator.cc
index b61a712..3bff2c9 100644
--- a/compiler/cpp/src/thrift/generate/t_html_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_html_generator.cc
@@ -776,13 +776,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = tvalue->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + truetype->get_name() + " has no field "
+ v_iter->first->get_string();
}
@@ -990,7 +990,7 @@
}
f_out_ << "</td><td>";
t_const_value* default_val = (*mem_iter)->get_value();
- if (default_val != NULL) {
+ if (default_val != nullptr) {
f_out_ << "<code>";
print_const_value((*mem_iter)->get_type(), default_val);
f_out_ << "</code>";
@@ -1049,7 +1049,7 @@
first = false;
print_type((*arg_iter)->get_type());
f_out_ << " " << (*arg_iter)->get_name();
- if ((*arg_iter)->get_value() != NULL) {
+ if ((*arg_iter)->get_value() != nullptr) {
f_out_ << " = ";
print_const_value((*arg_iter)->get_type(), (*arg_iter)->get_value());
}
diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc
index 24637d3..8778702 100644
--- a/compiler/cpp/src/thrift/generate/t_java_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc
@@ -305,7 +305,7 @@
t_type* type);
enum isset_type { ISSET_NONE, ISSET_PRIMITIVE, ISSET_BITSET };
- isset_type needs_isset(t_struct* tstruct, std::string* outPrimitiveType = NULL);
+ isset_type needs_isset(t_struct* tstruct, std::string* outPrimitiveType = nullptr);
/**
* Helper rendering functions
@@ -648,13 +648,13 @@
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, field_type, v_iter->second);
@@ -911,7 +911,7 @@
bool default_value = false;
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* type = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
indent(out) << "super(_Fields." << constant_name((*m_iter)->get_name()) << ", "
<< render_const_value(out, type, (*m_iter)->get_value()) << ");" << endl;
default_value = true;
@@ -1546,7 +1546,7 @@
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
print_const_value(out,
"this." + (*m_iter)->get_name(),
t,
@@ -2882,7 +2882,7 @@
void t_java_generator::generate_service_interface(t_service* tservice) {
string extends = "";
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_iface = " extends " + extends + ".Iface";
}
@@ -2903,7 +2903,7 @@
void t_java_generator::generate_service_async_interface(t_service* tservice) {
string extends = "";
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_iface = " extends " + extends + " .AsyncIface";
}
@@ -2943,7 +2943,7 @@
void t_java_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() == NULL) {
+ if (tservice->get_extends() == nullptr) {
extends_client = "org.apache.thrift.TServiceClient";
} else {
extends = type_name(tservice->get_extends());
@@ -3106,7 +3106,7 @@
void t_java_generator::generate_service_async_client(t_service* tservice) {
string extends = "org.apache.thrift.async.TAsyncClient";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends()) + ".AsyncClient";
}
@@ -3282,7 +3282,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() == NULL) {
+ if (tservice->get_extends() == nullptr) {
extends_processor = "org.apache.thrift.TBaseProcessor<I>";
} else {
extends = type_name(tservice->get_extends());
@@ -3345,7 +3345,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() == NULL) {
+ if (tservice->get_extends() == nullptr) {
extends_processor = "org.apache.thrift.TBaseAsyncProcessor<I>";
} else {
extends = type_name(tservice->get_extends());
@@ -4299,7 +4299,7 @@
// Check for namespacing
t_program* program = ttype->get_program();
- if ((program != NULL) && ((program != program_) || force_namespace)) {
+ if ((program != nullptr) && ((program != program_) || force_namespace)) {
string package = program->get_namespace("java");
if (!package.empty()) {
return package + "." + ttype->get_name();
@@ -4359,7 +4359,7 @@
}
result += type_name(tfield->get_type()) + " " + tfield->get_name();
if (init) {
- if (ttype->is_base_type() && tfield->get_value() != NULL) {
+ if (ttype->is_base_type() && tfield->get_value() != nullptr) {
std::ofstream dummy;
result += " = " + render_const_value(dummy, ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
@@ -4998,7 +4998,7 @@
if (count == 0) {
return ISSET_NONE;
} else if (count <= 64) {
- if (outPrimitiveType != NULL) {
+ if (outPrimitiveType != nullptr) {
if (count <= 8)
*outPrimitiveType = "byte";
else if (count <= 16)
@@ -5028,7 +5028,7 @@
t_field* field = *m_iter;
t_type* t = get_true_type(field->get_type());
- if (field->get_value() != NULL) {
+ if (field->get_value() != nullptr) {
print_const_value(out, "this." + field->get_name(), t, field->get_value(), true, true);
continue;
}
@@ -5420,7 +5420,7 @@
}
void t_java_generator::generate_javax_generated_annotation(ostream& out) {
- time_t seconds = time(NULL);
+ time_t seconds = time(nullptr);
struct tm* now = localtime(&seconds);
indent(out) << "@javax.annotation.Generated(value = \"" << autogen_summary() << "\"";
if (undated_generated_annotations_) {
diff --git a/compiler/cpp/src/thrift/generate/t_javame_generator.cc b/compiler/cpp/src/thrift/generate/t_javame_generator.cc
index e1694ab..b37a43b 100644
--- a/compiler/cpp/src/thrift/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_javame_generator.cc
@@ -462,13 +462,13 @@
indent_up();
}
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string val = render_const_value(out, name, field_type, v_iter->second);
@@ -1060,7 +1060,7 @@
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
print_const_value(out,
"this." + (*m_iter)->get_name(),
t,
@@ -1898,7 +1898,7 @@
f_iface.open(f_interface_name.c_str());
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends_iface = " extends " + type_name(tservice->get_extends()) + "Iface";
}
@@ -1923,7 +1923,7 @@
void t_javame_generator::generate_service_interface(t_service* tservice) {
string extends = "";
string extends_iface = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_iface = " extends " + extends + ".Iface";
}
@@ -1964,7 +1964,7 @@
void t_javame_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_client = " extends " + extends + ".Client";
}
@@ -2144,7 +2144,7 @@
// Extends stuff
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_processor = " extends " + extends + ".Processor";
}
@@ -2791,7 +2791,7 @@
// Check for namespacing
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
string package = program->get_namespace("java");
if (!package.empty()) {
return package + "." + ttype->get_name();
@@ -2846,7 +2846,7 @@
string result = type_name(tfield->get_type()) + " " + tfield->get_name();
if (init) {
t_type* ttype = get_true_type(tfield->get_type());
- if (ttype->is_base_type() && tfield->get_value() != NULL) {
+ if (ttype->is_base_type() && tfield->get_value() != nullptr) {
std::ofstream dummy;
result += " = " + render_const_value(dummy, tfield->get_name(), ttype, tfield->get_value());
} else if (ttype->is_base_type()) {
@@ -3208,7 +3208,7 @@
std::string t_javame_generator::get_enum_class_name(t_type* type) {
string package = "";
t_program* program = type->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
package = program->get_namespace("java") + ".";
}
return package + type->get_name();
@@ -3252,7 +3252,7 @@
indent_up();
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL) {
+ if ((*m_iter)->get_value() != nullptr) {
print_const_value(out,
"this." + (*m_iter)->get_name(),
t,
diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index 9766897..fddcef4 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -223,11 +223,12 @@
std::string argument_list(t_struct* tstruct, bool include_callback = false);
std::string type_to_enum(t_type* ttype);
std::string make_valid_nodeJs_identifier(std::string const& name);
+ std::string next_identifier_name(std::vector<t_field*> const& fields, std::string const& base_name);
+ bool find_field(std::vector<t_field*> const& fields, std::string const& name);
/**
* Helper parser functions
*/
-
void parse_imports(t_program* program, const std::string& imports_string);
void parse_thrift_package_output_directory(const std::string& thrift_package_output_directory);
@@ -265,7 +266,7 @@
std::string js_type_namespace(t_program* p) {
if (gen_node_) {
- if (p != NULL && p != program_) {
+ if (p != nullptr && p != program_) {
return make_valid_nodeJs_identifier(p->get_name()) + "_ttypes.";
}
return "ttypes.";
@@ -325,7 +326,7 @@
* @param t_field The field to check
* @return string
*/
- string ts_get_req(t_field* field) {return (field->get_req() == t_field::T_OPTIONAL || field->get_value() != NULL ? "?" : ""); }
+ string ts_get_req(t_field* field) {return (field->get_req() == t_field::T_OPTIONAL || field->get_value() != nullptr ? "?" : ""); }
/**
* Returns the documentation, if the provided documentable object has one.
@@ -738,13 +739,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw std::runtime_error("type error: " + type->get_name() + " has no field " + v_iter->first->get_string());
}
if (v_iter != val.begin())
@@ -901,7 +902,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string dval = declare_field(*m_iter, false, true);
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && !(t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) {
dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
out << indent() << "this." << (*m_iter)->get_name() << " = " << dval << ";" << endl;
} else {
@@ -923,7 +924,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "this." << (*m_iter)->get_name() << " = "
<< render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
}
@@ -1210,7 +1211,7 @@
f_service_ << js_includes() << endl << render_includes() << endl;
if (gen_ts_) {
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_ts_ << "/// <reference path=\"" << tservice->get_extends()->get_name()
<< ".d.ts\" />" << endl;
}
@@ -1262,13 +1263,16 @@
}
if (gen_node_) {
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_ << js_const_type_ << tservice->get_extends()->get_name() << " = require('./"
<< tservice->get_extends()->get_name() << "');" << endl << js_const_type_
<< tservice->get_extends()->get_name()
<< "Client = " << tservice->get_extends()->get_name() << ".Client;" << endl
<< js_const_type_ << tservice->get_extends()->get_name()
<< "Processor = " << tservice->get_extends()->get_name() << ".Processor;" << endl;
+
+ f_service_ts_ << "import " << tservice->get_extends()->get_name() << " = require('./"
+ << tservice->get_extends()->get_name() << "');" << endl;
}
f_service_ << js_const_type_ << "ttypes = require('./" + program_->get_name() + "_types');" << endl;
@@ -1311,12 +1315,15 @@
f_service_ << prefix << service_name_ << "Processor = " << "exports.Processor";
if (gen_ts_) {
f_service_ts_ << endl << "declare class Processor ";
- if (tservice->get_extends() != NULL) {
- f_service_ts_ << "extends " << tservice->get_extends()->get_name() << "Processor ";
+ if (tservice->get_extends() != nullptr) {
+ f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Processor ";
}
f_service_ts_ << "{" << endl;
indent_up();
- f_service_ts_ << ts_indent() << "private _handler: object;" << endl << endl;
+
+ if(tservice->get_extends() == nullptr) {
+ f_service_ts_ << ts_indent() << "private _handler: object;" << endl << endl;
+ }
f_service_ts_ << ts_indent() << "constructor(handler: object);" << endl;
f_service_ts_ << ts_indent() << "process(input: thrift.TProtocol, output: thrift.TProtocol): void;" << endl;
indent_down();
@@ -1326,14 +1333,14 @@
<< "exports.Processor";
}
- bool is_subclass_service = tservice->get_extends() != NULL;
+ bool is_subclass_service = tservice->get_extends() != nullptr;
// ES6 Constructor
if (gen_es6_) {
if (is_subclass_service) {
- f_service_ << " = class extends " << tservice->get_extends()->get_name() << "Processor {" << endl;
+ f_service_ << " = class " << service_name_ << "Processor extends " << tservice->get_extends()->get_name() << "Processor {" << endl;
} else {
- f_service_ << " = class {" << endl;
+ f_service_ << " = class " << service_name_ << "Processor {" << endl;
}
indent_up();
indent(f_service_) << "constructor(handler) {" << endl;
@@ -1686,7 +1693,7 @@
*/
void t_js_generator::generate_service_client(t_service* tservice) {
- bool is_subclass_service = tservice->get_extends() != NULL;
+ bool is_subclass_service = tservice->get_extends() != nullptr;
if (gen_node_) {
string prefix = has_js_namespace(tservice->get_program()) ? js_namespace(tservice->get_program()) : js_const_type_;
@@ -1694,8 +1701,8 @@
if (gen_ts_) {
f_service_ts_ << ts_print_doc(tservice) << ts_indent() << ts_declare() << "class "
<< "Client ";
- if (tservice->get_extends() != NULL) {
- f_service_ts_ << "extends " << tservice->get_extends()->get_name() << "Client ";
+ if (tservice->get_extends() != nullptr) {
+ f_service_ts_ << "extends " << tservice->get_extends()->get_name() << ".Client ";
}
f_service_ts_ << "{" << endl;
}
@@ -1714,11 +1721,12 @@
// ES6 Constructor
if (gen_es6_) {
+
if (is_subclass_service) {
- f_service_ << " = class extends " << js_namespace(tservice->get_extends()->get_program())
+ f_service_ << " = class " << service_name_ << "Client extends " << js_namespace(tservice->get_extends()->get_program())
<< tservice->get_extends()->get_name() << "Client {" << endl;
} else {
- f_service_ << " = class {" << endl;
+ f_service_ << " = class " << service_name_ << "Client {" << endl;
}
indent_up();
if (gen_node_) {
@@ -1745,11 +1753,14 @@
indent(f_service_) << "this._seqid = 0;" << endl;
indent(f_service_) << "this._reqs = {};" << endl;
if (gen_ts_) {
- f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << endl
- << ts_indent() << "private pClass: thrift.TProtocol;" << endl
- << ts_indent() << "private _seqid: number;" << endl
- << endl
- << ts_indent() << "constructor(output: thrift.TTransport, pClass: { new(trans: thrift.TTransport): thrift.TProtocol });"
+ if(!is_subclass_service) {
+ f_service_ts_ << ts_indent() << "private output: thrift.TTransport;" << endl
+ << ts_indent() << "private pClass: thrift.TProtocol;" << endl
+ << ts_indent() << "private _seqid: number;" << endl
+ << endl;
+ }
+
+ f_service_ts_ << ts_indent() << "constructor(output: thrift.TTransport, pClass: { new(trans: thrift.TTransport): thrift.TProtocol });"
<< endl;
}
} else {
@@ -1958,7 +1969,10 @@
: "Thrift.MessageType.CALL";
// Build args
if (fields.size() > 0){
- f_service_ << indent() << js_const_type_ << "params = {" << endl;
+ // It is possible that a method argument is named "params", we need to ensure the locally
+ // generated identifier "params" is uniquely named
+ std::string params_identifier = this->next_identifier_name(fields, "params");
+ f_service_ << indent() << js_const_type_ << params_identifier << " = {" << endl;
indent_up();
for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) {
indent(f_service_) << (*fld_iter)->get_name() << ": " << (*fld_iter)->get_name();
@@ -1970,7 +1984,9 @@
}
indent_down();
indent(f_service_) << "};" << endl;
- indent(f_service_) << js_const_type_ << "args = new " << argsname << "(params);" << endl;
+
+ // NOTE: "args" is a reserved keyword, so no need to generate a unique identifier
+ indent(f_service_) << js_const_type_ << "args = new " << argsname << "(" << params_identifier << ");" << endl;
} else {
indent(f_service_) << js_const_type_ << "args = new " << argsname << "();" << endl;
}
@@ -2729,7 +2745,7 @@
}
} else if (type->is_enum() || type->is_struct() || type->is_xception()) {
std::string type_name;
-
+
if (type->get_program()) {
type_name = js_namespace(type->get_program());
@@ -2938,6 +2954,33 @@
}
}
+/**
+ * Checks is the specified field name is contained in the specified field vector
+ */
+bool t_js_generator::find_field(const std::vector<t_field*>& fields, const std::string& name) {
+ vector<t_field*>::const_iterator f_iter;
+ for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
+ if ((*f_iter)->get_name() == name) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
+ * Given a vector of fields, generate a valid identifier name that does not conflict with avaliable field names
+ */
+std::string t_js_generator::next_identifier_name(const std::vector<t_field*>& fields, const std::string& base_name) {
+ // Search through fields until a match is not found, if a match is found prepend "_" to the identifier name
+ std::string current_name = this->make_valid_nodeJs_identifier(base_name);
+ while(this->find_field(fields, current_name)) {
+ current_name = this->make_valid_nodeJs_identifier("_" + current_name);
+ }
+
+ return current_name;
+}
+
THRIFT_REGISTER_GENERATOR(js,
"Javascript",
" jquery: Generate jQuery compatible code.\n"
diff --git a/compiler/cpp/src/thrift/generate/t_lua_generator.cc b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
index f858562..b63569d 100644
--- a/compiler/cpp/src/thrift/generate/t_lua_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_lua_generator.cc
@@ -282,13 +282,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end();) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -513,7 +513,7 @@
if (gen_requires_) {
f_service_ << endl << "require '" << cur_ns << "ttypes'" << endl;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_ << "require '" << get_namespace(tservice->get_extends()->get_program())
<< tservice->get_extends()->get_name() << "'" << endl;
}
@@ -550,7 +550,7 @@
// Client object definition
out << classname << " = __TObject.new(";
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
out << extends_s->get_name() << "Client";
} else {
out << "__TClient";
@@ -646,7 +646,7 @@
// Define processor table
out << endl << classname << " = __TObject.new(";
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
out << extends_s->get_name() << "Processor" << endl;
} else {
out << "__TProcessor" << endl;
diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index 7be3230..0373faf 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -128,7 +128,7 @@
return struct_name;
}
-static bool field_has_default(t_field* tfield) { return tfield->get_value() != NULL; }
+static bool field_has_default(t_field* tfield) { return tfield->get_value() != nullptr; }
static bool field_is_required(t_field* tfield) { return tfield->get_req() == t_field::T_REQUIRED; }
@@ -502,7 +502,7 @@
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter)
{
- t_field* field = NULL;
+ t_field* field = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter)
{
@@ -512,7 +512,7 @@
}
}
- if (field == NULL)
+ if (field == nullptr)
{
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -1031,7 +1031,7 @@
t_type* t = (*m_iter)->get_type();
t = resolve_typedef(t);
- if ((*m_iter)->get_value() != NULL)
+ if ((*m_iter)->get_value() != nullptr)
{
if (field_is_required((*m_iter)))
{
@@ -1924,7 +1924,7 @@
{
string extends = "";
string extends_iface = "";
- if (tservice->get_extends() != NULL)
+ if (tservice->get_extends() != nullptr)
{
extends = type_name(tservice->get_extends());
extends_iface = " : " + extends + ".IAsync";
@@ -1986,7 +1986,7 @@
{
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL)
+ if (tservice->get_extends() != nullptr)
{
extends = type_name(tservice->get_extends());
extends_client = extends + ".Client, ";
@@ -2132,7 +2132,7 @@
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL)
+ if (tservice->get_extends() != nullptr)
{
extends = type_name(tservice->get_extends());
extends_processor = extends + ".AsyncProcessor, ";
@@ -3120,7 +3120,7 @@
string the_name = check_and_correct_struct_name(normalize_name(ttype->get_name()));
t_program* program = ttype->get_program();
- if (program != NULL && program != program_)
+ if (program != nullptr && program != program_)
{
string ns = program->get_namespace("netstd");
if (!ns.empty())
@@ -3434,7 +3434,7 @@
{
string package = "";
t_program* program = type->get_program();
- if (program != NULL && program != program_)
+ if (program != nullptr && program != program_)
{
package = program->get_namespace("netstd") + ".";
}
diff --git a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
index a3781e8..0a96146 100644
--- a/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_ocaml_generator.cc
@@ -404,13 +404,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
string fname = v_iter->first->get_string();
@@ -898,7 +898,7 @@
f_service_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
f_service_i_ << ocaml_autogen_comment() << endl << ocaml_imports() << endl;
- /* if (tservice->get_extends() != NULL) {
+ /* if (tservice->get_extends() != nullptr) {
f_service_ <<
"open " << capitalize(tservice->get_extends()->get_name()) << endl;
f_service_i_ <<
@@ -970,7 +970,7 @@
indent_up();
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
string extends = type_name(tservice->get_extends());
indent(f_service_) << "inherit " << extends << ".iface" << endl;
indent(f_service_i_) << "inherit " << extends << ".iface" << endl;
@@ -1004,7 +1004,7 @@
indent(f_service_i_) << "class client : Protocol.t -> Protocol.t -> " << endl << "object" << endl;
indent_up();
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
indent(f_service_) << "inherit " << extends << ".client iprot oprot as super" << endl;
indent(f_service_i_) << "inherit " << extends << ".client" << endl;
@@ -1155,7 +1155,7 @@
f_service_i_ << indent() << "inherit Processor.t" << endl << endl;
string extends = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
indent(f_service_) << "inherit " + extends + ".processor (handler :> " + extends + ".iface)"
<< endl;
@@ -1377,7 +1377,7 @@
void t_ocaml_generator::generate_deserialize_struct(ostream& out, t_struct* tstruct) {
string prefix = "";
t_program* program = tstruct->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
prefix = capitalize(program->get_name()) + "_types.";
}
string name = decapitalize(tstruct->get_name());
@@ -1658,7 +1658,7 @@
string t_ocaml_generator::type_name(t_type* ttype) {
string prefix = "";
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
if (!ttype->is_service()) {
prefix = capitalize(program->get_name()) + "_types.";
}
diff --git a/compiler/cpp/src/thrift/generate/t_oop_generator.h b/compiler/cpp/src/thrift/generate/t_oop_generator.h
index f8da547..2df1be4 100644
--- a/compiler/cpp/src/thrift/generate/t_oop_generator.h
+++ b/compiler/cpp/src/thrift/generate/t_oop_generator.h
@@ -59,7 +59,7 @@
virtual std::string get_enum_class_name(t_type* type) {
std::string package = "";
t_program* program = type->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
package = program->get_namespace("java") + ".";
}
return package + type->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_perl_generator.cc b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
index 80729cb..2e687dd 100644
--- a/compiler/cpp/src/thrift/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_perl_generator.cc
@@ -362,13 +362,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
indent(out) << render_const_value(g_type_string, v_iter->first);
@@ -489,7 +489,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string dval = "undef";
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && !(t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) {
dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
}
out << indent() << "$self->{" << (*m_iter)->get_name() << "} = " << dval << ";" << endl;
@@ -500,7 +500,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "$self->{" << (*m_iter)->get_name()
<< "} = " << render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
}
@@ -680,7 +680,7 @@
generate_use_includes(f_service_, done, tservice, true);
t_service* extends_s = tservice->get_extends();
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
f_service_ << "use " << perl_namespace(extends_s->get_program()) << extends_s->get_name() << ";"
<< endl;
}
@@ -712,7 +712,7 @@
string extends = "";
string extends_processor = "";
t_service* extends_s = tservice->get_extends();
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
extends = perl_namespace(extends_s->get_program()) + extends_s->get_name();
extends_processor = "use base qw(" + extends + "Processor);";
}
@@ -939,7 +939,7 @@
void t_perl_generator::generate_service_interface(t_service* tservice) {
string extends_if = "";
t_service* extends_s = tservice->get_extends();
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name()
+ "If);";
}
@@ -964,7 +964,7 @@
string extends = "";
string extends_if = "";
t_service* extends_s = tservice->get_extends();
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
extends = extends_s->get_name();
extends_if = "use base qw(" + perl_namespace(extends_s->get_program()) + extends_s->get_name()
+ "Rest);";
@@ -1024,7 +1024,7 @@
string extends = "";
string extends_client = "";
t_service* extends_s = tservice->get_extends();
- if (extends_s != NULL) {
+ if (extends_s != nullptr) {
extends = perl_namespace(extends_s->get_program()) + extends_s->get_name();
extends_client = "use base qw(" + extends + "Client);";
}
diff --git a/compiler/cpp/src/thrift/generate/t_php_generator.cc b/compiler/cpp/src/thrift/generate/t_php_generator.cc
index e29ad77..c327854 100644
--- a/compiler/cpp/src/thrift/generate/t_php_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_php_generator.cc
@@ -651,13 +651,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
out << indent();
@@ -846,7 +846,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
string dval = "null";
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && !(t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && !(t->is_struct() || t->is_xception())) {
dval = render_const_value((*m_iter)->get_type(), (*m_iter)->get_value());
}
generate_php_doc(out, *m_iter);
@@ -864,7 +864,7 @@
if (members.size() > 0) {
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
t_type* t = get_true_type((*m_iter)->get_type());
- if ((*m_iter)->get_value() != NULL && (t->is_struct() || t->is_xception())) {
+ if ((*m_iter)->get_value() != nullptr && (t->is_struct() || t->is_xception())) {
indent(out) << "$this->" << (*m_iter)->get_name() << " = "
<< render_const_value(t, (*m_iter)->get_value()) << ";" << endl;
}
@@ -1293,7 +1293,7 @@
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = tservice->get_extends()->get_name();
extends_processor = " extends " + php_namespace(tservice->get_extends()->get_program())
+ extends + "Processor";
@@ -1618,7 +1618,7 @@
string extends = "";
string extends_if = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " extends " + php_namespace(tservice->get_extends()->get_program())
+ tservice->get_extends()->get_name();
extends_if = " extends " + php_namespace(tservice->get_extends()->get_program())
@@ -1657,7 +1657,7 @@
string extends = "";
string extends_if = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = " extends " + php_namespace(tservice->get_extends()->get_program())
+ tservice->get_extends()->get_name();
extends_if = " extends " + php_namespace(tservice->get_extends()->get_program())
@@ -1738,7 +1738,7 @@
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = tservice->get_extends()->get_name();
extends_client = " extends " + php_namespace(tservice->get_extends()->get_program()) + extends
+ "Client";
diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc
index 4be2fcc..827c482 100644
--- a/compiler/cpp/src/thrift/generate/t_py_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc
@@ -252,8 +252,8 @@
std::string type_name(t_type* ttype);
std::string function_signature(t_function* tfunction, bool interface = false);
std::string argument_list(t_struct* tstruct,
- std::vector<std::string>* pre = NULL,
- std::vector<std::string>* post = NULL);
+ std::vector<std::string>* pre = nullptr,
+ std::vector<std::string>* post = nullptr);
std::string type_to_enum(t_type* ttype);
std::string type_to_spec_args(t_type* ttype);
@@ -590,13 +590,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
indent(out) << render_const_value(g_type_string, v_iter->first) << ": "
@@ -832,7 +832,7 @@
for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) {
// Initialize fields
t_type* type = (*m_iter)->get_type();
- if (!type->is_base_type() && !type->is_enum() && (*m_iter)->get_value() != NULL) {
+ if (!type->is_base_type() && !type->is_enum() && (*m_iter)->get_value() != nullptr) {
indent(out) << "if " << (*m_iter)->get_name() << " is "
<< "self.thrift_spec[" << (*m_iter)->get_key() << "][4]:" << endl;
indent_up();
@@ -987,7 +987,7 @@
t_field* tfield = *f_iter;
std::ostringstream result;
result << tfield->get_name() << " = ";
- if (tfield->get_value() != NULL) {
+ if (tfield->get_value() != nullptr) {
result << render_field_default_value(tfield);
} else {
result << "None";
@@ -1138,7 +1138,7 @@
f_service_ << py_autogen_comment() << endl << py_imports() << endl;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
f_service_ << "import "
<< get_real_py_module(tservice->get_extends()->get_program(), gen_twisted_, package_prefix_) << "."
<< tservice->get_extends()->get_name() << endl;
@@ -1227,7 +1227,7 @@
void t_py_generator::generate_service_interface(t_service* tservice) {
string extends = "";
string extends_if = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_if = "(" + extends + ".Iface)";
} else {
@@ -1272,7 +1272,7 @@
void t_py_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
if (gen_zope_interface_) {
extends_client = "(" + extends + ".Client)";
@@ -1609,7 +1609,7 @@
vector<t_function*> functions = tservice->get_functions();
// Get all function from parents
t_service* parent = tservice->get_extends();
- while (parent != NULL) {
+ while (parent != nullptr) {
vector<t_function*> p_functions = parent->get_functions();
functions.insert(functions.end(), p_functions.begin(), p_functions.end());
parent = parent->get_extends();
@@ -1818,7 +1818,7 @@
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_processor = extends + ".Processor, ";
}
@@ -2609,7 +2609,7 @@
string t_py_generator::declare_argument(t_field* tfield) {
std::ostringstream result;
result << tfield->get_name() << "=";
- if (tfield->get_value() != NULL) {
+ if (tfield->get_value() != nullptr) {
result << render_field_default_value(tfield);
} else {
result << "None";
@@ -2624,7 +2624,7 @@
*/
string t_py_generator::render_field_default_value(t_field* tfield) {
t_type* type = get_true_type(tfield->get_type());
- if (tfield->get_value() != NULL) {
+ if (tfield->get_value() != nullptr) {
return render_const_value(type, tfield->get_value());
} else {
return "None";
@@ -2700,7 +2700,7 @@
if (ttype->is_service()) {
return get_real_py_module(program, gen_twisted_, package_prefix_) + "." + ttype->get_name();
}
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
return get_real_py_module(program, gen_twisted_, package_prefix_) + ".ttypes." + ttype->get_name();
}
return ttype->get_name();
diff --git a/compiler/cpp/src/thrift/generate/t_rb_generator.cc b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
index 61c3481..116ccaa 100644
--- a/compiler/cpp/src/thrift/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
@@ -460,13 +460,13 @@
const map<t_const_value*, t_const_value*, t_const_value::value_compare>& val = value->get_map();
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
out.indent();
@@ -713,7 +713,7 @@
void t_rb_generator::generate_field_data(t_rb_ofstream& out,
t_type* field_type,
const std::string& field_name = "",
- t_const_value* field_value = NULL,
+ t_const_value* field_value = nullptr,
bool optional = false) {
field_type = get_true_type(field_type);
@@ -724,7 +724,7 @@
out << ", :name => '" << field_name << "'";
}
- if (field_value != NULL) {
+ if (field_value != nullptr) {
out << ", :default => ";
render_const_value(out, field_type, field_value);
}
@@ -788,7 +788,7 @@
f_service_ << rb_autogen_comment() << endl << render_require_thrift();
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
if (namespaced_) {
f_service_ << "require '" << rb_namespace_to_path_prefix(
tservice->get_extends()->get_program()->get_namespace("rb"))
@@ -868,7 +868,7 @@
void t_rb_generator::generate_service_client(t_service* tservice) {
string extends = "";
string extends_client = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = full_type_name(tservice->get_extends());
extends_client = " < " + extends + "::Client ";
}
@@ -992,7 +992,7 @@
string extends = "";
string extends_processor = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = full_type_name(tservice->get_extends());
extends_processor = " < " + extends + "::Processor ";
}
diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
index b240d99..bdadf58 100644
--- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
@@ -2470,7 +2470,7 @@
void t_rs_generator::render_sync_handler_trait(t_service *tservice) {
string extension = "";
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
t_service* extends = tservice->get_extends();
extension = " : " + rust_namespace(extends) + rust_sync_handler_trait_name(extends);
}
@@ -2751,7 +2751,7 @@
indent_up();
// if there are any user-defined exceptions for this service call handle them first
- if (tfunc->get_xceptions() != NULL && tfunc->get_xceptions()->get_sorted_members().size() > 0) {
+ if (tfunc->get_xceptions() != nullptr && tfunc->get_xceptions()->get_sorted_members().size() > 0) {
string user_err_var("usr_err");
f_gen_ << indent() << "thrift::Error::User(" << user_err_var << ") => {" << endl;
indent_up();
@@ -2780,7 +2780,7 @@
}
void t_rs_generator::render_sync_handler_failed_user_exception_branch(t_function *tfunc) {
- if (tfunc->get_xceptions() == NULL || tfunc->get_xceptions()->get_sorted_members().empty()) {
+ if (tfunc->get_xceptions() == nullptr || tfunc->get_xceptions()->get_sorted_members().empty()) {
throw "cannot render user exception branches if no user exceptions defined";
}
@@ -2918,7 +2918,7 @@
}
// any user-defined exceptions
- if (tfunc->get_xceptions() != NULL) {
+ if (tfunc->get_xceptions() != nullptr) {
t_struct* txceptions = tfunc->get_xceptions();
const vector<t_field*> members = txceptions->get_sorted_members();
vector<t_field*>::const_iterator members_iter;
@@ -3170,7 +3170,7 @@
}
bool t_rs_generator::has_args(t_function* tfunc) {
- return tfunc->get_arglist() != NULL && !tfunc->get_arglist()->get_sorted_members().empty();
+ return tfunc->get_arglist() != nullptr && !tfunc->get_arglist()->get_sorted_members().empty();
}
bool t_rs_generator::has_non_void_args(t_function* tfunc) {
diff --git a/compiler/cpp/src/thrift/generate/t_st_generator.cc b/compiler/cpp/src/thrift/generate/t_st_generator.cc
index bc95feb..109adc7 100644
--- a/compiler/cpp/src/thrift/generate/t_st_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_st_generator.cc
@@ -406,13 +406,13 @@
map<t_const_value*, t_const_value*, t_const_value::value_compare>::const_iterator v_iter;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -934,7 +934,7 @@
vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter;
- if (tservice->get_extends() != NULL) {
+ if (tservice->get_extends() != nullptr) {
extends = type_name(tservice->get_extends());
extends_client = extends + "Client";
}
@@ -1000,7 +1000,7 @@
string t_st_generator::type_name(t_type* ttype) {
string prefix = "";
t_program* program = ttype->get_program();
- if (program != NULL && program != program_) {
+ if (program != nullptr && program != program_) {
if (!ttype->is_service()) {
prefix = program->get_name() + "_types.";
}
diff --git a/compiler/cpp/src/thrift/generate/t_swift_generator.cc b/compiler/cpp/src/thrift/generate/t_swift_generator.cc
index 91181f6..d8eb733 100644
--- a/compiler/cpp/src/thrift/generate/t_swift_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_swift_generator.cc
@@ -1599,7 +1599,7 @@
indent(out) << "public protocol " << tservice->get_name();
t_service* parent = tservice->get_extends();
- if (parent != NULL) {
+ if (parent != nullptr) {
out << " : " << parent->get_name();
}
block_open(out);
@@ -1684,7 +1684,7 @@
// Inherit from ParentClient
t_service* parent = tservice->get_extends();
- out << " : " << ((parent == NULL) ? "TClient" : parent->get_name() + "Client");
+ out << " : " << ((parent == nullptr) ? "TClient" : parent->get_name() + "Client");
out << " /* , " << tservice->get_name() << " */";
block_open(out);
out << endl;
@@ -1729,7 +1729,7 @@
// Inherit from ParentClient
t_service* parent = tservice->get_extends();
- out << " : " << ((parent == NULL) ? "T" : parent->get_name()) + "AsyncClient<Protocol, Factory>";
+ out << " : " << ((parent == nullptr) ? "T" : parent->get_name()) + "AsyncClient<Protocol, Factory>";
out << " /* , " << tservice->get_name() << " */";
block_open(out);
@@ -2646,7 +2646,7 @@
for (f_iter = fields.begin(); f_iter != fields.end();) {
t_field* tfield = *f_iter;
- t_const_value* value = NULL;
+ t_const_value* value = nullptr;
for (v_iter = val.begin(); v_iter != val.end(); ++v_iter) {
if (tfield->get_name() == v_iter->first->get_string()) {
value = v_iter->second;
diff --git a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
index 379e5a4..d7fb6cf 100644
--- a/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_xsd_generator.cc
@@ -82,7 +82,7 @@
void generate_element(std::ostream& out,
std::string name,
t_type* ttype,
- t_struct* attrs = NULL,
+ t_struct* attrs = nullptr,
bool optional = false,
bool nillable = false,
bool list_element = false);
@@ -199,7 +199,7 @@
if (ttype->is_void() || ttype->is_list()) {
indent(out) << "<xsd:element name=\"" << name << "\"" << soptional << snillable << ">" << endl;
indent_up();
- if (attrs == NULL && ttype->is_void()) {
+ if (attrs == nullptr && ttype->is_void()) {
indent(out) << "<xsd:complexType />" << endl;
} else {
indent(out) << "<xsd:complexType>" << endl;
@@ -216,12 +216,12 @@
}
f_php_ << "$GLOBALS['" << program_->get_name() << "_xsd_elt_" << name << "'] = '" << subname
<< "';" << endl;
- generate_element(out, subname, subtype, NULL, false, false, true);
+ generate_element(out, subname, subtype, nullptr, false, false, true);
indent_down();
indent(out) << "</xsd:sequence>" << endl;
indent(out) << "<xsd:attribute name=\"list\" type=\"xsd:boolean\" />" << endl;
}
- if (attrs != NULL) {
+ if (attrs != nullptr) {
const vector<t_field*>& members = attrs->get_members();
vector<t_field*>::const_iterator a_iter;
for (a_iter = members.begin(); a_iter != members.end(); ++a_iter) {
@@ -235,7 +235,7 @@
indent_down();
indent(out) << "</xsd:element>" << endl;
} else {
- if (attrs == NULL) {
+ if (attrs == nullptr) {
indent(out) << "<xsd:element name=\"" << name << "\""
<< " type=\"" << type_name(ttype) << "\"" << soptional << snillable << " />"
<< endl;
diff --git a/compiler/cpp/src/thrift/main.cc b/compiler/cpp/src/thrift/main.cc
index 4c900f7..50bdcea 100644
--- a/compiler/cpp/src/thrift/main.cc
+++ b/compiler/cpp/src/thrift/main.cc
@@ -337,7 +337,7 @@
// Realpath!
char rp[THRIFT_PATH_MAX];
// cppcheck-suppress uninitvar
- if (saferealpath(filename.c_str(), rp) == NULL) {
+ if (saferealpath(filename.c_str(), rp) == nullptr) {
pwarning(0, "Cannot open include file %s\n", filename.c_str());
return std::string();
}
@@ -360,7 +360,7 @@
// Realpath!
char rp[THRIFT_PATH_MAX];
// cppcheck-suppress uninitvar
- if (saferealpath(sfilename.c_str(), rp) == NULL) {
+ if (saferealpath(sfilename.c_str(), rp) == nullptr) {
continue;
}
@@ -382,20 +382,20 @@
* Also prints a warning if we are discarding information.
*/
void clear_doctext() {
- if (g_doctext != NULL) {
+ if (g_doctext != nullptr) {
pwarning(2, "Uncaptured doctext at on line %d.", g_doctext_lineno);
}
free(g_doctext);
- g_doctext = NULL;
+ g_doctext = nullptr;
}
/**
* Reset program doctext information after processing a file
*/
void reset_program_doctext_info() {
- if (g_program_doctext_candidate != NULL) {
+ if (g_program_doctext_candidate != nullptr) {
free(g_program_doctext_candidate);
- g_program_doctext_candidate = NULL;
+ g_program_doctext_candidate = nullptr;
}
g_program_doctext_lineno = 0;
g_program_doctext_status = INVALID;
@@ -406,7 +406,7 @@
* We are sure the program doctext candidate is really the program doctext.
*/
void declare_valid_program_doctext() {
- if ((g_program_doctext_candidate != NULL) && (g_program_doctext_status == STILL_CANDIDATE)) {
+ if ((g_program_doctext_candidate != nullptr) && (g_program_doctext_status == STILL_CANDIDATE)) {
g_program_doctext_status = ABSOLUTELY_SURE;
pdebug("%s", "program doctext set to ABSOLUTELY_SURE");
} else {
@@ -446,7 +446,7 @@
// A very profound docstring.
if (lines.empty()) {
- return NULL;
+ return nullptr;
}
// Clear leading whitespace from the first line.
@@ -616,7 +616,7 @@
* Emits a warning on list<byte>, binary type is typically a much better choice.
*/
void check_for_list_of_bytes(t_type* list_elem_type) {
- if ((g_parse_mode == PROGRAM) && (list_elem_type != NULL) && list_elem_type->is_base_type()) {
+ if ((g_parse_mode == PROGRAM) && (list_elem_type != nullptr) && list_elem_type->is_base_type()) {
t_base_type* tbase = (t_base_type*)list_elem_type;
if (tbase->get_base() == t_base_type::TYPE_I8) {
pwarning(1, "Consider using the more efficient \"binary\" type instead of \"list<byte>\".");
@@ -640,12 +640,12 @@
/**
* Prints deprecation notice for old NS declarations that are no longer supported
- * If new_form is NULL, old_form is assumed to be a language identifier, such as "cpp"
- * If new_form is not NULL, both arguments are used exactly as given
+ * If new_form is nullptr, old_form is assumed to be a language identifier, such as "cpp"
+ * If new_form is not nullptr, both arguments are used exactly as given
*/
void error_unsupported_namespace_decl(const char* old_form, const char* new_form) {
const char* remainder = "";
- if( new_form == NULL) {
+ if( new_form == nullptr) {
new_form = old_form;
remainder = "_namespace";
}
@@ -808,13 +808,13 @@
if (v_iter->first->get_type() != t_const_value::CV_STRING) {
throw "type error: " + name + " struct key must be string";
}
- t_type* field_type = NULL;
+ t_type* field_type = nullptr;
for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
if ((*f_iter)->get_name() == v_iter->first->get_string()) {
field_type = (*f_iter)->get_type();
}
}
- if (field_type == NULL) {
+ if (field_type == nullptr) {
throw "type error: " + type->get_name() + " has no field " + v_iter->first->get_string();
}
@@ -951,7 +951,7 @@
g_parse_mode = PROGRAM;
g_program = program;
g_scope = program->scope();
- g_parent_scope = (parent_program != NULL) ? parent_program->scope() : NULL;
+ g_parent_scope = (parent_program != nullptr) ? parent_program->scope() : nullptr;
g_parent_prefix = program->get_name() + ".";
g_curpath = path;
@@ -1004,7 +1004,7 @@
for (iter = generator_strings.begin(); iter != generator_strings.end(); ++iter) {
t_generator* generator = t_generator_registry::get_generator(program, *iter);
- if (generator == NULL) {
+ if (generator == nullptr) {
pwarning(1, "Unable to get a generator for \"%s\".\n", iter->c_str());
g_generator_failure = true;
} else if (generator) {
@@ -1032,14 +1032,14 @@
g_incl_searchpath.push_back(old_thrift_include_path);
}
- parse(old_program, NULL);
+ parse(old_program, nullptr);
g_incl_searchpath = temp_incl_searchpath;
if (!new_thrift_include_path.empty()) {
g_incl_searchpath.push_back(new_thrift_include_path);
}
- parse(new_program, NULL);
+ parse(new_program, nullptr);
compare_namespace(new_program, old_program);
compare_services(new_program->get_services(), old_program->get_services());
@@ -1059,7 +1059,7 @@
bool out_path_is_absolute = false;
// Setup time string
- time_t now = time(NULL);
+ time_t now = time(nullptr);
g_time_str = ctime(&now);
// Check for necessary arguments, you gotta have at least a filename and
@@ -1081,7 +1081,7 @@
char* arg;
arg = strtok(argv[i], " ");
- while (arg != NULL) {
+ while (arg != nullptr) {
// Treat double dashes as single dashes
if (arg[0] == '-' && arg[1] == '-') {
++arg;
@@ -1109,7 +1109,7 @@
g_allow_64bit_consts = true;
} else if (strcmp(arg, "-gen") == 0) {
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "Missing generator specification\n");
usage();
}
@@ -1118,7 +1118,7 @@
// An argument of "-I\ asdf" is invalid and has unknown results
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "Missing Include directory\n");
usage();
}
@@ -1126,7 +1126,7 @@
} else if ((strcmp(arg, "-o") == 0) || (strcmp(arg, "-out") == 0)) {
out_path_is_absolute = (strcmp(arg, "-out") == 0) ? true : false;
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "-o: missing output directory\n");
usage();
}
@@ -1144,14 +1144,14 @@
} else if (strcmp(arg, "-audit") == 0) {
g_audit = true;
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "Missing old thrift file name for audit operation\n");
usage();
}
char old_thrift_file_rp[THRIFT_PATH_MAX];
// cppcheck-suppress uninitvar
- if (saferealpath(arg, old_thrift_file_rp) == NULL) {
+ if (saferealpath(arg, old_thrift_file_rp) == nullptr) {
failure("Could not open input file with realpath: %s", arg);
}
old_input_file = string(old_thrift_file_rp);
@@ -1159,14 +1159,14 @@
g_audit_fatal = false;
} else if (strcmp(arg, "-Iold") == 0) {
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "Missing Include directory for old thrift file\n");
usage();
}
old_thrift_include_path = string(arg);
} else if (strcmp(arg, "-Inew") == 0) {
arg = argv[++i];
- if (arg == NULL) {
+ if (arg == nullptr) {
fprintf(stderr, "Missing Include directory for new thrift file\n");
usage();
}
@@ -1177,7 +1177,7 @@
}
// Tokenize more
- arg = strtok(NULL, " ");
+ arg = strtok(nullptr, " ");
}
}
@@ -1204,12 +1204,12 @@
}
char new_thrift_file_rp[THRIFT_PATH_MAX];
- if (argv[i] == NULL) {
+ if (argv[i] == nullptr) {
fprintf(stderr, "Missing file name of new thrift file for audit\n");
usage();
}
// cppcheck-suppress uninitvar
- if (saferealpath(argv[i], new_thrift_file_rp) == NULL) {
+ if (saferealpath(argv[i], new_thrift_file_rp) == nullptr) {
failure("Could not open input file with realpath: %s", argv[i]);
}
string new_input_file(new_thrift_file_rp);
@@ -1230,12 +1230,12 @@
// Real-pathify it
char rp[THRIFT_PATH_MAX];
- if (argv[i] == NULL) {
+ if (argv[i] == nullptr) {
fprintf(stderr, "Missing file name\n");
usage();
}
// cppcheck-suppress uninitvar
- if (saferealpath(argv[i], rp) == NULL) {
+ if (saferealpath(argv[i], rp) == nullptr) {
failure("Could not open input file with realpath: %s", argv[i]);
}
string input_file(rp);
@@ -1259,7 +1259,7 @@
program->set_include_prefix(include_prefix);
// Parse it!
- parse(program, NULL);
+ parse(program, nullptr);
// The current path is not really relevant when we are doing generation.
// Reset the variable to make warning messages clearer.
diff --git a/compiler/cpp/src/thrift/main.h b/compiler/cpp/src/thrift/main.h
index 163b02e..4615ace 100644
--- a/compiler/cpp/src/thrift/main.h
+++ b/compiler/cpp/src/thrift/main.h
@@ -103,8 +103,8 @@
/**
* Prints deprecation notice for old NS declarations that are no longer supported
- * If new_form is NULL, old_form is assumed to be a language identifier, such as "cpp"
- * If new_form is not NULL, both arguments are used exactly as given
+ * If new_form is nullptr, old_form is assumed to be a language identifier, such as "cpp"
+ * If new_form is not nullptr, both arguments are used exactly as given
*/
void error_unsupported_namespace_decl(const char* old_form, const char* new_form = nullptr);
diff --git a/compiler/cpp/src/thrift/parse/t_program.h b/compiler/cpp/src/thrift/parse/t_program.h
index 5b1b8d0..140dc35 100644
--- a/compiler/cpp/src/thrift/parse/t_program.h
+++ b/compiler/cpp/src/thrift/parse/t_program.h
@@ -291,14 +291,6 @@
pwarning(1, "Namespace 'smalltalk' is deprecated. Use 'st' instead");
base_language = "st";
}
- else if (base_language == "csharp") {
- pwarning(1, "The '%s' target is no longer available. Use 'netstd' instead.", base_language.c_str());
- // warn only, don't change base_language
- }
- else if (base_language == "netcore") {
- pwarning(1, "The '%s' target is no longer available. Use 'netstd' instead.", base_language.c_str());
- // warn only, don't change base_language
- }
t_generator_registry::gen_map_t my_copy = t_generator_registry::get_generator_map();
diff --git a/compiler/cpp/src/thrift/parse/t_typedef.cc b/compiler/cpp/src/thrift/parse/t_typedef.cc
index c808685..48e861e 100644
--- a/compiler/cpp/src/thrift/parse/t_typedef.cc
+++ b/compiler/cpp/src/thrift/parse/t_typedef.cc
@@ -26,9 +26,9 @@
}
const t_type* t_typedef::get_type() const {
- if (type_ == NULL) {
+ if (type_ == nullptr) {
const t_type* type = get_program()->scope()->get_type(symbolic_);
- if (type == NULL) {
+ if (type == nullptr) {
printf("Type \"%s\" not defined\n", symbolic_.c_str());
exit(1);
}
diff --git a/compiler/cpp/src/thrift/thriftl.ll b/compiler/cpp/src/thrift/thriftl.ll
index 5f0ebd9..3773516 100644
--- a/compiler/cpp/src/thrift/thriftl.ll
+++ b/compiler/cpp/src/thrift/thriftl.ll
@@ -159,7 +159,7 @@
g_doctext[strlen(g_doctext) - 1] = '\0';
g_doctext = clean_up_doctext(g_doctext);
g_doctext_lineno = yylineno;
- if( (g_program_doctext_candidate == NULL) && (g_program_doctext_status == INVALID)){
+ if( (g_program_doctext_candidate == nullptr) && (g_program_doctext_status == INVALID)){
g_program_doctext_candidate = strdup(g_doctext);
g_program_doctext_lineno = g_doctext_lineno;
g_program_doctext_status = STILL_CANDIDATE;
@@ -264,7 +264,7 @@
{intconstant} {
errno = 0;
- yylval.iconst = strtoll(yytext, NULL, 10);
+ yylval.iconst = strtoll(yytext, nullptr, 10);
if (errno == ERANGE) {
integer_overflow(yytext);
}
@@ -275,7 +275,7 @@
errno = 0;
char sign = yytext[0];
int shift = sign == '0' ? 2 : 3;
- yylval.iconst = strtoll(yytext+shift, NULL, 16);
+ yylval.iconst = strtoll(yytext+shift, nullptr, 16);
if (sign == '-') {
yylval.iconst = -yylval.iconst;
}
diff --git a/compiler/cpp/src/thrift/thrifty.yy b/compiler/cpp/src/thrift/thrifty.yy
index df34adf..dc6838a 100644
--- a/compiler/cpp/src/thrift/thrifty.yy
+++ b/compiler/cpp/src/thrift/thrifty.yy
@@ -250,7 +250,7 @@
HeaderList DefinitionList
{
pdebug("Program -> Headers DefinitionList");
- if((g_program_doctext_candidate != NULL) && (g_program_doctext_status != ALREADY_PROCESSED))
+ if((g_program_doctext_candidate != nullptr) && (g_program_doctext_status != ALREADY_PROCESSED))
{
g_program->set_doc(g_program_doctext_candidate);
g_program_doctext_status = ALREADY_PROCESSED;
@@ -262,9 +262,9 @@
{
if (g_parse_mode == PROGRAM) {
$$ = g_doctext;
- g_doctext = NULL;
+ g_doctext = nullptr;
} else {
- $$ = NULL;
+ $$ = nullptr;
}
}
@@ -300,7 +300,7 @@
if (g_parse_mode == PROGRAM) {
g_program->set_namespace($2, $3);
}
- if ($4 != NULL) {
+ if ($4 != nullptr) {
g_program->set_namespace_annotations($2, $4->annotations_);
delete $4;
}
@@ -339,7 +339,7 @@
DefinitionList CaptureDocText Definition
{
pdebug("DefinitionList -> DefinitionList Definition");
- if ($2 != NULL && $3 != NULL) {
+ if ($2 != nullptr && $3 != nullptr) {
$3->set_doc($2);
}
}
@@ -362,7 +362,7 @@
pdebug("Definition -> TypeDefinition");
if (g_parse_mode == PROGRAM) {
g_scope->add_type($1->get_name(), $1);
- if (g_parent_scope != NULL) {
+ if (g_parent_scope != nullptr) {
g_parent_scope->add_type(g_parent_prefix + $1->get_name(), $1);
}
if (! g_program->is_unique_typename($1)) {
@@ -377,7 +377,7 @@
pdebug("Definition -> Service");
if (g_parse_mode == PROGRAM) {
g_scope->add_service($1->get_name(), $1);
- if (g_parent_scope != NULL) {
+ if (g_parent_scope != nullptr) {
g_parent_scope->add_service(g_parent_prefix + $1->get_name(), $1);
}
g_program->add_service($1);
@@ -441,7 +441,7 @@
validate_simple_identifier( $3);
t_typedef *td = new t_typedef(g_program, $2, $3);
$$ = td;
- if ($4 != NULL) {
+ if ($4 != nullptr) {
$$->annotations_ = $4->annotations_;
delete $4;
}
@@ -454,7 +454,7 @@
$$ = $4;
validate_simple_identifier( $2);
$$->set_name($2);
- if ($6 != NULL) {
+ if ($6 != nullptr) {
$$->annotations_ = $6->annotations_;
delete $6;
}
@@ -468,7 +468,7 @@
t_const_value* const_val = new t_const_value((*c_iter)->get_value());
const_val->set_enum($$);
g_scope->add_constant(const_name, new t_const(g_type_i32, (*c_iter)->get_name(), const_val));
- if (g_parent_scope != NULL) {
+ if (g_parent_scope != nullptr) {
g_parent_scope->add_constant(g_parent_prefix + const_name, new t_const(g_type_i32, (*c_iter)->get_name(), const_val));
}
}
@@ -494,10 +494,10 @@
{
pdebug("EnumDef -> EnumValue");
$$ = $2;
- if ($1 != NULL) {
+ if ($1 != nullptr) {
$$->set_doc($1);
}
- if ($3 != NULL) {
+ if ($3 != nullptr) {
$$->annotations_ = $3->annotations_;
delete $3;
}
@@ -536,7 +536,7 @@
pdebug("Senum -> tok_senum tok_identifier { SenumDefList }");
validate_simple_identifier( $2);
$$ = new t_typedef(g_program, $4, $2);
- if ($6 != NULL) {
+ if ($6 != nullptr) {
$$->annotations_ = $6->annotations_;
delete $6;
}
@@ -574,11 +574,11 @@
validate_const_type($$);
g_scope->add_constant($3, $$);
- if (g_parent_scope != NULL) {
+ if (g_parent_scope != nullptr) {
g_parent_scope->add_constant(g_parent_prefix + $3, $$);
}
} else {
- $$ = NULL;
+ $$ = nullptr;
}
}
@@ -681,7 +681,7 @@
$5->set_union($1 == struct_is_union);
$$ = $5;
$$->set_name($2);
- if ($7 != NULL) {
+ if ($7 != nullptr) {
$$->annotations_ = $7->annotations_;
delete $7;
}
@@ -724,7 +724,7 @@
}
|
{
- $$ = NULL;
+ $$ = nullptr;
}
Xception:
@@ -735,7 +735,7 @@
$4->set_name($2);
$4->set_xception(true);
$$ = $4;
- if ($6 != NULL) {
+ if ($6 != nullptr) {
$$->annotations_ = $6->annotations_;
delete $6;
}
@@ -749,7 +749,7 @@
$$ = $6;
$$->set_name($2);
$$->set_extends($3);
- if ($9 != NULL) {
+ if ($9 != nullptr) {
$$->annotations_ = $9->annotations_;
delete $9;
}
@@ -769,10 +769,10 @@
tok_extends tok_identifier
{
pdebug("Extends -> tok_extends tok_identifier");
- $$ = NULL;
+ $$ = nullptr;
if (g_parse_mode == PROGRAM) {
$$ = g_scope->get_service($2);
- if ($$ == NULL) {
+ if ($$ == nullptr) {
yyerror("Service \"%s\" has not been defined.", $2);
exit(1);
}
@@ -780,7 +780,7 @@
}
|
{
- $$ = NULL;
+ $$ = nullptr;
}
FunctionList:
@@ -802,10 +802,10 @@
validate_simple_identifier( $4);
$6->set_name(std::string($4) + "_args");
$$ = new t_function($3, $4, $6, $8, $2);
- if ($1 != NULL) {
+ if ($1 != nullptr) {
$$->set_doc($1);
}
- if ($9 != NULL) {
+ if ($9 != nullptr) {
$$->annotations_ = $9->annotations_;
delete $9;
}
@@ -868,20 +868,20 @@
$$ = new t_field($4, $6, $2.value);
$$->set_reference($5);
$$->set_req($3);
- if ($7 != NULL) {
+ if ($7 != nullptr) {
g_scope->resolve_const_value($7, $4);
validate_field_value($$, $7);
$$->set_value($7);
}
$$->set_xsd_optional($8);
$$->set_xsd_nillable($9);
- if ($1 != NULL) {
+ if ($1 != nullptr) {
$$->set_doc($1);
}
- if ($10 != NULL) {
+ if ($10 != nullptr) {
$$->set_xsd_attrs($10);
}
- if ($11 != NULL) {
+ if ($11 != nullptr) {
$$->annotations_ = $11->annotations_;
delete $11;
}
@@ -974,12 +974,12 @@
if (g_parse_mode == PROGRAM) {
$$ = $2;
} else {
- $$ = NULL;
+ $$ = nullptr;
}
}
|
{
- $$ = NULL;
+ $$ = nullptr;
}
FunctionType:
@@ -1000,11 +1000,11 @@
pdebug("FieldType -> tok_identifier");
if (g_parse_mode == INCLUDES) {
// Ignore identifiers in include mode
- $$ = NULL;
+ $$ = nullptr;
} else {
// Lookup the identifier in the current scope
$$ = g_scope->get_type($1);
- if ($$ == NULL) {
+ if ($$ == nullptr) {
/*
* Either this type isn't yet declared, or it's never
declared. Either way allow it and we'll figure it out
@@ -1028,7 +1028,7 @@
BaseType: SimpleBaseType TypeAnnotations
{
pdebug("BaseType -> SimpleBaseType TypeAnnotations");
- if ($2 != NULL) {
+ if ($2 != nullptr) {
$$ = new t_base_type(*static_cast<t_base_type*>($1));
$$->annotations_ = $2->annotations_;
delete $2;
@@ -1088,7 +1088,7 @@
{
pdebug("ContainerType -> SimpleContainerType TypeAnnotations");
$$ = $1;
- if ($2 != NULL) {
+ if ($2 != nullptr) {
$$->annotations_ = $2->annotations_;
delete $2;
}
@@ -1116,7 +1116,7 @@
{
pdebug("MapType -> tok_map <FieldType, FieldType>");
$$ = new t_map($4, $6);
- if ($2 != NULL) {
+ if ($2 != nullptr) {
((t_container*)$$)->set_cpp_name(std::string($2));
}
}
@@ -1126,7 +1126,7 @@
{
pdebug("SetType -> tok_set<FieldType>");
$$ = new t_set($4);
- if ($2 != NULL) {
+ if ($2 != nullptr) {
((t_container*)$$)->set_cpp_name(std::string($2));
}
}
@@ -1137,7 +1137,7 @@
pdebug("ListType -> tok_list<FieldType>");
check_for_list_of_bytes($3);
$$ = new t_list($3);
- if ($5 != NULL) {
+ if ($5 != nullptr) {
((t_container*)$$)->set_cpp_name(std::string($5));
}
}
@@ -1149,7 +1149,7 @@
}
|
{
- $$ = NULL;
+ $$ = nullptr;
}
TypeAnnotations:
@@ -1160,7 +1160,7 @@
}
|
{
- $$ = NULL;
+ $$ = nullptr;
}
TypeAnnotationList:
diff --git a/contrib/async-test/test-server.cpp b/contrib/async-test/test-server.cpp
index b304e1b..9e696c9 100644
--- a/contrib/async-test/test-server.cpp
+++ b/contrib/async-test/test-server.cpp
@@ -28,7 +28,7 @@
public:
AggrAsyncHandler()
- : eb_(NULL)
+ : eb_(nullptr)
, pfact_(new TBinaryProtocolFactory())
{
leaf_ports_.push_back(8081);
diff --git a/contrib/fb303/TClientInfo.cpp b/contrib/fb303/TClientInfo.cpp
index 1fc6612..a4b00cf 100644
--- a/contrib/fb303/TClientInfo.cpp
+++ b/contrib/fb303/TClientInfo.cpp
@@ -34,7 +34,7 @@
eraseAddr();
initTime();
ncalls_ = 0;
- if (addr != NULL) {
+ if (addr != nullptr) {
if (addr->sa_family == AF_INET) {
memcpy((void*)&addr_.ipv4, (const void *)addr, sizeof(sockaddr_in));
}
@@ -55,7 +55,7 @@
case AF_INET6:
return inet_ntop(AF_INET6, &addr_.ipv6.sin6_addr, buf, len);
default:
- return NULL;
+ return nullptr;
}
}
@@ -70,7 +70,7 @@
const char* TClientInfoConnection::getCall() const {
if (call_[0] == '\0') {
- return NULL;
+ return nullptr;
}
return call_;
}
@@ -90,7 +90,7 @@
TClientInfoConnection* TClientInfo::getConnection(int fd, bool grow) {
if (fd < 0 || (!grow && fd >= info_.size())) {
- return NULL;
+ return nullptr;
}
return &info_[fd];
}
@@ -119,7 +119,7 @@
void TClientInfoServerHandler::processContext(void* connectionContext,
shared_ptr<TTransport> transport) {
Connect* call = static_cast<Connect*>(connectionContext);
- if (call->callInfo_ == NULL) {
+ if (call->callInfo_ == nullptr) {
if (typeid(*(transport.get())) == typeid(TSocket)) {
TSocket* tsocket = static_cast<TSocket*>(transport.get());
int fd = tsocket->getSocketFD();
@@ -127,7 +127,7 @@
return;
}
call->callInfo_ = call->clientInfo_->getConnection(fd, true);
- assert(call->callInfo_ != NULL);
+ assert(call->callInfo_ != nullptr);
socklen_t len;
call->callInfo_->recordAddr(tsocket->getCachedAddress(&len));
}
@@ -142,13 +142,13 @@
for (int i = 0; i < clientInfo_.size(); ++i) {
TClientInfoConnection* info = clientInfo_.getConnection(i, false);
const char* callStr = info->getCall();
- if (callStr == NULL) {
+ if (callStr == nullptr) {
continue;
}
char addrBuf[INET6_ADDRSTRLEN];
const char* addrStr = info->getAddr(addrBuf, sizeof addrBuf);
- if (addrStr == NULL) {
+ if (addrStr == nullptr) {
// cerr << "no addr!" << endl;
continue;
}
@@ -168,11 +168,11 @@
void* TClientInfoCallHandler::getContext(const char* fn_name, void* serverContext) {
if (serverContext) {
TClientInfoConnection* callInfo = static_cast<TClientInfoServerHandler::Connect*>(serverContext)->callInfo_;
- if (callInfo != NULL) {
+ if (callInfo != nullptr) {
callInfo->recordCall(fn_name);
}
}
- return NULL;
+ return nullptr;
}
} } } // namespace apache::thrift::server
diff --git a/contrib/fb303/TClientInfo.h b/contrib/fb303/TClientInfo.h
index 6668c19..e3859a7 100644
--- a/contrib/fb303/TClientInfo.h
+++ b/contrib/fb303/TClientInfo.h
@@ -174,7 +174,7 @@
void eraseAddr();
/**
- * Return a string representing the present address, or NULL if none.
+ * Return a string representing the present address, or nullptr if none.
* Copies the string into the buffer provided.
*/
const char* getAddr(char* buf, int len) const;
@@ -193,7 +193,7 @@
/**
* Return as string the thrift call either currently being processed or
* most recently processed if the connection is still open for additional
- * calls. Returns NULL if a call hasn't been made yet or processing
+ * calls. Returns nullptr if a call hasn't been made yet or processing
* has ended.
*/
const char* getCall() const;
@@ -229,7 +229,7 @@
* Return the info object for a given file descriptor. If "grow" is true
* extend the info vector if required (such as for a file descriptor not seen
* before). If "grow" is false and the info vector isn't large enough,
- * or if "fd" is negative, return NULL.
+ * or if "fd" is negative, return nullptr.
*/
TClientInfoConnection* getConnection(int fd, bool grow);
@@ -258,7 +258,7 @@
explicit Connect(TClientInfo* clientInfo)
: clientInfo_(clientInfo)
- , callInfo_(NULL) {
+ , callInfo_(nullptr) {
}
};
diff --git a/contrib/fb303/cpp/FacebookBase.cpp b/contrib/fb303/cpp/FacebookBase.cpp
index 3c56975..eb2e63c 100644
--- a/contrib/fb303/cpp/FacebookBase.cpp
+++ b/contrib/fb303/cpp/FacebookBase.cpp
@@ -24,7 +24,7 @@
FacebookBase::FacebookBase(std::string name) :
name_(name) {
- aliveSince_ = (int64_t) time(NULL);
+ aliveSince_ = (int64_t) time(nullptr);
}
inline void FacebookBase::getName(std::string& _return) {
diff --git a/contrib/fb303/cpp/FacebookBase.h b/contrib/fb303/cpp/FacebookBase.h
index daa5246..e0be4bf 100644
--- a/contrib/fb303/cpp/FacebookBase.h
+++ b/contrib/fb303/cpp/FacebookBase.h
@@ -65,7 +65,7 @@
virtual void reinitialize() {}
virtual void shutdown() {
- if (server_.get() != NULL) {
+ if (server_.get() != nullptr) {
server_->stop();
}
}
diff --git a/contrib/fb303/cpp/ServiceTracker.cpp b/contrib/fb303/cpp/ServiceTracker.cpp
index 7a61b21..a2e670c 100644
--- a/contrib/fb303/cpp/ServiceTracker.cpp
+++ b/contrib/fb303/cpp/ServiceTracker.cpp
@@ -46,7 +46,7 @@
checkpointServices_(0)
{
if (featureCheckpoint_) {
- time_t now = time(NULL);
+ time_t now = time(nullptr);
checkpointTime_ = now;
} else {
checkpointTime_ = 0;
@@ -105,7 +105,7 @@
if (featureThreadCheck_ && !serviceMethod.featureLogOnly_) {
// note: Might want to put these messages in reportCheckpoint() if
// log is getting spammed.
- if (threadManager_ != NULL) {
+ if (threadManager_ != nullptr) {
size_t idle_count = threadManager_->idleWorkerCount();
if (idle_count == 0) {
stringstream message;
@@ -211,7 +211,7 @@
// maybe report checkpoint
// note: ...if it's been long enough since the last report.
- time_t now = time(NULL);
+ time_t now = time(nullptr);
uint64_t check_interval = now - checkpointTime_;
if (check_interval >= CHECKPOINT_MINIMUM_INTERVAL_SECONDS) {
reportCheckpoint();
@@ -239,7 +239,7 @@
void
ServiceTracker::reportCheckpoint()
{
- time_t now = time(NULL);
+ time_t now = time(nullptr);
uint64_t check_count = checkpointServices_;
uint64_t check_interval = now - checkpointTime_;
@@ -282,7 +282,7 @@
<< " checkpoint_speed_sum:" << check_duration
<< " lifetime_time:" << life_interval
<< " lifetime_services:" << life_count;
- if (featureThreadCheck_ && threadManager_ != NULL) {
+ if (featureThreadCheck_ && threadManager_ != nullptr) {
size_t worker_count = threadManager_->workerCount();
size_t idle_count = threadManager_->idleWorkerCount();
message << " total_workers:" << worker_count
@@ -321,7 +321,7 @@
{
if (level <= LOG_LEVEL) {
string level_string;
- time_t now = time(NULL);
+ time_t now = time(nullptr);
char now_pretty[26];
ctime_r(&now, now_pretty);
now_pretty[24] = '\0';
@@ -356,20 +356,20 @@
*/
Stopwatch::Stopwatch()
{
- gettimeofday(&startTime_, NULL);
+ gettimeofday(&startTime_, nullptr);
}
void
Stopwatch::reset()
{
- gettimeofday(&startTime_, NULL);
+ gettimeofday(&startTime_, nullptr);
}
uint64_t
Stopwatch::elapsedUnits(Stopwatch::Unit unit, string *label) const
{
timeval now_time;
- gettimeofday(&now_time, NULL);
+ gettimeofday(&now_time, nullptr);
time_t duration_secs = now_time.tv_sec - startTime_.tv_sec;
uint64_t duration_units;
@@ -377,7 +377,7 @@
case UNIT_SECONDS:
duration_units = duration_secs
+ (now_time.tv_usec - startTime_.tv_usec + 500000) / 1000000;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " secs";
label->assign(ss_label.str());
@@ -386,7 +386,7 @@
case UNIT_MICROSECONDS:
duration_units = duration_secs * 1000000
+ now_time.tv_usec - startTime_.tv_usec;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " us";
label->assign(ss_label.str());
@@ -396,7 +396,7 @@
default:
duration_units = duration_secs * 1000
+ (now_time.tv_usec - startTime_.tv_usec + 500) / 1000;
- if (NULL != label) {
+ if (nullptr != label) {
stringstream ss_label;
ss_label << duration_units << " ms";
label->assign(ss_label.str());
diff --git a/contrib/fb303/cpp/ServiceTracker.h b/contrib/fb303/cpp/ServiceTracker.h
index 9a3edd8..faaa4a7 100644
--- a/contrib/fb303/cpp/ServiceTracker.h
+++ b/contrib/fb303/cpp/ServiceTracker.h
@@ -120,7 +120,7 @@
public:
enum Unit { UNIT_SECONDS, UNIT_MILLISECONDS, UNIT_MICROSECONDS };
Stopwatch();
- uint64_t elapsedUnits(Unit unit, std::string *label = NULL) const;
+ uint64_t elapsedUnits(Unit unit, std::string *label = nullptr) const;
void reset();
private:
timeval startTime_;
diff --git a/contrib/transport-sample/ThriftCommon.cpp b/contrib/transport-sample/ThriftCommon.cpp
index 60ebf7a..2b676a8 100644
--- a/contrib/transport-sample/ThriftCommon.cpp
+++ b/contrib/transport-sample/ThriftCommon.cpp
@@ -23,7 +23,7 @@
(int)boost::shared_dynamic_cast<TPipeServer>(transport)->getClientWrtPipeHandle());
//spawn the child process
- if (!CreateProcessA(NULL, handles, NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
+ if (!CreateProcessA(nullptr, handles, nullptr,nullptr,TRUE,0,nullptr,nullptr,&si,&pi))
{
GlobalOutput.perror("TPipeServer CreateProcess failed, GLE=", GetLastError());
return false;
diff --git a/contrib/zeromq/TZmqServer.cpp b/contrib/zeromq/TZmqServer.cpp
index 88660a3..1ad7db8 100644
--- a/contrib/zeromq/TZmqServer.cpp
+++ b/contrib/zeromq/TZmqServer.cpp
@@ -41,7 +41,7 @@
outputProtocolFactory_->getProtocol(outputTransport));
shared_ptr<TMemoryBuffer> transport(new TMemoryBuffer);
- processor_->process(inputProtocol, outputProtocol, NULL);
+ processor_->process(inputProtocol, outputProtocol, nullptr);
if (zmq_type_ == ZMQ_REP) {
uint8_t* buf;
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
index 0ab3e93..f13c5a3 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
@@ -79,7 +79,7 @@
gint ret = 0;
guint32 want = len;
guint32 got = 0;
- guchar *tmpdata = g_alloca (len);
+ guchar *tmpdata = g_new0 (guchar, len);
guint32 have = t->r_buf->len;
/* we shouldn't hit this unless the buffer doesn't have enough to read */
@@ -102,12 +102,14 @@
tmpdata,
want,
error)) < 0) {
+ g_free (tmpdata);
return ret;
}
got += ret;
/* copy the data starting from where we left off */
memcpy ((guint8 *)buf + have, tmpdata, got);
+ g_free (tmpdata);
return got + have;
} else {
guint32 give;
@@ -116,11 +118,12 @@
tmpdata,
want,
error)) < 0) {
+ g_free (tmpdata);
return ret;
}
got += ret;
t->r_buf = g_byte_array_append (t->r_buf, tmpdata, got);
-
+ g_free (tmpdata);
/* hand over what we have up to what the caller wants */
give = want < t->r_buf->len ? want : t->r_buf->len;
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index 20fbcdb..5732996 100644
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -384,11 +384,11 @@
// create a C client
tsocket = (ThriftSocket *) g_object_new (THRIFT_TYPE_SOCKET,
"hostname", "localhost",
- "port", TEST_PORT, NULL);
+ "port", TEST_PORT, nullptr);
protocol = (ThriftBinaryProtocol *) g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
"transport",
- tsocket, NULL);
- client = (TTestThriftTestClient *) g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT, "input_protocol", protocol, "output_protocol", protocol, NULL);
+ tsocket, nullptr);
+ client = (TTestThriftTestClient *) g_object_new (T_TEST_TYPE_THRIFT_TEST_CLIENT, "input_protocol", protocol, "output_protocol", protocol, nullptr);
iface = T_TEST_THRIFT_TEST_IF (client);
// open and send
diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp
index 800ba07..a30879a 100644
--- a/lib/cpp/src/thrift/TOutput.cpp
+++ b/lib/cpp/src/thrift/TOutput.cpp
@@ -122,8 +122,8 @@
#else // HAVE_STRERROR_R
#ifdef _WIN32
const size_t size = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errno_copy, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- b_errbuf, sizeof(b_errbuf), NULL);
+ nullptr, errno_copy, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ b_errbuf, sizeof(b_errbuf), nullptr);
if (size > 2 && b_errbuf[size-2] == '\r' && b_errbuf[size-1] == '\n') {
b_errbuf[size-2] = '\0';
diff --git a/lib/cpp/src/thrift/VirtualProfiling.cpp b/lib/cpp/src/thrift/VirtualProfiling.cpp
index 6ce346b..4d752cf 100644
--- a/lib/cpp/src/thrift/VirtualProfiling.cpp
+++ b/lib/cpp/src/thrift/VirtualProfiling.cpp
@@ -112,7 +112,7 @@
void* getFrame(int index) const {
int adjusted_index = index + skip_;
if (adjusted_index < 0 || adjusted_index >= numCallers_) {
- return NULL;
+ return nullptr;
}
return callers_[adjusted_index];
}
@@ -151,7 +151,7 @@
};
Key(const Backtrace* bt, const std::type_info& type_info)
- : backtrace_(bt), typeName1_(type_info.name()), typeName2_(NULL) {}
+ : backtrace_(bt), typeName1_(type_info.name()), typeName2_(nullptr) {}
Key(const Backtrace* bt, const std::type_info& type_info1, const std::type_info& type_info2)
: backtrace_(bt), typeName1_(type_info1.name()), typeName2_(type_info2.name()) {}
@@ -189,7 +189,7 @@
*/
void cleanup() {
delete backtrace_;
- backtrace_ = NULL;
+ backtrace_ = nullptr;
}
int cmp(const Key& k) const {
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.cpp b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
index 26ffa68..ea394c8 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.cpp
@@ -1341,7 +1341,7 @@
FD_ZERO(&efds);
FD_SET(fd, &wfds);
FD_SET(fd, &efds);
- ret = select(static_cast<int>(fd + 1), NULL, &wfds, &efds, NULL);
+ ret = select(static_cast<int>(fd + 1), nullptr, &wfds, &efds, nullptr);
if (ret < 0) {
return false;
} else if (ret == 0) {
diff --git a/lib/cpp/src/thrift/server/TNonblockingServer.h b/lib/cpp/src/thrift/server/TNonblockingServer.h
index e44c7ee..65e569d 100644
--- a/lib/cpp/src/thrift/server/TNonblockingServer.h
+++ b/lib/cpp/src/thrift/server/TNonblockingServer.h
@@ -158,7 +158,7 @@
/// The optional user-provided event-base (for single-thread servers)
event_base* userEventBase_;
- /// For processing via thread pool, may be NULL
+ /// For processing via thread pool, may be nullptr
std::shared_ptr<ThreadManager> threadManager_;
/// Is thread pool processing?
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.cpp b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
index 329d220..d8a1b3e 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.cpp
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.cpp
@@ -112,7 +112,7 @@
const uint8_t* TBufferedTransport::borrowSlow(uint8_t* buf, uint32_t* len) {
(void)buf;
(void)len;
- // Simply return NULL. We don't know if there is actually data available on
+ // Simply return nullptr. We don't know if there is actually data available on
// the underlying transport, so calling read() might block.
return nullptr;
}
diff --git a/lib/cpp/src/thrift/transport/TBufferTransports.h b/lib/cpp/src/thrift/transport/TBufferTransports.h
index df06586..86f0c5a 100644
--- a/lib/cpp/src/thrift/transport/TBufferTransports.h
+++ b/lib/cpp/src/thrift/transport/TBufferTransports.h
@@ -137,7 +137,7 @@
/**
* Slow path borrow.
*
- * POSTCONDITION: return == NULL || rBound_ - rBase_ >= *len
+ * POSTCONDITION: return == nullptr || rBound_ - rBase_ >= *len
*/
virtual const uint8_t* borrowSlow(uint8_t* buf, uint32_t* len) = 0;
@@ -245,7 +245,7 @@
/**
* The following behavior is currently implemented by TBufferedTransport,
* but that may change in a future version:
- * 1/ If len is at most rBufSize_, borrow will never return NULL.
+ * 1/ If len is at most rBufSize_, borrow will never return nullptr.
* Depending on the underlying transport, it could throw an exception
* or hang forever.
* 2/ Some borrow requests may copy bytes internally. However,
diff --git a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
index f811328..e8997d7 100644
--- a/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TNonblockingServerTransport.h
@@ -49,7 +49,7 @@
* Gets a new dynamically allocated transport object and passes it to the
* caller. Note that it is the explicit duty of the caller to free the
* allocated object. The returned TTransport object must always be in the
- * opened state. NULL should never be returned, instead an Exception should
+ * opened state. nullptr should never be returned, instead an Exception should
* always be thrown.
*
* @return A new TTransport object
@@ -58,7 +58,7 @@
std::shared_ptr<TSocket> accept() {
std::shared_ptr<TSocket> result = acceptImpl();
if (!result) {
- throw TTransportException("accept() may not return NULL");
+ throw TTransportException("accept() may not return nullptr");
}
return result;
}
diff --git a/lib/cpp/src/thrift/transport/TPipe.cpp b/lib/cpp/src/thrift/transport/TPipe.cpp
index 72af4fc..4c2fea9 100644
--- a/lib/cpp/src/thrift/transport/TPipe.cpp
+++ b/lib/cpp/src/thrift/transport/TPipe.cpp
@@ -183,7 +183,7 @@
uint32_t written = 0;
while (written < len) {
- BOOL result = ::WriteFile(pipe, buf + written, len - written, NULL, &tempOverlap);
+ BOOL result = ::WriteFile(pipe, buf + written, len - written, nullptr, &tempOverlap);
if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
GlobalOutput.perror("TPipe ::WriteFile errored GLE=", ::GetLastError());
@@ -205,7 +205,7 @@
memset(&tempOverlap, 0, sizeof(tempOverlap));
tempOverlap.hEvent = event;
- BOOL result = ::ReadFile(pipe, buf, len, NULL, &tempOverlap);
+ BOOL result = ::ReadFile(pipe, buf, len, nullptr, &tempOverlap);
if (result == FALSE && ::GetLastError() != ERROR_IO_PENDING) {
GlobalOutput.perror("TPipe ::ReadFile errored GLE=", ::GetLastError());
@@ -255,7 +255,7 @@
// Transport callbacks
//---------------------------------------------------------
bool TPipe::isOpen() const {
- return impl_.get() != NULL;
+ return impl_.get() != nullptr;
}
bool TPipe::peek() {
@@ -272,10 +272,10 @@
hPipe.reset(CreateFileA(pipename_.c_str(),
GENERIC_READ | GENERIC_WRITE,
0, // no sharing
- NULL, // default security attributes
+ nullptr, // default security attributes
OPEN_EXISTING, // opens existing pipe
flags,
- NULL)); // no template file
+ nullptr)); // no template file
if (hPipe.h != INVALID_HANDLE_VALUE)
break; // success!
@@ -310,7 +310,7 @@
buf, // buffer to receive reply
len, // size of buffer
&cbRead, // number of bytes read
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
return 0; // No more data, possibly because client disconnected.
@@ -330,7 +330,7 @@
buf, // message
len, // message length
&cbWritten, // bytes written
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess)
throw TTransportException(TTransportException::NOT_OPEN, "Write to pipe failed");
diff --git a/lib/cpp/src/thrift/transport/TPipeServer.cpp b/lib/cpp/src/thrift/transport/TPipeServer.cpp
index e1cee80..2763551 100644
--- a/lib/cpp/src/thrift/transport/TPipeServer.cpp
+++ b/lib/cpp/src/thrift/transport/TPipeServer.cpp
@@ -50,7 +50,7 @@
virtual HANDLE getWrtPipeHandle() = 0;
virtual HANDLE getClientRdPipeHandle() = 0;
virtual HANDLE getClientWrtPipeHandle() = 0;
- virtual HANDLE getNativeWaitHandle() { return NULL; }
+ virtual HANDLE getNativeWaitHandle() { return nullptr; }
};
class TAnonPipeServer : public TPipeServerImpl {
@@ -155,7 +155,7 @@
HANDLE TPipeServer::getNativeWaitHandle() {
if (impl_)
return impl_->getNativeWaitHandle();
- return NULL;
+ return nullptr;
}
//---- Constructors ----
@@ -227,7 +227,7 @@
&buf, // buffer to receive reply
0, // size of buffer
&br, // number of bytes read
- NULL); // not overlapped
+ nullptr); // not overlapped
if (!fSuccess && GetLastError() != ERROR_MORE_DATA) {
GlobalOutput.perror("TPipeServer unable to initiate pipe comms, GLE=", GetLastError());
@@ -248,7 +248,7 @@
// The prior connection has been handled, so close the gate
ResetEvent(listen_event_.h);
- connectOverlap_.reset(NULL, 0, listen_event_.h);
+ connectOverlap_.reset(nullptr, 0, listen_event_.h);
connectOverlap_.h = Pipe_.h;
thread_->addWorkItem(&connectOverlap_);
@@ -283,7 +283,7 @@
shared_ptr<TTransport> TNamedPipeServer::acceptImpl() {
{
TAutoCrit lock(pipe_protect_);
- if (cached_client_.get() != NULL) {
+ if (cached_client_.get() != nullptr) {
shared_ptr<TPipe> client;
// zero out cached_client, since we are about to return it.
client.swap(cached_client_);
@@ -350,7 +350,7 @@
bool TNamedPipeServer::createNamedPipe(const TAutoCrit& /*lockProof*/) {
- PSECURITY_DESCRIPTOR psd = NULL;
+ PSECURITY_DESCRIPTOR psd = nullptr;
ULONG size = 0;
if (!ConvertStringSecurityDescriptorToSecurityDescriptorA(securityDescriptor_.c_str(),
@@ -404,7 +404,7 @@
GetLastError());
return false;
}
- if (!SetSecurityDescriptorDacl(&sd, true, NULL, false)) {
+ if (!SetSecurityDescriptorDacl(&sd, true, nullptr, false)) {
GlobalOutput.perror("TPipeServer SetSecurityDescriptorDacl (anon) failed, GLE=",
GetLastError());
return false;
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index 64f08dd..aa76980 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -562,7 +562,7 @@
throw TSSLException("BIO_flush: Handshake is not completed");
BIO* bio = SSL_get_wbio(ssl_);
if (bio == nullptr) {
- throw TSSLException("SSL_get_wbio returns NULL");
+ throw TSSLException("SSL_get_wbio returns nullptr");
}
if (BIO_flush(bio) != 1) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -798,7 +798,7 @@
}
if (bio == nullptr) {
- throw TSSLException("SSL_get_?bio returned NULL");
+ throw TSSLException("SSL_get_?bio returned nullptr");
}
if (BIO_get_fd(bio, &fdSocket) <= 0) {
@@ -943,7 +943,7 @@
void TSSLSocketFactory::loadCertificate(const char* path, const char* format) {
if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadCertificateChain: either <path> or <format> is NULL");
+ "loadCertificateChain: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
if (SSL_CTX_use_certificate_chain_file(ctx_->get(), path) == 0) {
@@ -960,12 +960,12 @@
void TSSLSocketFactory::loadCertificateFromBuffer(const char* aCertificate, const char* format) {
if (aCertificate == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadCertificate: either <path> or <format> is NULL");
+ "loadCertificate: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
BIO* mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aCertificate);
- X509* cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ X509* cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (SSL_CTX_use_certificate(ctx_->get(), cert) == 0) {
@@ -982,7 +982,7 @@
void TSSLSocketFactory::loadPrivateKey(const char* path, const char* format) {
if (path == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadPrivateKey: either <path> or <format> is NULL");
+ "loadPrivateKey: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
if (SSL_CTX_use_PrivateKey_file(ctx_->get(), path, SSL_FILETYPE_PEM) == 0) {
@@ -997,7 +997,7 @@
void TSSLSocketFactory::loadPrivateKeyFromBuffer(const char* aPrivateKey, const char* format) {
if (aPrivateKey == nullptr || format == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadPrivateKey: either <path> or <format> is NULL");
+ "loadPrivateKey: either <path> or <format> is nullptr");
}
if (strcmp(format, "PEM") == 0) {
BIO* mem = BIO_new(BIO_s_mem());
@@ -1019,7 +1019,7 @@
void TSSLSocketFactory::loadTrustedCertificates(const char* path, const char* capath) {
if (path == nullptr) {
throw TTransportException(TTransportException::BAD_ARGS,
- "loadTrustedCertificates: <path> is NULL");
+ "loadTrustedCertificates: <path> is nullptr");
}
if (SSL_CTX_load_verify_locations(ctx_->get(), path, capath) == 0) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
@@ -1037,7 +1037,7 @@
X509_STORE* vX509Store = SSL_CTX_get_cert_store(ctx_->get());
BIO* mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aCertificate);
- X509* cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ X509* cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (X509_STORE_add_cert(vX509Store, cert) == 0) {
@@ -1050,7 +1050,7 @@
if (aChain) {
mem = BIO_new(BIO_s_mem());
BIO_puts(mem, aChain);
- cert = PEM_read_bio_X509(mem, NULL, 0, NULL);
+ cert = PEM_read_bio_X509(mem, nullptr, 0, nullptr);
BIO_free(mem);
if (SSL_CTX_add_extra_chain_cert(ctx_->get(), cert) == 0) {
diff --git a/lib/cpp/src/thrift/transport/TServerTransport.h b/lib/cpp/src/thrift/transport/TServerTransport.h
index 9e84850..0c56609 100644
--- a/lib/cpp/src/thrift/transport/TServerTransport.h
+++ b/lib/cpp/src/thrift/transport/TServerTransport.h
@@ -54,7 +54,7 @@
* Gets a new dynamically allocated transport object and passes it to the
* caller. Note that it is the explicit duty of the caller to free the
* allocated object. The returned TTransport object must always be in the
- * opened state. NULL should never be returned, instead an Exception should
+ * opened state. nullptr should never be returned, instead an Exception should
* always be thrown.
*
* @return A new TTransport object
@@ -63,7 +63,7 @@
std::shared_ptr<TTransport> accept() {
std::shared_ptr<TTransport> result = acceptImpl();
if (!result) {
- throw TTransportException("accept() may not return NULL");
+ throw TTransportException("accept() may not return nullptr");
}
return result;
}
diff --git a/lib/cpp/src/thrift/transport/TSocket.cpp b/lib/cpp/src/thrift/transport/TSocket.cpp
index 3811279..a1a6dfb 100644
--- a/lib/cpp/src/thrift/transport/TSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSocket.cpp
@@ -432,7 +432,7 @@
void TSocket::unix_open() {
if (!path_.empty()) {
- // Unix Domain SOcket does not need addrinfo struct, so we pass NULL
+ // Unix Domain SOcket does not need addrinfo struct, so we pass nullptr
openConnection(nullptr);
}
}
diff --git a/lib/cpp/src/thrift/transport/TTransport.h b/lib/cpp/src/thrift/transport/TTransport.h
index 891bfe1..6397882 100644
--- a/lib/cpp/src/thrift/transport/TTransport.h
+++ b/lib/cpp/src/thrift/transport/TTransport.h
@@ -191,7 +191,7 @@
* @oaram buf A buffer where the data can be stored if needed.
* If borrow doesn't return buf, then the contents of
* buf after the call are undefined. This parameter may be
- * NULL to indicate that the caller is not supplying storage,
+ * nullptr to indicate that the caller is not supplying storage,
* but would like a pointer into an internal buffer, if
* available.
* @param len *len should initially contain the number of bytes to borrow.
diff --git a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
index 0a0292c..ac24124 100644
--- a/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
+++ b/lib/cpp/src/thrift/windows/GetTimeOfDay.cpp
@@ -51,7 +51,7 @@
int thrift_gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// We don't fill it in so prove nobody is looking for the data
- assert(tzp == NULL);
+ assert(tzp == nullptr);
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
diff --git a/lib/cpp/src/thrift/windows/SocketPair.cpp b/lib/cpp/src/thrift/windows/SocketPair.cpp
index 7228832..2650b37 100644
--- a/lib/cpp/src/thrift/windows/SocketPair.cpp
+++ b/lib/cpp/src/thrift/windows/SocketPair.cpp
@@ -77,12 +77,12 @@
break;
if (listen(listener, 1) == SOCKET_ERROR)
break;
- sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, NULL, 0, flags);
+ sv[0] = WSASocket(AF_INET, SOCK_STREAM, 0, nullptr, 0, flags);
if (sv[0] == INVALID_SOCKET)
break;
if (connect(sv[0], &a.addr, sizeof(a.inaddr)) == SOCKET_ERROR)
break;
- sv[1] = accept(listener, NULL, NULL);
+ sv[1] = accept(listener, nullptr, nullptr);
if (sv[1] == INVALID_SOCKET)
break;
diff --git a/lib/cpp/src/thrift/windows/Sync.h b/lib/cpp/src/thrift/windows/Sync.h
index 5d32199..a296d7e 100644
--- a/lib/cpp/src/thrift/windows/Sync.h
+++ b/lib/cpp/src/thrift/windows/Sync.h
@@ -55,8 +55,8 @@
HANDLE h;
TAutoResetEvent() {
- h = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (h == NULL) {
+ h = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ if (h == nullptr) {
GlobalOutput.perror("TAutoResetEvent unable to create event, GLE=", GetLastError());
throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
}
@@ -68,8 +68,8 @@
HANDLE h;
TManualResetEvent() {
- h = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (h == NULL) {
+ h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+ if (h == nullptr) {
GlobalOutput.perror("TManualResetEvent unable to create event, GLE=", GetLastError());
throw apache::thrift::concurrency::SystemResourceException("CreateEvent failed");
}
diff --git a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
index a502cbd..c3339f3 100644
--- a/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
+++ b/lib/cpp/src/thrift/windows/TWinsockSingleton.cpp
@@ -26,7 +26,7 @@
namespace thrift {
namespace transport {
-TWinsockSingleton::instance_ptr TWinsockSingleton::instance_ptr_(NULL);
+TWinsockSingleton::instance_ptr TWinsockSingleton::instance_ptr_(nullptr);
std::once_flag TWinsockSingleton::flags_;
//------------------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/WinFcntl.cpp b/lib/cpp/src/thrift/windows/WinFcntl.cpp
index c907e92..292ddfc 100644
--- a/lib/cpp/src/thrift/windows/WinFcntl.cpp
+++ b/lib/cpp/src/thrift/windows/WinFcntl.cpp
@@ -45,8 +45,8 @@
#if WINVER <= 0x0502 // XP, Server2003
int thrift_poll(THRIFT_POLLFD* fdArray, ULONG nfds, INT timeout) {
fd_set read_fds, write_fds;
- fd_set* read_fds_ptr = NULL;
- fd_set* write_fds_ptr = NULL;
+ fd_set* read_fds_ptr = nullptr;
+ fd_set* write_fds_ptr = nullptr;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
@@ -65,7 +65,7 @@
}
timeval time_out;
- timeval* time_out_ptr = NULL;
+ timeval* time_out_ptr = nullptr;
if (timeout >= 0) {
time_out.tv_sec = timeout / 1000;
time_out.tv_usec = (timeout % 1000) * 1000;
@@ -75,7 +75,7 @@
(void)timeout;
}
- int sktready = select(1, read_fds_ptr, write_fds_ptr, NULL, time_out_ptr);
+ int sktready = select(1, read_fds_ptr, write_fds_ptr, nullptr, time_out_ptr);
if (sktready > 0) {
for (ULONG i = 0; i < nfds; i++) {
fdArray[i].revents = 0;
diff --git a/lib/cpp/test/OpenSSLManualInitTest.cpp b/lib/cpp/test/OpenSSLManualInitTest.cpp
index a751806..935a205 100644
--- a/lib/cpp/test/OpenSSLManualInitTest.cpp
+++ b/lib/cpp/test/OpenSSLManualInitTest.cpp
@@ -88,6 +88,6 @@
suite->add(BOOST_TEST_CASE(test_openssl_availability));
- return NULL;
+ return nullptr;
}
#endif
\ No newline at end of file
diff --git a/lib/cpp/test/TFileTransportTest.cpp b/lib/cpp/test/TFileTransportTest.cpp
index 21c1f3b..c116fdc 100644
--- a/lib/cpp/test/TFileTransportTest.cpp
+++ b/lib/cpp/test/TFileTransportTest.cpp
@@ -399,6 +399,6 @@
// Parse arguments
parse_args(argc, argv);
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/TransportTest.cpp b/lib/cpp/test/TransportTest.cpp
index a890aa8..085197a 100644
--- a/lib/cpp/test/TransportTest.cpp
+++ b/lib/cpp/test/TransportTest.cpp
@@ -230,7 +230,7 @@
HANDLE hWrite;
CoupledPipeTransports() {
- BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, NULL, 1048576 * 2));
+ BOOST_REQUIRE(CreatePipe(&hRead, &hWrite, nullptr, 1048576 * 2));
in.reset(new TPipe(hRead, hWrite));
in->open();
out = in;
@@ -707,7 +707,7 @@
uint8_t read_buf[16];
memset(write_buf, 'a', sizeof(write_buf));
- // Attemping to borrow 10 bytes when only 9 are available should return NULL
+ // Attemping to borrow 10 bytes when only 9 are available should return nullptr
// immediately.
transports.out->write(write_buf, 9);
transports.out->flush();
@@ -1075,7 +1075,7 @@
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
struct timeval tv;
- THRIFT_GETTIMEOFDAY(&tv, NULL);
+ THRIFT_GETTIMEOFDAY(&tv, nullptr);
int seed = tv.tv_sec ^ tv.tv_usec;
initrand(seed);
@@ -1084,6 +1084,6 @@
suite->p_name.value = "TransportTest";
TransportTestGen transport_test_generator(suite, 1);
transport_test_generator.generate();
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/ZlibTest.cpp b/lib/cpp/test/ZlibTest.cpp
index 3e2eb81..274a243 100644
--- a/lib/cpp/test/ZlibTest.cpp
+++ b/lib/cpp/test/ZlibTest.cpp
@@ -454,7 +454,7 @@
boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) {
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
- uint32_t seed = static_cast<uint32_t>(time(NULL));
+ uint32_t seed = static_cast<uint32_t>(time(nullptr));
#ifdef HAVE_INTTYPES_H
printf("seed: %" PRIu32 "\n", seed);
#endif
@@ -470,6 +470,6 @@
suite->add(BOOST_TEST_CASE(test_no_write));
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/cpp/test/processor/ProcessorTest.cpp b/lib/cpp/test/processor/ProcessorTest.cpp
index a36ef3e..017fa89 100644
--- a/lib/cpp/test/processor/ProcessorTest.cpp
+++ b/lib/cpp/test/processor/ProcessorTest.cpp
@@ -924,6 +924,6 @@
THRIFT_UNUSED_VARIABLE(argc);
THRIFT_UNUSED_VARIABLE(argv);
::boost::unit_test::framework::master_test_suite().p_name.value = "ProcessorTest";
- return NULL;
+ return nullptr;
}
#endif
diff --git a/lib/netstd/Thrift/Thrift.csproj b/lib/netstd/Thrift/Thrift.csproj
index b63a12a..3278d98 100644
--- a/lib/netstd/Thrift/Thrift.csproj
+++ b/lib/netstd/Thrift/Thrift.csproj
@@ -56,4 +56,9 @@
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>
+ <Target Name="SetTFMAssemblyAttributesPath" BeforeTargets="GenerateTargetFrameworkMonikerAttribute">
+ <PropertyGroup>
+ <TargetFrameworkMonikerAssemblyAttributesPath>$(IntermediateOutputPath)$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)</TargetFrameworkMonikerAssemblyAttributesPath>
+ </PropertyGroup>
+ </Target>
</Project>
diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
index e152d08..c8bc50e 100644
--- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
+++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
@@ -414,7 +414,7 @@
object_and_properties_init(return_value, ce, nullptr);
zend_function* constructor = zend_std_get_constructor(Z_OBJ_P(return_value));
zval ctor_rv;
- zend_call_method(return_value, ce, &constructor, NULL, 0, &ctor_rv, nargs, arg1, arg2);
+ zend_call_method(return_value, ce, &constructor, nullptr, 0, &ctor_rv, nargs, arg1, arg2);
zval_dtor(&ctor_rv);
if (EG(exception)) {
zend_object *ex = EG(exception);
diff --git a/lib/py/src/ext/module.cpp b/lib/py/src/ext/module.cpp
index 7158b8f..f14ddae 100644
--- a/lib/py/src/ext/module.cpp
+++ b/lib/py/src/ext/module.cpp
@@ -48,20 +48,20 @@
template <typename T>
static PyObject* encode_impl(PyObject* args) {
if (!args)
- return NULL;
+ return nullptr;
- PyObject* enc_obj = NULL;
- PyObject* type_args = NULL;
+ PyObject* enc_obj = nullptr;
+ PyObject* type_args = nullptr;
if (!PyArg_ParseTuple(args, "OO", &enc_obj, &type_args)) {
- return NULL;
+ return nullptr;
}
if (!enc_obj || !type_args) {
- return NULL;
+ return nullptr;
}
T protocol;
if (!protocol.prepareEncodeBuffer() || !protocol.encodeValue(enc_obj, T_STRUCT, type_args)) {
- return NULL;
+ return nullptr;
}
return protocol.getEncodedValue();
@@ -79,11 +79,11 @@
template <typename T>
static PyObject* decode_impl(PyObject* args) {
- PyObject* output_obj = NULL;
- PyObject* oprot = NULL;
- PyObject* typeargs = NULL;
+ PyObject* output_obj = nullptr;
+ PyObject* oprot = nullptr;
+ PyObject* typeargs = nullptr;
if (!PyArg_ParseTuple(args, "OOO", &output_obj, &oprot, &typeargs)) {
- return NULL;
+ return nullptr;
}
T protocol;
@@ -96,16 +96,16 @@
default_limit));
ScopedPyObject transport(PyObject_GetAttr(oprot, INTERN_STRING(trans)));
if (!transport) {
- return NULL;
+ return nullptr;
}
StructTypeArgs parsedargs;
if (!parse_struct_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
if (!protocol.prepareDecodeBufferFromTransport(transport.get())) {
- return NULL;
+ return nullptr;
}
return protocol.readStruct(output_obj, parsedargs.klass, parsedargs.spec);
@@ -141,22 +141,22 @@
{"decode_binary", decode_binary, METH_VARARGS, ""},
{"encode_compact", encode_compact, METH_VARARGS, ""},
{"decode_compact", decode_compact, METH_VARARGS, ""},
- {NULL, NULL, 0, NULL} /* Sentinel */
+ {nullptr, nullptr, 0, nullptr} /* Sentinel */
};
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef ThriftFastBinaryDef = {PyModuleDef_HEAD_INIT,
"thrift.protocol.fastbinary",
- NULL,
+ nullptr,
0,
ThriftFastBinaryMethods,
- NULL,
- NULL,
- NULL,
- NULL};
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr};
-#define INITERROR return NULL;
+#define INITERROR return nullptr;
PyObject* PyInit_fastbinary() {
@@ -167,7 +167,7 @@
void initfastbinary() {
PycString_IMPORT;
- if (PycStringIO == NULL)
+ if (PycStringIO == nullptr)
INITERROR
#endif
@@ -193,7 +193,7 @@
#else
Py_InitModule("thrift.protocol.fastbinary", ThriftFastBinaryMethods);
#endif
- if (module == NULL)
+ if (module == nullptr)
INITERROR;
#if PY_MAJOR_VERSION >= 3
diff --git a/lib/py/src/ext/protocol.h b/lib/py/src/ext/protocol.h
index 521b7ee..c0cd437 100644
--- a/lib/py/src/ext/protocol.h
+++ b/lib/py/src/ext/protocol.h
@@ -35,7 +35,7 @@
ProtocolBase()
: stringLimit_((std::numeric_limits<int32_t>::max)()),
containerLimit_((std::numeric_limits<int32_t>::max)()),
- output_(NULL) {}
+ output_(nullptr) {}
inline virtual ~ProtocolBase();
bool prepareDecodeBufferFromTransport(PyObject* trans);
diff --git a/lib/py/src/ext/protocol.tcc b/lib/py/src/ext/protocol.tcc
index ede2bb4..03cfc9b 100644
--- a/lib/py/src/ext/protocol.tcc
+++ b/lib/py/src/ext/protocol.tcc
@@ -48,7 +48,7 @@
PycString_IMPORT;
}
if (!PycStringIO) {
- return NULL;
+ return nullptr;
}
return PycStringIO->NewOutput(size);
}
@@ -83,7 +83,7 @@
PycString_IMPORT;
}
if (!PycStringIO) {
- return NULL;
+ return nullptr;
}
return PycStringIO->cgetvalue(output_);
}
@@ -277,7 +277,7 @@
} else {
// using building functions as this is a rare codepath
ScopedPyObject newiobuf(PyObject_CallFunction(input_.refill_callable.get(), refill_signature,
- *output, rlen, len, NULL));
+ *output, rlen, len, nullptr));
if (!newiobuf) {
return false;
}
@@ -332,7 +332,7 @@
template <typename Impl>
bool ProtocolBase<Impl>::prepareEncodeBuffer() {
output_ = detail::new_encode_buffer(INIT_OUTBUF_SIZE);
- return output_ != NULL;
+ return output_ != nullptr;
}
template <typename Impl>
@@ -484,8 +484,8 @@
return false;
}
Py_ssize_t pos = 0;
- PyObject* k = NULL;
- PyObject* v = NULL;
+ PyObject* k = nullptr;
+ PyObject* v = nullptr;
// TODO(bmaurer): should support any mapping, not just dicts
while (PyDict_Next(value, &pos, &k, &v)) {
if (!encodeValue(k, parsedargs.ktag, parsedargs.ktypeargs)
@@ -647,7 +647,7 @@
case T_BOOL: {
bool v = 0;
if (!impl()->readBool(v)) {
- return NULL;
+ return nullptr;
}
if (v) {
Py_RETURN_TRUE;
@@ -658,21 +658,21 @@
case T_I08: {
int8_t v = 0;
if (!impl()->readI8(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
case T_I16: {
int16_t v = 0;
if (!impl()->readI16(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
case T_I32: {
int32_t v = 0;
if (!impl()->readI32(v)) {
- return NULL;
+ return nullptr;
}
return PyInt_FromLong(v);
}
@@ -680,7 +680,7 @@
case T_I64: {
int64_t v = 0;
if (!impl()->readI64(v)) {
- return NULL;
+ return nullptr;
}
// TODO(dreiss): Find out if we can take this fastpath always when
// sizeof(long) == sizeof(long long).
@@ -693,16 +693,16 @@
case T_DOUBLE: {
double v = 0.0;
if (!impl()->readDouble(v)) {
- return NULL;
+ return nullptr;
}
return PyFloat_FromDouble(v);
}
case T_STRING: {
- char* buf = NULL;
+ char* buf = nullptr;
int len = impl()->readString(&buf);
if (len < 0) {
- return NULL;
+ return nullptr;
}
if (isUtf8(typeargs)) {
return PyUnicode_DecodeUTF8(buf, len, 0);
@@ -715,28 +715,28 @@
case T_SET: {
SetListTypeArgs parsedargs;
if (!parse_set_list_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
TType etype = T_STOP;
int32_t len = impl()->readListBegin(etype);
if (len < 0) {
- return NULL;
+ return nullptr;
}
if (len > 0 && !checkType(etype, parsedargs.element_type)) {
- return NULL;
+ return nullptr;
}
bool use_tuple = type == T_LIST && parsedargs.immutable;
ScopedPyObject ret(use_tuple ? PyTuple_New(len) : PyList_New(len));
if (!ret) {
- return NULL;
+ return nullptr;
}
for (int i = 0; i < len; i++) {
PyObject* item = decodeValue(etype, parsedargs.typeargs);
if (!item) {
- return NULL;
+ return nullptr;
}
if (use_tuple) {
PyTuple_SET_ITEM(ret.get(), i, item);
@@ -758,32 +758,32 @@
case T_MAP: {
MapTypeArgs parsedargs;
if (!parse_map_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
TType ktype = T_STOP;
TType vtype = T_STOP;
uint32_t len = impl()->readMapBegin(ktype, vtype);
if (len > 0 && (!checkType(ktype, parsedargs.ktag) || !checkType(vtype, parsedargs.vtag))) {
- return NULL;
+ return nullptr;
}
ScopedPyObject ret(PyDict_New());
if (!ret) {
- return NULL;
+ return nullptr;
}
for (uint32_t i = 0; i < len; i++) {
ScopedPyObject k(decodeValue(ktype, parsedargs.ktypeargs));
if (!k) {
- return NULL;
+ return nullptr;
}
ScopedPyObject v(decodeValue(vtype, parsedargs.vtypeargs));
if (!v) {
- return NULL;
+ return nullptr;
}
if (PyDict_SetItem(ret.get(), k.get(), v.get()) == -1) {
- return NULL;
+ return nullptr;
}
}
@@ -792,12 +792,12 @@
ThriftModule = PyImport_ImportModule("thrift.Thrift");
}
if (!ThriftModule) {
- return NULL;
+ return nullptr;
}
ScopedPyObject cls(PyObject_GetAttr(ThriftModule, INTERN_STRING(TFrozenDict)));
if (!cls) {
- return NULL;
+ return nullptr;
}
ScopedPyObject arg(PyTuple_New(1));
@@ -811,7 +811,7 @@
case T_STRUCT: {
StructTypeArgs parsedargs;
if (!parse_struct_args(&parsedargs, typeargs)) {
- return NULL;
+ return nullptr;
}
return readStruct(Py_None, parsedargs.klass, parsedargs.spec);
}
@@ -823,7 +823,7 @@
case T_U64:
default:
PyErr_Format(PyExc_TypeError, "Unexpected TType for decodeValue: %d", type);
- return NULL;
+ return nullptr;
}
}
@@ -833,26 +833,26 @@
bool immutable = output == Py_None;
ScopedPyObject kwargs;
if (spec_seq_len == -1) {
- return NULL;
+ return nullptr;
}
if (immutable) {
kwargs.reset(PyDict_New());
if (!kwargs) {
PyErr_SetString(PyExc_TypeError, "failed to prepare kwargument storage");
- return NULL;
+ return nullptr;
}
}
detail::ReadStructScope<Impl> scope = detail::readStructScope(this);
if (!scope) {
- return NULL;
+ return nullptr;
}
while (true) {
TType type = T_STOP;
int16_t tag;
if (!impl()->readFieldBegin(type, tag)) {
- return NULL;
+ return nullptr;
}
if (type == T_STOP) {
break;
@@ -860,7 +860,7 @@
if (tag < 0 || tag >= spec_seq_len) {
if (!skip(type)) {
PyErr_SetString(PyExc_TypeError, "Error while skipping unknown field");
- return NULL;
+ return nullptr;
}
continue;
}
@@ -869,38 +869,38 @@
if (item_spec == Py_None) {
if (!skip(type)) {
PyErr_SetString(PyExc_TypeError, "Error while skipping unknown field");
- return NULL;
+ return nullptr;
}
continue;
}
StructItemSpec parsedspec;
if (!parse_struct_item_spec(&parsedspec, item_spec)) {
- return NULL;
+ return nullptr;
}
if (parsedspec.type != type) {
if (!skip(type)) {
PyErr_Format(PyExc_TypeError, "struct field had wrong type: expected %d but got %d",
parsedspec.type, type);
- return NULL;
+ return nullptr;
}
continue;
}
ScopedPyObject fieldval(decodeValue(parsedspec.type, parsedspec.typeargs));
if (!fieldval) {
- return NULL;
+ return nullptr;
}
if ((immutable && PyDict_SetItem(kwargs.get(), parsedspec.attrname, fieldval.get()) == -1)
|| (!immutable && PyObject_SetAttr(output, parsedspec.attrname, fieldval.get()) == -1)) {
- return NULL;
+ return nullptr;
}
}
if (immutable) {
ScopedPyObject args(PyTuple_New(0));
if (!args) {
PyErr_SetString(PyExc_TypeError, "failed to prepare argument storage");
- return NULL;
+ return nullptr;
}
return PyObject_Call(klass, args.get(), kwargs.get());
}
diff --git a/lib/py/src/ext/types.cpp b/lib/py/src/ext/types.cpp
index 68443fb..e8d6939 100644
--- a/lib/py/src/ext/types.cpp
+++ b/lib/py/src/ext/types.cpp
@@ -24,7 +24,7 @@
namespace thrift {
namespace py {
-PyObject* ThriftModule = NULL;
+PyObject* ThriftModule = nullptr;
#if PY_MAJOR_VERSION < 3
char refill_signature[] = {'s', '#', 'i'};
diff --git a/lib/py/src/ext/types.h b/lib/py/src/ext/types.h
index 5cd8dda..9b45dd0 100644
--- a/lib/py/src/ext/types.h
+++ b/lib/py/src/ext/types.h
@@ -83,7 +83,7 @@
// replace with unique_ptr when we're OK with C++11
class ScopedPyObject {
public:
- ScopedPyObject() : obj_(NULL) {}
+ ScopedPyObject() : obj_(nullptr) {}
explicit ScopedPyObject(PyObject* py_object) : obj_(py_object) {}
~ScopedPyObject() {
if (obj_)
@@ -98,7 +98,7 @@
}
PyObject* release() throw() {
PyObject* tmp = obj_;
- obj_ = NULL;
+ obj_ = nullptr;
return tmp;
}
void swap(ScopedPyObject& other) throw() {