File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ void HashTable::init(Handle<Object> exports) {
1919 prototype->Set (" reserve" , FunctionTemplate::New (Reserve)->GetFunction ());
2020 prototype->Set (" max_load_factor" , FunctionTemplate::New (MaxLoadFactor)->GetFunction ());
2121
22+ // prototype->SetNamedPropertyHandler(GetNamedProperty, SetNamedProperty);
23+
2224 exports->Set (String::NewSymbol (" HashTable" ), Persistent<Function>::New (constructor->GetFunction ()));
2325}
2426
@@ -43,6 +45,22 @@ Handle<Value> HashTable::Constructor(const Arguments& args) {
4345 return args.This ();
4446}
4547
48+ /*
49+ Handle<Value> HashTable::GetNamedProperty(Local<String> key, const AccessorInfo &info) {
50+ HandleScope scope;
51+ String::AsciiValue keyStr(key);
52+ std::cout << "GetNamedProperty() " << *keyStr << std::endl;
53+ return scope.Close(Local<Value>());
54+ }
55+
56+ Handle<Value> HashTable::SetNamedProperty(Local<String> key, Local<Value> value, const AccessorInfo &info) {
57+ HandleScope scope;
58+ String::AsciiValue keyStr(key);
59+ std::cout << "SetNamedProperty() " << *keyStr << std::endl;
60+ return scope.Close(Local<Value>());
61+ }
62+ */
63+
4664Handle<Value> HashTable::Get (const Arguments& args) {
4765 HandleScope scope;
4866
Original file line number Diff line number Diff line change @@ -16,9 +16,16 @@ class HashTable : public node::ObjectWrap {
1616 typedef std::unordered_map<std::string,v8::Persistent<v8::Value>> MapType;
1717 MapType map;
1818
19+
1920 // new HashTable() or new HashTable(buckets)
2021 static v8::Handle<v8::Value> Constructor (const v8::Arguments &args);
2122
23+ // hashTable[key] : value
24+ static v8::Handle<v8::Value> GetNamedProperty (v8::Local<v8::String> key, const v8::AccessorInfo &info);
25+
26+ // hashTable[key] = value
27+ static v8::Handle<v8::Value> SetNamedProperty (v8::Local<v8::String> key, v8::Local<v8::Value> value, const v8::AccessorInfo &info);
28+
2229 // hashTable.get(key) : value
2330 static v8::Handle<v8::Value> Get (const v8::Arguments &args);
2431
You can’t perform that action at this time.
0 commit comments