Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

Commit

Permalink
Fixed constants and fs, and finally got rid of Io.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Nov 1, 2011
1 parent 4d65559 commit 96820f7
Show file tree
Hide file tree
Showing 14 changed files with 978 additions and 320 deletions.
6 changes: 0 additions & 6 deletions node.gyp
Expand Up @@ -22,9 +22,6 @@
'src/modules/sys.js',
'src/modules/url.js',
'src/modules/util.js',

#FIXME
'src/modules/Io.gear',
],
'gear_output': [
'src/modules/assert.cc',
Expand All @@ -40,9 +37,6 @@
'src/modules/sys.cc',
'src/modules/url.cc',
'src/modules/util.cc',

#FIXME
'src/modules/Io.cc',
],
},

Expand Down
22 changes: 0 additions & 22 deletions src/Context.cc
Expand Up @@ -22,7 +22,6 @@
#include <gearbox.h>

#include <cstdlib>
#include <iostream>

namespace Gearbox {
Context *Context::m_pCurrentContext = 0;
Expand All @@ -32,26 +31,6 @@ namespace Gearbox {
return undefined;
}

static v8::Handle<v8::Value> _load(const v8::Arguments& args) {
if(args.Length() >= 1) {
Value file(args[0]);

TryCatch tryCatch;
String source = NativeModule::require("Io")["read"](file);

// Report exceptions caught while reading the file
if(tryCatch.hasCaught())
return undefined;

Context *pCurrentContext = Context::getCurrent();
if(!pCurrentContext)
THROW_ERROR("No Context is in use");

return pCurrentContext->runScript(source, file);
}
THROW_ERROR("Invalid call to load");
}

static v8::Handle<v8::Value> _print(const v8::Arguments& args) {
if(args.Length()) {
for(int i = 0; i < args.Length(); i++)
Expand Down Expand Up @@ -118,7 +97,6 @@ namespace Gearbox {
var _global = global();

_global["exit"] = Function(_exit, "exit");
_global["load"] = Function(_load, "load");
_global["print"] = Function(_print, "print");
_global["require"] = NativeModule::getRequireFunc();

Expand Down
11 changes: 3 additions & 8 deletions src/main.cc
Expand Up @@ -23,8 +23,6 @@

using namespace Gearbox;

#include <iostream>

int main(int argc, char *argv[]) {
v8::HandleScope handleScope;

Expand All @@ -43,14 +41,11 @@ int main(int argc, char *argv[]) {
for(int i = 1; i < argc; i++) {
String arg = argv[i];

// Warn about unknown flags
if(arg.compare("--", 2))
std::cerr << "Warning: unknown flag " << *arg << "." << std::endl << "Try --help for options" << std::endl;
// Treat the first argument that is not an option as a file to execute
else {
// Ignore unknown flags
if(!arg.compare("-", 2)) {

// Read the file
String source = NativeModule::require("Io")["read"](arg);
String source = NativeModule::require("fs")["readFileSync"](arg);

// Report exceptions caught while reading the file
if(tryCatch.hasCaught())
Expand Down
79 changes: 0 additions & 79 deletions src/modules/Io.cc

This file was deleted.

61 changes: 0 additions & 61 deletions src/modules/Io.gear

This file was deleted.

0 comments on commit 96820f7

Please sign in to comment.