diff -r d8fccb2cd802 -r 468f4c8d3d5b Orb/python/orb/hrefloader.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Orb/python/orb/hrefloader.py Wed Aug 11 14:49:30 2010 +0100 @@ -0,0 +1,462 @@ +# Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +try: + from xml.etree import cElementTree as etree +except ImportError: + from xml.etree import ElementTree as etree +import xml +import os +import logging + + +class HrefLoader(object): + """ + Class that parses DITA cxx files and returns the header file an API is declared in. + + >>> refloader = HrefLoader(".", parser=EtreeStub()) # Pass in a stub parser for testing + >>> refloader.get("class_c_always_online_e_com_interface.xml#class_c_always_online_e_com_interface") + 'D:/epoc32/include/platform/mw/AlwaysOnlineEComInterface.h' + """ + def __init__(self, filedir, parser=etree): + self.basedir = filedir + self.parser = parser + self.decls = ['cxxClassDeclarationFile', 'cxxTypedefDeclarationFile', 'cxxFunctionDeclarationFile', 'cxxVariableDeclarationFile',] + + def get(self, url): + filename = url.split('#')[0].split('::')[-1] + id = url.split('#')[1] if '#' in url else filename + filepath = os.path.join(self.basedir, filename) + try: + tree = self.parser.parse(filepath) + #except xml.parsers.expat.ExpatError, e: + except Exception, e: + logging.error("%s could not be parsed: %s\n" % (filepath, str(e))) + return "" + except IOError: + return "" + in_correct_element = False + for el in tree.getiterator(): + if 'id' in el.attrib and el.attrib['id'] == id: + in_correct_element = True + if el.tag in self.decls and in_correct_element: + return el.attrib['value'] + return "" + + +################################################################ +# Unit test code +################################################################ +import unittest +from cStringIO import StringIO + + +class EtreeStub(object): + def parse(self, file): + return etree.parse(StringIO(class_c_always_online)) + + +class InvalidEtreeStub(object): + def parse(self, file): + return etree.parse(StringIO(" + + + CAlwaysOnlineEComInterface + + + + + + + + + CBase + + + + + + + + + + + +

7.0 REComSession, CActive An AlwaysOnlineManager abstract class being representative of the concrete class which the client wishes to use. It acts as a base, for a real class to provide all the functionality that a client requires. It supplies instantiation & destruction by using the ECom framework, and functional services by using the methods of the actual class.

+
+
+ CAlwaysOnlineEComInterface + + TAlwaysOnlineManagerInterfaceInitParams + + + + + struct CAlwaysOnlineEComInterface::_CEComInterfaceInitParams + + CAlwaysOnlineEComInterface + struct CAlwaysOnlineEComInterface::_CEComInterfaceInitParams TAlwaysOnlineManagerInterfaceInitParams + CAlwaysOnlineEComInterface::TAlwaysOnlineManagerInterfaceInitParams + + + + + + + + + + NewL + + + + + + + + CAlwaysOnlineEComInterface * + CAlwaysOnlineEComInterface + inline static CAlwaysOnlineEComInterface * NewL(TUid aId) + CAlwaysOnlineEComInterface::NewL(TUid) + + + + TUid + + aId + + + + + + + + + + + + + + + + NewL + + + + + + + + CAlwaysOnlineEComInterface * + CAlwaysOnlineEComInterface + inline static CAlwaysOnlineEComInterface * NewL(const TDesC8 &aMatchString) + CAlwaysOnlineEComInterface::NewL(const TDesC8 &) + + + const TDesC8 & + aMatchString + + + + + + + + + + + + + + + + ~CAlwaysOnlineEComInterface + + + + + + + + + CAlwaysOnlineEComInterface + inline virtual ~CAlwaysOnlineEComInterface() + CAlwaysOnlineEComInterface::~CAlwaysOnlineEComInterface() + + + + + + + + + + + + + + ListImplementationsL + + + + + + + void + CAlwaysOnlineEComInterface + inline static void ListImplementationsL(RImplInfoPtrArray &aImplInfoArray) + CAlwaysOnlineEComInterface::ListImplementationsL(RImplInfoPtrArray &) + + + + RImplInfoPtrArray & + aImplInfoArray + + + + + + + + + + + + + + + + ListAllImplementationsL + + + + + + + void + CAlwaysOnlineEComInterface + inline static void ListAllImplementationsL(RImplInfoPtrArray &aImplInfoArray) + CAlwaysOnlineEComInterface::ListAllImplementationsL(RImplInfoPtrArray &) + + + + RImplInfoPtrArray & + aImplInfoArray + + + + + + + + + + + + + + + + HandleServerCommandL + + + + + + + + TAny * + CAlwaysOnlineEComInterface + inline virtual TAny * HandleServerCommandL(TInt aCommand, TDesC8 *aParameters=NULL)=0 + CAlwaysOnlineEComInterface::HandleServerCommandL(TInt,TDesC8 *) + + + + TInt + + aCommand + + + + + TDesC8 * + aParameters + NULL + + + + + + + + + + + + + + + + SetStatusQueryObject + + + + + + void + CAlwaysOnlineEComInterface + inline void SetStatusQueryObject(MAlwaysOnlineStatusQueryInterface *aStatusQueryObject) + CAlwaysOnlineEComInterface::SetStatusQueryObject(MAlwaysOnlineStatusQueryInterface *) + + + + MAlwaysOnlineStatusQueryInterface * + aStatusQueryObject + + + + + + + + + + + + + + + + InstanceUid + + + + + + + TUid + + CAlwaysOnlineEComInterface + inline TUid InstanceUid() + CAlwaysOnlineEComInterface::InstanceUid() + + + + + + + + + + + + + + CAlwaysOnlineEComInterface + + + + + + + + CAlwaysOnlineEComInterface + inline CAlwaysOnlineEComInterface() + CAlwaysOnlineEComInterface::CAlwaysOnlineEComInterface() + + + + + + + + + + + + + + iDtor_ID_Key + + + + + + TUid + + CAlwaysOnlineEComInterface + TUid iDtor_ID_Key + CAlwaysOnlineEComInterface::iDtor_ID_Key + + + + + + + + + + iStatusQueryObject + + + + + + MAlwaysOnlineStatusQueryInterface * + CAlwaysOnlineEComInterface + MAlwaysOnlineStatusQueryInterface * iStatusQueryObject + CAlwaysOnlineEComInterface::iStatusQueryObject + + + + + + + + + + CBase::CBase() + CBase::Delete(CBase *) + CBase::Extension_(TUint,TAny *&,TAny *) + CBase::operator new(TUint) + CBase::operator new(TUint,TAny *) + CBase::operator new(TUint,TLeave) + CBase::operator new(TUint,TLeave,TUint) + CBase::operator new(TUint,TUint) + CBase::~CBase() + +
""" \ No newline at end of file