Permalink
Browse files

Demonstrate NODE_DEFINE_CONSTANT

  • Loading branch information...
1 parent 69ecf13 commit 77d0e9397110958f160f94425359da46956f93d4 @nikhilm committed Jan 18, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 primitives/primitives.cc
View
10 primitives/primitives.cc
@@ -1,15 +1,17 @@
+#include <math.h>
#include <v8.h>
#include <node.h>
#include <node_version.h>
using namespace v8;
extern "C" {
static void Init(Handle<Object> target) {
- target->Set(String::New("answer"),
- Integer::New(42));
+ target->Set(String::NewSymbol("pi"),
+ Number::New(M_PI));
- target->Set(String::New("node_version"),
- String::New(NODE_VERSION_STRING));
+ NODE_DEFINE_CONSTANT(target, NODE_MINOR_VERSION);
+
+ target->Set(String::New("name"), String::New("Nikhil"));
}
NODE_MODULE(primitives, Init)
}

0 comments on commit 77d0e93

Please sign in to comment.