Browse Source

initial skeleton, right now it is just an empty c++ node shell

cpp-prototype
Brett Langdon 14 years ago
parent
commit
160cef4b32
9 changed files with 187 additions and 1 deletions
  1. +5
    -1
      .gitignore
  2. +1
    -0
      lib/index.js
  3. +19
    -0
      package.json
  4. +39
    -0
      src/consumer.cc
  5. +20
    -0
      src/consumer.h
  6. +29
    -0
      src/franz.cc
  7. +39
    -0
      src/producer.cc
  8. +20
    -0
      src/producer.h
  9. +15
    -0
      wscript

+ 5
- 1
.gitignore View File

@ -15,4 +15,8 @@ node_modules
npm-debug.log
*#*#
*~
*~
build*
*.lock-wscript

+ 1
- 0
lib/index.js View File

@ -0,0 +1 @@
module.exports = require('../build/Release/franz');

+ 19
- 0
package.json View File

@ -0,0 +1,19 @@
{
"name": "franz"
, "version": "0.0.1"
, "description": "Network based distributed tasks"
, "homepage": ""
, "keywords": ["queue", "kafka", "franz"]
, "author": "brett_langdon <brett@blangdon.com>"
, "contributors": [
{ "name": "brett_langdon", "email": "brett@blangdon.com" }
]
, "repository":{
"type": "git"
, "url": "github.com/brettlangdon/franz.git"
}
, "dependencies": {
}
, "main": "./lib/index.js"
, "engines": { "node": ">= 0.6.0" }
}

+ 39
- 0
src/consumer.cc View File

@ -0,0 +1,39 @@
#define BUILDING_NODE_EXTENSION
#include <node.h>
#include "consumer.h"
using namespace v8;
Consumer::Consumer() {};
Consumer::~Consumer() {};
Persistent<Function> Consumer::constructor;
void Consumer::Init() {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("Consumer"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
constructor = Persistent<Function>::New(tpl->GetFunction());
}
Handle<Value> Consumer::New(const Arguments& args) {
HandleScope scope;
Consumer* obj = new Consumer();
obj->Wrap(args.This());
return args.This();
}
Handle<Value> Consumer::NewInstance(const Arguments& args) {
HandleScope scope;
const unsigned argc = 0;
Handle<Value> argv[argc] = {};
Local<Object> instance = constructor->NewInstance(argc, argv);
return scope.Close(instance);
}

+ 20
- 0
src/consumer.h View File

@ -0,0 +1,20 @@
#define BUILDING_NODE_EXTENSION
#ifndef CONSUMER_H
#define CONSUMER_H
#include <node.h>
class Consumer : public node::ObjectWrap {
public:
static void Init();
static v8::Handle<v8::Value> NewInstance(const v8::Arguments& args);
private:
Consumer();
~Consumer();
static v8::Persistent<v8::Function> constructor;
static v8::Handle<v8::Value> New(const v8::Arguments& args);
};
#endif

+ 29
- 0
src/franz.cc View File

@ -0,0 +1,29 @@
#define BUILDING_NODE_EXTENSION
#include <node.h>
#include "producer.h"
#include "consumer.h"
using namespace v8;
Handle<Value> CreateProducer(const Arguments& args) {
HandleScope scope;
return scope.Close(Producer::NewInstance(args));
}
Handle<Value> CreateConsumer(const Arguments& args) {
HandleScope scope;
return scope.Close(Consumer::NewInstance(args));
}
void InitAll(Handle<Object> target) {
Producer::Init();
Consumer::Init();
target->Set(String::NewSymbol("createProducer"),
FunctionTemplate::New(CreateProducer)->GetFunction());
target->Set(String::NewSymbol("createConsumer"),
FunctionTemplate::New(CreateConsumer)->GetFunction());
}
NODE_MODULE(franz, InitAll)

+ 39
- 0
src/producer.cc View File

@ -0,0 +1,39 @@
#define BUILDING_NODE_EXTENSION
#include <node.h>
#include "producer.h"
using namespace v8;
Producer::Producer() {};
Producer::~Producer() {};
Persistent<Function> Producer::constructor;
void Producer::Init() {
// Prepare constructor template
Local<FunctionTemplate> tpl = FunctionTemplate::New(New);
tpl->SetClassName(String::NewSymbol("Producer"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
constructor = Persistent<Function>::New(tpl->GetFunction());
}
Handle<Value> Producer::New(const Arguments& args) {
HandleScope scope;
Producer* obj = new Producer();
obj->Wrap(args.This());
return args.This();
}
Handle<Value> Producer::NewInstance(const Arguments& args) {
HandleScope scope;
const unsigned argc = 0;
Handle<Value> argv[argc] = {};
Local<Object> instance = constructor->NewInstance(argc, argv);
return scope.Close(instance);
}

+ 20
- 0
src/producer.h View File

@ -0,0 +1,20 @@
#define BUILDING_NODE_EXTENSION
#ifndef PRODUCER_H
#define PRODUCER_H
#include <node.h>
class Producer : public node::ObjectWrap {
public:
static void Init();
static v8::Handle<v8::Value> NewInstance(const v8::Arguments& args);
private:
Producer();
~Producer();
static v8::Persistent<v8::Function> constructor;
static v8::Handle<v8::Value> New(const v8::Arguments& args);
};
#endif

+ 15
- 0
wscript View File

@ -0,0 +1,15 @@
srcdir = '.'
blddir = 'build'
VERSION = '0.0.1'
def set_options(opt):
opt.tool_options('compiler_cxx')
def configure(conf):
conf.check_tool('compiler_cxx')
conf.check_tool('node_addon')
def build(bld):
obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
obj.target = 'franz'
obj.source = ['src/consumer.cc','src/producer.cc','src/franz.cc']

Loading…
Cancel
Save