Created
May 16, 2014 18:56
-
-
Save BobGneu/27ba3717d2442fac3d87 to your computer and use it in GitHub Desktop.
Example of object encapsulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Flathead::DefineLoggingFunctions(Local<ObjectTemplate> globalTemplate) | |
{ | |
HandleScope scope(GetIsolate()); | |
Handle<Context> context = Context::New(GetIsolate()); | |
Context::Scope ContextScope(context); | |
Local<FunctionTemplate> log_tmp = FunctionTemplate::New(GetIsolate()); | |
log_tmp->PrototypeTemplate()->Set(String::NewFromUtf8(GetIsolate(), "log", String::kInternalizedString), FunctionTemplate::New(GetIsolate(), Flathead::LogCallback)); | |
log_tmp->PrototypeTemplate()->Set(String::NewFromUtf8(GetIsolate(), "display", String::kInternalizedString), FunctionTemplate::New(GetIsolate(), Flathead::DisplayCallback)); | |
log_tmp->PrototypeTemplate()->Set(String::NewFromUtf8(GetIsolate(), "warning", String::kInternalizedString), FunctionTemplate::New(GetIsolate(), Flathead::WarningCallback)); | |
log_tmp->PrototypeTemplate()->Set(String::NewFromUtf8(GetIsolate(), "error", String::kInternalizedString), FunctionTemplate::New(GetIsolate(), Flathead::ErrorCallback)); | |
log_tmp->PrototypeTemplate()->Set(String::NewFromUtf8(GetIsolate(), "fatal", String::kInternalizedString), FunctionTemplate::New(GetIsolate(), Flathead::FatalCallback)); | |
globalTemplate->Set(String::NewFromUtf8(GetIsolate(), "game"), log_tmp->GetFunction()->NewInstance(), ReadOnly); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment