Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
c4milo committed Mar 7, 2012
1 parent 74617a7 commit 5cdc5a6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
### Under design and development
### Under design and development. IT IS NOT USABLE YET.
3 changes: 0 additions & 3 deletions spec/fuse.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ describe('fuse_common.h', function() {

it('fuse_mount');
it('fuse_unmount');
it('fuse_daemonize');
it('fuse_set_signal_handlers');
it('fuse_remove_signal_handlers');
});

describe('fuse_lowlevel.h', function() {
Expand Down
58 changes: 54 additions & 4 deletions src/bindings.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Copyright 2012, Camilo Aguilar. Cloudescape, LLC.
#include "bindings.h"
namespace NodeFuse {
void Fuse::Initialize(Handle<Object> target) {
Persistent<FunctionTemplate> Fuse::constructor_template;

static Persistent<String> mountpoint_sym;
static Persistent<String> operations_sym;
static Persistent<String> options_sym;

void Fuse::Initialize(Handle<Object> target) {
Local<FunctionTemplate> t = FunctionTemplate::New(Fuse::New);

t->InstanceTemplate()->SetInternalFieldCount(1);
Expand All @@ -11,8 +17,14 @@ namespace NodeFuse {
NODE_SET_PROTOTYPE_METHOD(t, "umount",
Fuse::Umount);

t->SetClassName(String::NewSymbol("Fuse"));
target->Set(String::NewSymbol("Fuse"), t->GetFunction());
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->SetClassName(String::NewSymbol("Fuse"));

target->Set(String::NewSymbol("Fuse"), constructor_template->GetFunction());

mountpoint_sym = NODE_PSYMBOL("mountpoint");
operations_sym = NODE_PSYMBOL("operations");
options_sym = NODE_PSYMBOL("options");
}

Fuse::Fuse() : ObjectWrap() {}
Expand All @@ -30,7 +42,45 @@ namespace NodeFuse {

Handle<Value> Fuse::Mount(const Arguments& args) {
HandleScope scope;
//handles parameters and mounts the filesystem
struct fuse_chan* channel = NULL;
struct fuse_session* session = NULL;
struct fuse_args* fargs = NULL;

struct fuse_args fuse_args = FUSE_ARGS_INIT(0, NULL);

char* mountpoint = NULL;
char* options = NULL;
char* operations = NULL;

if (args.Length() == 0) {
return ThrowException(Exception::TypeError(
String::New("You must specify arguments to invoke this function")));
}

if (!args[0]->IsObject()) {
return ThrowException(Exception::TypeError(
String::New("You must specify an object as first argument")));
}

Local<Object> args_ = args[0]->ToObject();
THROW_IF_MISSING_PROPERTY(args_, mountpoint_sym, "mountpoint");
THROW_IF_MISSING_PROPERTY(args_, operations_sym, "operations");
THROW_IF_MISSING_PROPERTY(args_, options_sym, "options");

/*THROW_IF_UNEXPECTED_TYPE("mountpoint", mountpoint_sym, "isString");
THROW_IF_UNEXPECTED_TYPE("operations", args_->Get(operations_sym), "Object");
THROW_IF_UNEXPECTED_TYPE("options", args_->Get(options_sym), "Array");*/

//Local<Value>
//parse options
/*if (fuse_parse_cmdline(fargs, NULL, NULL, NULL) != 0) {
}*/

//channel = fuse_mount(mountpoint, &fargs);
//session = fuse_lowlevel_new(&fargs, &fuse_ops, sizeof(fuse_ops), NULL)
//fuse_set_signal_handlers(session)
//fuse_session_loop()

}

Handle<Value> Fuse::Umount(const Arguments& args) {
Expand Down
1 change: 1 addition & 0 deletions src/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace NodeFuse {
static Handle<Value> Umount(const Arguments& args);

private:
static Persistent<FunctionTemplate> constructor_template;
};
}//namespace NodeFuse

Expand Down
12 changes: 12 additions & 0 deletions src/node_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
using namespace v8;
using namespace node;

#define THROW_IF_MISSING_PROPERTY(obj, symbol, name) \
if (!obj->Has(symbol)) { \
return v8::ThrowException(v8::Exception::TypeError( \
v8::String::New("You must have set the property " #name " in the object")));\
} \

#define THROW_IF_UNEXPECTED_TYPE(symbol, value, expected_type) \
if (!value->expected_type()) { \
return v8::ThrowException(v8::Exception::TypeError( \
v8::String::New("Wrong type for " #symbol ", expected " #expected_type))); \
} \

namespace NodeFuse {

}
Expand Down

0 comments on commit 5cdc5a6

Please sign in to comment.