2010-10-14 01:30:07 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 09:29:57 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
2008-04-11 06:19:01 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 09:29:57 -05:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 21:39:32 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_codemaker.hxx"
|
|
|
|
|
2000-09-18 09:29:57 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-28 10:20:05 -05:00
|
|
|
#include "sal/main.h"
|
|
|
|
|
2006-03-15 02:16:04 -06:00
|
|
|
#include "codemaker/typemanager.hxx"
|
2004-06-03 21:13:45 -05:00
|
|
|
#include "codemaker/generatedtypeset.hxx"
|
2000-09-18 09:29:57 -05:00
|
|
|
#include "javaoptions.hxx"
|
|
|
|
#include "javatype.hxx"
|
|
|
|
|
2011-03-02 14:53:12 -06:00
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::rtl::OString;
|
2005-01-31 08:29:29 -06:00
|
|
|
sal_Bool produceAllTypes(RegistryKey& rTypeKey, sal_Bool bIsExtraType,
|
|
|
|
TypeManager const & typeMgr,
|
2004-06-03 21:13:45 -05:00
|
|
|
codemaker::GeneratedTypeSet & generated,
|
2000-09-18 09:29:57 -05:00
|
|
|
JavaOptions* pOptions,
|
|
|
|
sal_Bool bFullScope)
|
|
|
|
throw( CannotDumpException )
|
|
|
|
{
|
2005-01-31 08:29:29 -06:00
|
|
|
OString typeName = typeMgr.getTypeName(rTypeKey);
|
|
|
|
|
|
|
|
if (!produceType(rTypeKey, bIsExtraType, typeMgr, generated, pOptions))
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s ERROR: %s\n",
|
|
|
|
pOptions->getProgramName().getStr(),
|
|
|
|
OString("cannot dump Type '" + typeName + "'").getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
|
2005-01-31 08:29:29 -06:00
|
|
|
RegistryKeyList typeKeys = typeMgr.getTypeKeys(typeName);
|
|
|
|
RegistryKeyList::const_iterator iter = typeKeys.begin();
|
|
|
|
RegistryKey key, subKey;
|
|
|
|
RegistryKeyArray subKeys;
|
|
|
|
|
|
|
|
while (iter != typeKeys.end())
|
|
|
|
{
|
|
|
|
key = (*iter).first;
|
|
|
|
|
|
|
|
if (!(*iter).second && !key.openSubKeys(OUString(), subKeys))
|
|
|
|
{
|
|
|
|
for (sal_uInt32 i = 0; i < subKeys.getLength(); i++)
|
|
|
|
{
|
|
|
|
subKey = subKeys.getElement(i);
|
|
|
|
if (bFullScope)
|
|
|
|
{
|
|
|
|
if (!produceAllTypes(
|
|
|
|
subKey, (*iter).second,
|
|
|
|
typeMgr, generated, pOptions, sal_True))
|
|
|
|
return sal_False;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (!produceType(subKey, (*iter).second,
|
|
|
|
typeMgr, generated, pOptions))
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++iter;
|
|
|
|
}
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2005-01-31 08:29:29 -06:00
|
|
|
return sal_True;
|
|
|
|
}
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2005-01-31 08:29:29 -06:00
|
|
|
sal_Bool produceAllTypes(const OString& typeName,
|
|
|
|
TypeManager const & typeMgr,
|
|
|
|
codemaker::GeneratedTypeSet & generated,
|
|
|
|
JavaOptions* pOptions,
|
|
|
|
sal_Bool bFullScope)
|
|
|
|
throw( CannotDumpException )
|
|
|
|
{
|
|
|
|
if (!produceType(typeName, typeMgr, generated, pOptions))
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
2005-01-31 08:29:29 -06:00
|
|
|
fprintf(stderr, "%s ERROR: %s\n",
|
|
|
|
pOptions->getProgramName().getStr(),
|
|
|
|
OString("cannot dump Type '" + typeName + "'").getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2005-01-31 08:29:29 -06:00
|
|
|
RegistryKeyList typeKeys = typeMgr.getTypeKeys(typeName);
|
|
|
|
RegistryKeyList::const_iterator iter = typeKeys.begin();
|
|
|
|
RegistryKey key, subKey;
|
|
|
|
RegistryKeyArray subKeys;
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2005-01-31 08:29:29 -06:00
|
|
|
while (iter != typeKeys.end())
|
|
|
|
{
|
|
|
|
key = (*iter).first;
|
|
|
|
if (!(*iter).second && !key.openSubKeys(OUString(), subKeys))
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
2005-01-31 08:29:29 -06:00
|
|
|
for (sal_uInt32 i = 0; i < subKeys.getLength(); i++)
|
|
|
|
{
|
|
|
|
subKey = subKeys.getElement(i);
|
|
|
|
if (bFullScope)
|
|
|
|
{
|
|
|
|
if (!produceAllTypes(
|
|
|
|
subKey, (*iter).second,
|
|
|
|
typeMgr, generated, pOptions, sal_True))
|
|
|
|
return sal_False;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (!produceType(subKey, (*iter).second,
|
|
|
|
typeMgr, generated, pOptions))
|
|
|
|
return sal_False;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
2005-01-31 08:29:29 -06:00
|
|
|
|
|
|
|
++iter;
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return sal_True;
|
|
|
|
}
|
|
|
|
|
2004-10-28 10:20:05 -05:00
|
|
|
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
JavaOptions options;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (!options.initOptions(argc, argv))
|
|
|
|
{
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( IllegalArgument& e)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Illegal option: %s\n", e.m_message.getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegistryTypeManager typeMgr;
|
|
|
|
|
2002-07-31 06:46:45 -05:00
|
|
|
if (!typeMgr.init(options.getInputFiles(), options.getExtraInputFiles()))
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s : init registries failed, check your registry files.\n", options.getProgramName().getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.isValid("-B"))
|
|
|
|
{
|
|
|
|
typeMgr.setBase(options.getOption("-B"));
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (options.isValid("-T"))
|
|
|
|
{
|
|
|
|
OString tOption(options.getOption("-T"));
|
2001-05-10 08:16:41 -05:00
|
|
|
sal_Int32 nIndex = 0;
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2004-06-03 21:13:45 -05:00
|
|
|
codemaker::GeneratedTypeSet generated;
|
2000-09-18 09:29:57 -05:00
|
|
|
OString typeName, tmpName;
|
|
|
|
sal_Bool ret = sal_False;
|
2001-05-10 08:16:41 -05:00
|
|
|
do
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
2001-05-10 08:16:41 -05:00
|
|
|
typeName = tOption.getToken(0, ';', nIndex);
|
2000-09-18 09:29:57 -05:00
|
|
|
|
2001-05-10 08:16:41 -05:00
|
|
|
sal_Int32 nPos = typeName.lastIndexOf( '.' );
|
|
|
|
tmpName = typeName.copy( nPos != -1 ? nPos+1 : 0 );
|
2000-09-18 09:29:57 -05:00
|
|
|
if (tmpName == "*")
|
|
|
|
{
|
2005-01-31 08:29:29 -06:00
|
|
|
// produce this type and his scope.
|
2000-09-18 09:29:57 -05:00
|
|
|
if (typeName.equals("*"))
|
|
|
|
{
|
|
|
|
tmpName = "/";
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
tmpName = typeName.copy(0, typeName.lastIndexOf('.')).replace('.', '/');
|
|
|
|
if (tmpName.getLength() == 0)
|
|
|
|
tmpName = "/";
|
|
|
|
else
|
|
|
|
tmpName.replace('.', '/');
|
|
|
|
}
|
2005-01-31 08:29:29 -06:00
|
|
|
// related to task #116780# the scope is recursively
|
|
|
|
// generated. bFullScope = true
|
2004-06-03 21:13:45 -05:00
|
|
|
ret = produceAllTypes(
|
2005-01-31 08:29:29 -06:00
|
|
|
tmpName, typeMgr, generated, &options, sal_True);
|
2000-09-18 09:29:57 -05:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
// produce only this type
|
2004-06-03 21:13:45 -05:00
|
|
|
ret = produceType(
|
|
|
|
typeName.replace('.', '/'), typeMgr, generated,
|
|
|
|
&options);
|
2000-09-18 09:29:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s ERROR: %s\n",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
OString("cannot dump Type '" + typeName + "'").getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
2001-05-10 08:16:41 -05:00
|
|
|
} while( nIndex != -1 );
|
2000-09-18 09:29:57 -05:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
// produce all types
|
2004-06-03 21:13:45 -05:00
|
|
|
codemaker::GeneratedTypeSet generated;
|
|
|
|
if (!produceAllTypes("/", typeMgr, generated, &options, sal_True))
|
2000-09-18 09:29:57 -05:00
|
|
|
{
|
|
|
|
fprintf(stderr, "%s ERROR: %s\n",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
"an error occurs while dumping all types.");
|
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( CannotDumpException& e)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s ERROR: %s\n",
|
|
|
|
options.getProgramName().getStr(),
|
|
|
|
e.m_message.getStr());
|
|
|
|
exit(99);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 01:30:07 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|