本文整理汇总了C++中Handle::Inherit方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::Inherit方法的具体用法?C++ Handle::Inherit怎么用?C++ Handle::Inherit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::Inherit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bind_Transforms
bool bind_Transforms(Handle<Object> parent)
{
ScriptingManager* pManager = ScriptingManager::getSingletonPtr();
Handle<FunctionTemplate> transforms = pManager->getClassTemplate("Athena.Entities.Transforms");
if (transforms.IsEmpty())
{
assert(!pManager->getClassTemplate("Athena.Entities.Component").IsEmpty());
// Declaration of the class
transforms = FunctionTemplate::New(Transforms_New);
transforms->InstanceTemplate()->SetInternalFieldCount(1);
transforms->Inherit(pManager->getClassTemplate("Athena.Entities.Component"));
// Attributes
AddAttribute(transforms, "position", Transforms_GetPosition, Transforms_SetPosition);
AddAttribute(transforms, "worldPosition", Transforms_GetWorldPosition, 0);
AddAttribute(transforms, "orientation", Transforms_GetOrientation, Transforms_SetOrientation);
AddAttribute(transforms, "worldOrientation", Transforms_GetWorldOrientation, 0);
AddAttribute(transforms, "inheritOrientation", Transforms_GetInheritOrientation, Transforms_SetInheritOrientation);
AddAttribute(transforms, "scale", Transforms_GetScale, Transforms_SetScale);
AddAttribute(transforms, "worldScale", Transforms_GetWorldScale, 0);
AddAttribute(transforms, "inheritScale", Transforms_GetInheritScale, Transforms_SetInheritScale);
// Methods
AddMethod(transforms, "translate", Transforms_Translate);
AddMethod(transforms, "setDirection", Transforms_SetDirection);
AddMethod(transforms, "lookAt", Transforms_LookAt);
AddMethod(transforms, "roll", Transforms_Roll);
AddMethod(transforms, "pitch", Transforms_Pitch);
AddMethod(transforms, "yaw", Transforms_Yaw);
AddMethod(transforms, "rotate", Transforms_Rotate);
AddMethod(transforms, "resetOrientation", Transforms_ResetOrientation);
AddMethod(transforms, "rescale", Transforms_Rescale);
pManager->declareClassTemplate("Athena.Entities.Transforms", transforms);
parent->Set(String::New("Transforms_TYPE"), String::New(Athena::Entities::Transforms::TYPE.c_str()));
parent->Set(String::New("TS_LOCAL"), Uint32::New(Transforms::TS_LOCAL));
parent->Set(String::New("TS_PARENT"), Uint32::New(Transforms::TS_PARENT));
parent->Set(String::New("TS_WORLD"), Uint32::New(Transforms::TS_WORLD));
}
// Add the class to the parent
return parent->Set(String::New("Transforms"), transforms->GetFunction());
}
示例2: GetOrCreateInternal
Handle<FunctionTemplate> MetadataNode::GetConstructorFunctionTemplate(Isolate *isolate, MetadataTreeNode *treeNode)
{
SET_PROFILER_FRAME();
Handle<FunctionTemplate> ctorFuncTemplate;
auto itFound = s_ctorFuncCache.find(treeNode);
if (itFound != s_ctorFuncCache.end())
{
ctorFuncTemplate = Local<FunctionTemplate>::New(isolate, *itFound->second);
return ctorFuncTemplate;
}
auto node = GetOrCreateInternal(treeNode);
auto ctorCallbackData = External::New(isolate, node);
auto isInterface = s_metadataReader.IsNodeTypeInterface(treeNode->type);
auto funcCallback = isInterface ? InterfaceConstructorCallback : ClassConstructorCallback;
ctorFuncTemplate = FunctionTemplate::New(isolate, funcCallback, ctorCallbackData);
auto baseClass = s_metadataReader.GetBaseClassNode(treeNode);
Handle<Function> baseCtorFunc;
if ((baseClass != treeNode) && (baseClass != nullptr) && (baseClass->offsetValue > 0))
{
auto baseFuncTemplate = GetConstructorFunctionTemplate(isolate, baseClass);
if (!baseFuncTemplate.IsEmpty())
{
ctorFuncTemplate->Inherit(baseFuncTemplate);
baseCtorFunc = baseFuncTemplate->GetFunction();
}
}
auto prototypeTemplate = ctorFuncTemplate->PrototypeTemplate();
auto ctorFunc = node->SetMembers(isolate, ctorFuncTemplate, prototypeTemplate, treeNode);
if (!baseCtorFunc.IsEmpty())
{
ctorFunc->SetPrototype(baseCtorFunc);
}
auto pft = new Persistent<FunctionTemplate>(isolate, ctorFuncTemplate);
s_ctorFuncCache.insert(make_pair(treeNode, pft));
SetInnnerTypes(isolate, ctorFunc, treeNode);
SetTypeMetadata(isolate, ctorFunc, new TypeMetadata(s_metadataReader.ReadTypeName(treeNode)));
return ctorFuncTemplate;
}
示例3: WrapElementDocument
v8::Handle<v8::Object> WrapElementDocument(v8::Handle<v8::Context> context, Rocket::Core::ElementDocument* v)
{
v8::HandleScope handle_scope;
Handle<FunctionTemplate> templt = GetScriptSystem()->GetTemplateBySID(s_elementDocumentWrapper);
if(templt.IsEmpty())
{
templt = FunctionTemplate::New();
templt->Inherit(GetElementTemplate());
templt->SetClassName(String::New("ElementDocument"));
templt->InstanceTemplate()->SetInternalFieldCount(1);
templt->InstanceTemplate()->SetNamedPropertyHandler(
ELNamedPropertyGetter,
ELNamedPropertySetter,
ELNamedPropertyQuery,
ELNamedPropertyDeleter,
ELNamedPropertyEnumerator
);
Handle<ObjectTemplate> proto = templt->PrototypeTemplate();
proto->Set("hide", FunctionTemplate::New(EDHide));
proto->Set("toString", FunctionTemplate::New(EDToString));
proto->Set("show", FunctionTemplate::New(EDShow));
proto->Set("hide", FunctionTemplate::New(EDHide));
proto->Set("close", FunctionTemplate::New(EDClose));
GetScriptSystem()->SetTemplateBySID(s_elementDocumentWrapper, templt);
}
Local<Object> instance = templt->GetFunction()->NewInstance();
instance->SetInternalField(0, External::New(v));
return handle_scope.Close(instance);
}