RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
soa/service/js/s3_js.cc
00001 #include "v8.h"
00002 #include "soa/service/s3.h"
00003 #include "soa/js/js_wrapped.h"
00004 #include "soa/js/js_utils.h"
00005 #include "soa/js/js_call.h"
00006 #include "soa/js/js_registry.h"
00007 #include "soa/js/js_value.h"
00008 #include "soa/js/js_wrapped.h"
00009 
00010 using namespace v8;
00011 using namespace std;
00012 using namespace node;
00013 
00014 namespace Datacratic{
00015 namespace JS{
00016 
00017 
00018 extern const char * const S3ApiModule;
00019 const char * const S3ApiModule = "s3";
00020 const char * S3ApiName = "S3Api";
00021 
00022 struct S3ApiJS : public JSWrapped2<S3Api, S3ApiJS, S3ApiName, S3ApiModule>{
00023     S3ApiJS(v8::Handle<v8::Object> This, 
00024         const std::shared_ptr<S3Api>& store = std::shared_ptr<S3Api>())
00025     {
00026         HandleScope scope;
00027         wrap(This, store);
00028     }
00029 
00030     static Handle<v8::Value> New(const Arguments & args){
00031         try{
00032             S3Api* storePtr;
00033             if(args.Length() == 0){
00034                 storePtr = new S3Api();
00035             }else if(args.Length() == 2){
00036                 storePtr = new S3Api(getArg<string>(args, 0, ""), getArg<string>(args, 1, ""));
00037             }else{
00038                 cerr << "Undefined S3Api constructor" << endl;
00039                 throw ML::Exception("undefined S3Api constructor");
00040             }
00041             new S3ApiJS(args.This(), ML::make_std_sp(storePtr));
00042             return args.This();
00043         } HANDLE_JS_EXCEPTIONS;
00044     }
00045 
00046     static void Initialize(){
00047         Persistent<FunctionTemplate> t = Register(New);
00048         registerMemberFn(&S3Api::downloadToFile, "downloadToFile");
00049         registerMemberFn(&S3Api::setDefaultBandwidthToServiceMbps, "setDefaultBandwidthToServiceMbps");
00050     }
00051 
00052 };
00053 extern "C" void
00054 init(Handle<v8::Object> target){
00055     Datacratic::JS::registry.init(target, S3ApiModule);
00056 }
00057     
00058 }//namespace JS
00059 }//namespace Datacratic
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator