1 /* 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Copyright (C) 2012 - Scilab Enterprises - Calixte DENIZET 4 * 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises 6 * 7 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * This file was originally licensed under the terms of the CeCILL v2.1, 10 * and continues to be available under such terms. 11 * For more information, see the COPYING file which you should have received 12 * along with this program. 13 * 14 */ 15 16 #include "VariableScope.hxx" 17 #include "XMLObject.hxx" 18 19 #define SCOPE_SIZE 1024 20 21 namespace org_modules_xml 22 { 23 VariableScope *XMLObject::scope = 0; 24 25 #ifdef SCILAB_DEBUG_XML 26 std::set<XMLObject *> XMLObject::pointers; 27 #endif 28 XMLObject()29XMLObject::XMLObject(): id(0), valid(true) 30 { 31 if (!scope) 32 { 33 scope = new VariableScope(SCOPE_SIZE); 34 } 35 36 #ifdef SCILAB_DEBUG_XML 37 XMLObject::pointers.insert(this); 38 //std::cout << "Create = " << (void*)this << std::endl; 39 #endif 40 41 scilabType = -1; 42 } 43 getVariableFromId(int id)44XMLObject *XMLObject::getVariableFromId(int id) 45 { 46 if (!scope) 47 { 48 return 0; 49 } 50 51 return scope->getVariableFromId(id); 52 } 53 createOnStack(int pos,void * pvApiCtx) const54int XMLObject::createOnStack(int pos, void *pvApiCtx) const 55 { 56 if (scilabType != -1) 57 { 58 return createXMLObjectAtPos(scilabType, pos, id, pvApiCtx); 59 } 60 61 return 0; 62 } 63 resetScope()64void XMLObject::resetScope() 65 { 66 if (scope) 67 { 68 delete scope; 69 70 scope = 0; 71 } 72 } 73 } 74