Repository: thrift
Updated Branches:
  refs/heads/master 359036acc -> af26af6d2


THRIFT-2387 nodejs: external imports should be centralized in index.js
Patch: Pierre Lamot


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/af26af6d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/af26af6d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/af26af6d

Branch: refs/heads/master
Commit: af26af6d25d480acea179a6d4831f3ea78351912
Parents: 359036a
Author: henrique <[email protected]>
Authored: Thu Mar 6 15:06:22 2014 +0100
Committer: henrique <[email protected]>
Committed: Thu Mar 6 15:06:22 2014 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_js_generator.cc | 14 +++++++-------
 lib/nodejs/lib/thrift/index.js              | 11 ++++++-----
 2 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/af26af6d/compiler/cpp/src/generate/t_js_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_js_generator.cc 
b/compiler/cpp/src/generate/t_js_generator.cc
index 7d99ab2..06f3562 100644
--- a/compiler/cpp/src/generate/t_js_generator.cc
+++ b/compiler/cpp/src/generate/t_js_generator.cc
@@ -302,31 +302,31 @@ void t_js_generator::init_generator() {
  */
 string t_js_generator::js_includes() {
   if (gen_node_) {
-    return string("var Thrift = require('thrift').Thrift;\nvar Q = 
require('q');");
+    return string("var thrift = require('thrift');\n"
+      "var Thrift = thrift.Thrift;\n"
+      "var Q = thrift.Q;\n");
   }
-  string inc;
 
-  return inc;
+  return "";
 }
 
 /**
  * Renders all the imports necessary for including another Thrift program
  */
 string t_js_generator::render_includes() {
+  string result = "";
+
   if (gen_node_) {
     const vector<t_program*>& includes = program_->get_includes();
-    string result = "";
     for (size_t i = 0; i < includes.size(); ++i) {
       result += "var " + includes[i]->get_name() + "_ttypes = require('./" + 
includes[i]->get_name() + "_types')\n";
     }
     if (includes.size() > 0) {
       result += "\n";
     }
-    return result;
   }
-  string inc;
 
-  return inc;
+  return result;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/thrift/blob/af26af6d/lib/nodejs/lib/thrift/index.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/lib/thrift/index.js b/lib/nodejs/lib/thrift/index.js
index 9846d3d..8499f9a 100644
--- a/lib/nodejs/lib/thrift/index.js
+++ b/lib/nodejs/lib/thrift/index.js
@@ -26,7 +26,7 @@ exports.createSSLConnection = connection.createSSLConnection;
 exports.createStdIOClient = connection.createStdIOClient;
 exports.createStdIOConnection = connection.createStdIOConnection;
 
-var server = require('./server')
+var server = require('./server');
 exports.createServer = server.createServer;
 exports.createSSLServer = server.createSSLServer;
 exports.createHttpServer = server.createHttpServer;
@@ -35,15 +35,16 @@ exports.httpMiddleware = server.httpMiddleware;
 exports.createMultiplexServer = server.createMultiplexServer;
 exports.createMultiplexSSLServer = server.createMultiplexSSLServer;
 
-var static_server = require('./static_server')
+var static_server = require('./static_server');
 exports.createStaticHttpThriftServer = 
static_server.createStaticHttpThriftServer;
 
-exports.Int64 = require('node-int64')
+exports.Int64 = require('node-int64');
+exports.Q = require('q');
 
 var mprocessor = require('./multiplexed_processor');
 var mprotocol = require('./multiplexed_protocol');
-exports.Multiplexer = mprotocol.Multiplexer
-exports.MultiplexedProcessor = mprocessor.MultiplexedProcessor
+exports.Multiplexer = mprotocol.Multiplexer;
+exports.MultiplexedProcessor = mprocessor.MultiplexedProcessor;
 
 /*
  * Export transport and protocol so they can be used outside of a

Reply via email to