Reviewers: Søren Gjesse,
Description:
Add os.unsetenv to d8.
Please review this at http://codereview.chromium.org/1602023/show
SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
Affected files:
M src/d8-posix.cc
M src/d8.h
Index: src/d8.h
===================================================================
--- src/d8.h (revision 4385)
+++ src/d8.h (working copy)
@@ -175,6 +175,7 @@
static Handle<Value> System(const Arguments& args);
static Handle<Value> ChangeDirectory(const Arguments& args);
static Handle<Value> SetEnvironment(const Arguments& args);
+ static Handle<Value> UnsetEnvironment(const Arguments& args);
static Handle<Value> SetUMask(const Arguments& args);
static Handle<Value> MakeDirectory(const Arguments& args);
static Handle<Value> RemoveDirectory(const Arguments& args);
Index: src/d8-posix.cc
===================================================================
--- src/d8-posix.cc (revision 4385)
+++ src/d8-posix.cc (working copy)
@@ -663,10 +663,27 @@
}
+Handle<Value> Shell::UnsetEnvironment(const Arguments& args) {
+ if (args.Length() != 1) {
+ const char* message = "unsetenv() takes one argument";
+ return ThrowException(String::New(message));
+ }
+ String::Utf8Value var(args[0]);
+ if (*var == NULL) {
+ const char* message =
+ "os.setenv(): String conversion of variable name failed.";
+ return ThrowException(String::New(message));
+ }
+ unsetenv(*var);
+ return v8::Undefined();
+}
+
+
void Shell::AddOSMethods(Handle<ObjectTemplate> os_templ) {
os_templ->Set(String::New("system"), FunctionTemplate::New(System));
os_templ->Set(String::New("chdir"),
FunctionTemplate::New(ChangeDirectory));
os_templ->Set(String::New("setenv"),
FunctionTemplate::New(SetEnvironment));
+ os_templ->Set(String::New("unsetenv"),
FunctionTemplate::New(UnsetEnvironment));
os_templ->Set(String::New("umask"), FunctionTemplate::New(SetUMask));
os_templ->Set(String::New("mkdirp"),
FunctionTemplate::New(MakeDirectory));
os_templ->Set(String::New("rmdir"),
FunctionTemplate::New(RemoveDirectory));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
To unsubscribe, reply using "remove me" as the subject.