static void AppendOrReplaceChildren( pIStructureNode contextStructureNode, const spINode & parsedNode ) { pIMetadata meta( NULL ); try { meta = parsedNode->GetInterfacePointer< IMetadata >(); } catch ( spcIError err ) { meta = NULL; } if ( meta ) { auto it = meta->Iterator(); while ( it ) { auto childNode = it->GetNode(); it = it->Next(); childNode = meta->GetIMetadata_I()->RemoveNode( childNode->GetNameSpace(), childNode->GetName() ); if ( contextStructureNode->GetIStructureNode_I()->GetNode( childNode->GetNameSpace(), childNode->GetName() ) ) contextStructureNode->ReplaceNode( childNode ); else contextStructureNode->AppendNode( childNode ); } } else { if ( contextStructureNode->GetIStructureNode_I()->GetNode( parsedNode->GetNameSpace(), parsedNode->GetName() ) ) contextStructureNode->ReplaceNode( parsedNode ); else contextStructureNode->AppendNode( parsedNode ); } }
gd::ObjectMetadata & PlatformExtension::AddObject(const std::string & name, const std::string & fullname, const std::string & informations, const std::string & icon24x24, CreateFunPtr createFunPtrP, DestroyFunPtr destroyFunPtrP) { std::string nameWithNamespace = GetNameSpace().empty() ? name : GetNameSpace()+name; objectsInfos[nameWithNamespace] = ObjectMetadata(GetNameSpace(), nameWithNamespace, fullname, informations, icon24x24, createFunPtrP, destroyFunPtrP); return objectsInfos[nameWithNamespace]; }
gd::ExpressionMetadata & PlatformExtension::AddStrExpression(const gd::String & name, const gd::String & fullname, const gd::String & description, const gd::String & group, const gd::String & smallicon) { #if defined(GD_IDE_ONLY) gd::String nameWithNamespace = GetNameSpace().empty() ? name : GetNameSpace()+name; strExpressionsInfos[nameWithNamespace] = ExpressionMetadata(GetNameSpace(), nameWithNamespace, fullname, description, group, smallicon); return strExpressionsInfos[nameWithNamespace]; #endif }
gd::EventMetadata & PlatformExtension::AddEvent(const gd::String & name_, const gd::String & fullname_, const gd::String & description_, const gd::String & group_, const gd::String & smallicon_, std::shared_ptr<gd::BaseEvent> instance_) { #if defined(GD_IDE_ONLY) gd::String nameWithNamespace = GetNameSpace().empty() ? name_ : GetNameSpace()+name_; eventsInfos[nameWithNamespace] = gd::EventMetadata(nameWithNamespace, fullname_, description_, group_, smallicon_, instance_); return eventsInfos[nameWithNamespace]; #endif }
gd::BehaviorMetadata & PlatformExtension::AddBehavior(const gd::String & name, const gd::String & fullname, const gd::String & defaultName, const gd::String & description, const gd::String & group, const gd::String & icon24x24, const gd::String & className, std::shared_ptr<gd::Behavior> instance, std::shared_ptr<gd::BehaviorsSharedData> sharedDatasInstance) { gd::String nameWithNamespace = GetNameSpace().empty() ? name : GetNameSpace()+name; behaviorsInfo[nameWithNamespace] = BehaviorMetadata(GetNameSpace(), nameWithNamespace, fullname, defaultName, description, group, icon24x24, className, instance, sharedDatasInstance); return behaviorsInfo[nameWithNamespace]; }
gd::InstructionMetadata & PlatformExtension::AddCondition(const gd::String & name, const gd::String & fullname, const gd::String & description, const gd::String & sentence, const gd::String & group, const gd::String & icon, const gd::String & smallicon) { #if defined(GD_IDE_ONLY) gd::String nameWithNamespace = GetNameSpace().empty() ? name : GetNameSpace()+name; conditionsInfos[nameWithNamespace] = InstructionMetadata(GetNameSpace(), nameWithNamespace, fullname, description, sentence, group, icon, smallicon); return conditionsInfos[nameWithNamespace]; #endif }
gd::AutomatismMetadata & PlatformExtension::AddAutomatism(const std::string & name, const std::string & fullname, const std::string & defaultName, const std::string & description, const std::string & group, const std::string & icon24x24, const std::string & className, boost::shared_ptr<gd::Automatism> instance, boost::shared_ptr<gd::AutomatismsSharedData> sharedDatasInstance) { std::string nameWithNamespace = GetNameSpace().empty() ? name : GetNameSpace()+name; automatismsInfo[nameWithNamespace] = AutomatismMetadata(GetNameSpace(), nameWithNamespace, fullname, defaultName, description, group, icon24x24, className, instance, sharedDatasInstance); return automatismsInfo[nameWithNamespace]; }
sInt DebugInfo::GetNameSpaceByName(sChar *name) { sChar *pp = name - 2; sChar *p; sInt cname; while((p = sFindString(pp+2,"::"))) pp = p; while((p = sFindString(pp+1,"."))) pp = p; if(pp != name - 2) { sChar buffer[2048]; sCopyString(buffer,name,2048); if(pp - name < 2048) buffer[pp - name] = 0; cname = MakeString(buffer); } else cname = MakeString("<global>"); return GetNameSpace(cname); }
static void AppendAsChildren( const spINode & contextNode, const spINode & parsedNode ) { if ( !contextNode ) NOTIFY_ERROR( IError::kEDParser, kPECInvalidContextNode, "Context Node is invalid", IError::kESOperationFatal, false, false ); auto contextNodeType = contextNode->GetNodeType(); if ( contextNodeType != INode::kNTStructure && contextNodeType != INode::kNTArray ) NOTIFY_ERROR( IError::kEDParser, kPECContextNodeIsNonComposite, "Context Node is non composite", IError::kESOperationFatal, true, static_cast< sizet >( contextNodeType ) ); pICompositeNode compositeContextNode = contextNode->GetInterfacePointer< ICompositeNode >(); pIMetadata meta( NULL ); try { meta = parsedNode->GetInterfacePointer< IMetadata >(); } catch ( spcIError err ) { meta = NULL; } if ( meta ) { auto it = meta->Iterator(); while ( it ) { auto childNode = it->GetNode(); it = it->Next(); childNode = meta->GetIMetadata_I()->RemoveNode( childNode->GetNameSpace(), childNode->GetName() ); compositeContextNode->AppendNode( childNode ); } } else { compositeContextNode->AppendNode( parsedNode ); } }
static void InsertAfter( const spINode & contextNode, const spINode & parsedNode ) { if ( !contextNode ) NOTIFY_ERROR( IError::kEDParser, kPECInvalidContextNode, "Context Node is invalid", IError::kESOperationFatal, false, false ); if ( !contextNode->IsArrayItem() ) NOTIFY_ERROR( IError::kEDParser, kPECContextNodeParentIsNonArray, "Context Node's Parent is non array node", IError::kESOperationFatal, false, false ); pIMetadata meta( NULL ); try { meta = parsedNode->GetInterfacePointer< IMetadata >(); } catch ( spcIError err ) { meta = NULL; } pIArrayNode parentArrayNode = contextNode->GetINode_I()->GetRawParentPointer()->GetInterfacePointer< IArrayNode >(); if ( meta ) { auto it = meta->Iterator(); sizet index = contextNode->GetIndex() + 1; while ( it ) { auto childNode = it->GetNode(); it = it->Next(); childNode = meta->GetIMetadata_I()->RemoveNode( childNode->GetNameSpace(), childNode->GetName() ); parentArrayNode->InsertNodeAtIndex( childNode, index ); index = childNode->GetIndex() + 1; } } else { parentArrayNode->InsertNodeAtIndex( parsedNode, contextNode->GetIndex() + 1 ); } }
static PyObject* Session_InvokeMethod(Session *self, PyObject *args, PyObject *kwds) { PyObject* target = NULL; wchar_t* methodName = NULL; PyObject* inboundParams = NULL; static char *kwlist[] = { "target", "method_name", "inbound_params", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwds, "Ou|O", kwlist, &target, &methodName, &inboundParams)) return NULL; try { if (!CheckPyNone(inboundParams) && !PyObject_IsInstance(inboundParams, reinterpret_cast<PyObject*>(&InstanceType))) throw MI::TypeConversionException(L"\"inbound_params\" must have type Instance"); std::shared_ptr<MI::Operation> op; if (PyObject_IsInstance(target, reinterpret_cast<PyObject*>(&InstanceType))) { AllowThreads(&self->cs, [&]() { op = self->session->InvokeMethod(*((Instance*)target)->instance, methodName, !CheckPyNone(inboundParams) ? ((Instance*)inboundParams)->instance : NULL); }); } else if (PyObject_IsInstance(target, reinterpret_cast<PyObject*>(&ClassType))) { AllowThreads(&self->cs, [&]() { auto miClass = ((Class*)target)->miClass; op = self->session->InvokeMethod(miClass->GetNameSpace(), miClass->GetClassName(), methodName, !CheckPyNone(inboundParams) ? ((Instance*)inboundParams)->instance : NULL); }); } else { throw MI::TypeConversionException(L"\"target\" must have type Instance or Class"); } if (op) { return (PyObject*)Operation_New(op); } Py_RETURN_NONE; } catch (std::exception& ex) { SetPyException(ex); return NULL; } }
static void ReplaceChildren( pIArrayNode contextArrayNode, const spINode & parsedNode ) { contextArrayNode->Clear(); pIMetadata meta( NULL ); try { meta = parsedNode->GetInterfacePointer< IMetadata >(); } catch ( spcIError err ) { meta = NULL; } if ( meta ) { auto it = meta->Iterator(); while ( it ) { auto childNode = it->GetNode(); it = it->Next(); childNode = meta->GetIMetadata_I()->RemoveNode( childNode->GetNameSpace(), childNode->GetName() ); contextArrayNode->AppendNode( childNode ); } } else { contextArrayNode->AppendNode( parsedNode ); } }