Permalink
Browse files

wordament->wordfs

  • Loading branch information...
1 parent b5d76f4 commit f4e09ba4cf351b9ac44befb859982ab40a094da8 @boopathi boopathi committed Dec 6, 2012
Showing with 6 additions and 83 deletions.
  1. +3 −64 src/{wordament.cpp → wordfs.cpp}
  2. +3 −19 src/{wordament.h → wordfs.h}
@@ -31,7 +31,7 @@
*
*/
-#include "./wordament.h"
+#include "./wordfs.h"
#include <string>
#include <vector>
#include <algorithm>
@@ -211,71 +211,11 @@ Handle<Value> Game::lookup(const Arguments& args) {
return False();
}
-/*
- * Implementing a Functor
-Handle<Value> Game::search(Game* g) {
- struct SEARCH {
- SEARCH(const Arguments& args):args(args) {}
- int operator()(const Arguments& args) { return args; }
- private:
- const Arguments& args;
- };
-}
-*/
Handle<Value> Game::search(const Arguments& args){
return True();
}
-//Finally the node part
-
-/*
-Old code - Working but only one instance of game is possible
-void Wordament::Init(Handle<Object> target) {
- HandleScope scope;
- //Set all handlers accessible by JavaScript
- //NODE_SET_METHOD(target, "getMatrix", Wordament::getMatrix);
- //NODE_SET_METHOD(target, "search", Wordament::search);
- //NODE_SET_METHOD(target, "solution", Wordament::solution);
- NODE_SET_METHOD(target, "create", Wordament::create);
-}
-
-Handle<Value> Wordament::create(const Arguments& args) {
- HandleScope scope;
- Game* g = new Game();
-
- Local<Object> game = Object::New();
- game->Set(String::NewSymbol("matrix"), g->matrix() );
- game->Set(String::NewSymbol("solution"), g->solution() );
-
- //Local<FunctionTemplate> stpl = FunctionTemplate::New(Game::search);
- //Local<Function> search = stpl->GetFunction();
- //search->SetName(String::NewSymbol("search"));
-
- //game->Set(String::NewSymbol("search"), search);
-
- //Local<Function> matrix = FunctionTemplate::New(g->matrix)->GetFunction();
- //matrix->SetName(String::NewSymbol("matrix"));
- //game->Set(String::NewSymbol("matrix"), FunctionTemplate::New(g->matrix)->GetFunction());
- //game->Set(String::NewSymbol("search"), FunctionTemplate::New(g->search)->GetFunction());
- return scope.Close(game);
-}
-
-Handle<Value> Wordament::solution(const Arguments& args) {
- HandleScope scope;
- int l = Solution.size();
- Local<Array> found = Array::New(l);
- FOR(i,l) found->Set(i, String::New(Solution[i].c_str()));
- return scope.Close(found);
-}
-
-Handle<Value> Wordament::getMatrix(const Arguments& args) {
- HandleScope scope;
- return scope.Close(String::New( (M->get()).c_str() ));
-}
-
-*/
-
W::W() { g = new Game(); }
W::~W() { delete g; }
@@ -290,7 +230,7 @@ void W::Initialize(Handle<Object> target) {
SetPrototypeMethod(t, "search", Search);
- target->Set(String::NewSymbol("Wordament"), t->GetFunction());
+ target->Set(String::NewSymbol("Wordfs"), t->GetFunction());
}
Handle<Value> W::New(const Arguments& args) {
@@ -313,8 +253,7 @@ Handle<Value> W::Search(const Arguments& args) {
extern "C" {
//just a wrapper - don't worry about a thing
void init(Handle<Object> target) {
- //Wordament::Init(target);
W::Initialize(target);
}
- NODE_MODULE(wordament, init);
+ NODE_MODULE(wordfs, init);
}
@@ -31,8 +31,8 @@
*
*/
-#ifndef WORDAMENT_H //NOLINT
-#define WORDAMENT_H "rm -rf /"
+#ifndef WORDFS_H //NOLINT
+#define WORDFS_H "rm -rf /"
#include <v8.h>
#include <node.h>
@@ -43,22 +43,6 @@ using namespace v8;
using namespace node;
using namespace std;
-//Node stuff
-/*
-class Wordament:ObjectWrap {
-private:
-public:
- Wordament();
- ~Wordament();
- static void Init(Handle<Object>);
- static Handle<Value> create(const Arguments& args);
- //static Handle<Value> search(Wordament *word, const Arguments& args);
- //static Handle<Value> getMatrix(const Arguments& args);
- //static Handle<Value> solution(const Arguments& args);
-
-};
-*/
-
//Trie
class Node {
@@ -130,4 +114,4 @@ class W: ObjectWrap {
};
-#endif //NOLINT
+#endif //NOLINT

0 comments on commit f4e09ba

Please sign in to comment.