void TNodeJsFIn::Init(v8::Handle<v8::Object> exports) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); // template for creating function from javascript using "new", uses _NewJs callback v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewJs<TNodeJsFIn>); // child will have the same properties and methods, but a different callback: _NewCpp v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewCpp<TNodeJsFIn>); child->Inherit(tpl); child->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr())); // ObjectWrap uses the first internal field to store the wrapped pointer child->InstanceTemplate()->SetInternalFieldCount(1); tpl->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr())); // ObjectWrap uses the first internal field to store the wrapped pointer tpl->InstanceTemplate()->SetInternalFieldCount(1); // Add all prototype methods, getters and setters here NODE_SET_PROTOTYPE_METHOD(tpl, "peekCh", _peekCh); NODE_SET_PROTOTYPE_METHOD(tpl, "getCh", _getCh); NODE_SET_PROTOTYPE_METHOD(tpl, "readLine", _readLine); NODE_SET_PROTOTYPE_METHOD(tpl, "readJson", _readJson); NODE_SET_PROTOTYPE_METHOD(tpl, "readAll", _readAll); // Add properties tpl->InstanceTemplate()->SetAccessor(v8::String::NewFromUtf8(Isolate, "eof"), _eof); tpl->InstanceTemplate()->SetAccessor(v8::String::NewFromUtf8(Isolate, "length"), _length); // This has to be last, otherwise the properties won't show up on the object in JavaScript // Constructor is used when creating the object from C++ Constructor.Reset(Isolate, child->GetFunction()); // we need to export the class for calling using "new FIn(...)" exports->Set(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()), tpl->GetFunction()); }
// protected HRESULT CFeedback::CloneTo(CInteractionAreaEx *pTarget, bool bCopyHashKey) { HRESULT hr = S_OK; hr = CInteractionAreaEx::CloneTo(pTarget, bCopyHashKey); if (SUCCEEDED(hr)) { if (pTarget->GetClassId() != GetClassId()) return E_INVALIDARG; CFeedback *pOther = (CFeedback *)pTarget; pOther->m_idType = m_idType; pOther->m_bIsInherited = m_bIsInherited; pOther->m_bIsDisabled = m_bIsDisabled; pOther->m_csText = m_csText; pOther->m_aObjects.SetSize(0, m_aObjects.GetSize()); for (int i=0; i<m_aObjects.GetSize(); ++i) pOther->m_aObjects.Add(m_aObjects[i]->Copy()); if (m_pOkButton != NULL) pOther->m_pOkButton = m_pOkButton->Copy(); pOther->m_nInteractionObjectHash = 0; // the new object is not yet added anywhere pOther->m_bPassed = m_bPassed; } return hr; }
///////////////////////////////////////// // DHT11 - Digital temperature and humidity sensor void TNodejsDHT11Sensor::Init(v8::Handle<v8::Object> Exports) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewJs<TNodejsDHT11Sensor>); tpl->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr())); // ObjectWrap uses the first internal field to store the wrapped pointer. tpl->InstanceTemplate()->SetInternalFieldCount(1); // Add all methods, getters and setters here. NODE_SET_PROTOTYPE_METHOD(tpl, "init", _init); NODE_SET_PROTOTYPE_METHOD(tpl, "read", _read); NODE_SET_PROTOTYPE_METHOD(tpl, "readSync", _readSync); Exports->Set(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()), tpl->GetFunction()); }
boolean TextFileComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; return strcmp(GetPathname(), ((TextFileComp&)comp).GetPathname()) && strcmp(GetBegstr(), ((TextFileComp&)comp).GetBegstr()) && strcmp(GetEndstr(), ((TextFileComp&)comp).GetEndstr()) && GetLineWidth() == ((TextFileComp&)comp).GetLineWidth() && OverlayComp::operator==(comp); }
boolean TextOvComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; TextGraphic* texta = GetText(); TextGraphic* textb = ((TextOvComp&)comp).GetText(); int lha = texta->GetLineHeight(); int lhb = textb->GetLineHeight(); return lha == lhb && strcmp(texta->GetOriginal(), textb->GetOriginal()) == 0 && OverlayComp::operator==(comp); }
///////////////////////////////////////// // RF24 - Radio void TNodeJsRf24Radio::Init(v8::Handle<v8::Object> Exports) { v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::HandleScope HandleScope(Isolate); v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewJs<TNodeJsRf24Radio>); tpl->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr())); // ObjectWrap uses the first internal field to store the wrapped pointer. tpl->InstanceTemplate()->SetInternalFieldCount(1); // Add all methods, getters and setters here. NODE_SET_PROTOTYPE_METHOD(tpl, "init", _init); NODE_SET_PROTOTYPE_METHOD(tpl, "get", _get); NODE_SET_PROTOTYPE_METHOD(tpl, "getAll", _getAll); NODE_SET_PROTOTYPE_METHOD(tpl, "set", _set); NODE_SET_PROTOTYPE_METHOD(tpl, "ping", _ping); NODE_SET_PROTOTYPE_METHOD(tpl, "onValue", _onValue); NODE_SET_PROTOTYPE_METHOD(tpl, "onPong", _onPong); Exports->Set(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()), tpl->GetFunction()); }
BuildingGUID CBaseManager::GenerateGUID(char const* szTeam, char const* szClass) const { // Get the team and class IDs TeamID nTeamID = TEAMID_INVALID; BuildingClassID nClassID = GetClassId(szClass); if (NULL != g_D6Core->pTeamManager) nTeamID = g_D6Core->pTeamManager->GetTeamId(szTeam); // Must be valid if (TEAMID_INVALID == nTeamID || BC_INVALID == nClassID) return GUID_INVALID; return MAKE_BUILDING_GUID(nTeamID, nClassID); }
void TNodeJsFOut::New(const v8::FunctionCallbackInfo<v8::Value>& Args) { EAssertR(Args.IsConstructCall(), "TNodeJsFOut: not a constructor call (you forgot to use the new operator)"); v8::Isolate* Isolate = v8::Isolate::GetCurrent(); v8::EscapableHandleScope HandleScope(Isolate); // set hidden class id v8::Local<v8::Object> Instance = Args.This(); v8::Handle<v8::String> key = v8::String::NewFromUtf8(Isolate, "class"); v8::Handle<v8::String> value = v8::String::NewFromUtf8(Isolate, GetClassId().CStr()); Instance->SetHiddenValue(key, value); // empty constructor call just forwards the instance if (Args.Length() == 0) { Args.GetReturnValue().Set(Instance); return; } // parse arguments EAssertR(Args.Length() >= 1 && Args[0]->IsString(), "Expected file path."); TStr FNm(*v8::String::Utf8Value(Args[0]->ToString())); bool AppendP = Args.Length() >= 2 && Args[1]->IsBoolean() && Args[1]->BooleanValue(); // Args.This() is an instance, wrap our C++ object TNodeJsFOut* Obj = new TNodeJsFOut(FNm, AppendP); Obj->Wrap(Instance); Args.GetReturnValue().Set(Instance); }
BOOL CActiveMember::IsMember() { return CNetBarConfig::GetInstance()->GetIsMember( GetClassId() ); }
void CActiveMember::SetClassId(UINT newVal) { GPropertyInit( ClassId, newVal ); UserClassName = CNetBarConfig::GetInstance()->GetUserClassName(GetClassId()); }
ComponentView* Component::Create (ClassId viewId) { ClassId gv = Combine(GetClassId(), viewId); return (ComponentView*) unidraw->GetCatalog()->GetCreator()->Create(gv); }