Commit d6b08a3a authored by Giuseppe Lo Presti's avatar Giuseppe Lo Presti
Browse files

Improved clone() implementation for special cases: if <EntityName>.cpp_clone

is found in the source, its code is included in the generated <EntityName>.cpp class.
parent f7c75990
DEV=$(CASTORDEV_HOME)/codeGeneration/gencastor
UMBRELLOBASE=../kdesdk-3.5.1
UMBRELLOBASE=kdesdk-3.5
UMBRELLO=$(UMBRELLOBASE)/umbrello/umbrello
UMBRELLOOBJBASE=$(UMBRELLOBASE)
......@@ -30,6 +30,7 @@ all : gencastor.bin
install : gencastor.bin
@echo Installing gencastor
@install gencastor $(DESTDIR)/usr/bin
@install codemerge.py $(DESTDIR)/usr/bin
@install gencastor.bin $(DESTDIR)/usr/bin
@install gencastor.1 $(DESTDIR)/usr/share/man/man1
@install -D headers/heading.cpp $(DESTDIR)/etc/castor/gencastor/heading.cpp
......
#!/usr/bin/python
#
# An internal script used by gencastor to merge specific code for some special cases in the generated one.
# Currently used to merge the clone() method for some classes that need a custom implementation.
#
# @author Castor dev team, castor-dev@cern.ch
#
# @(#)$RCSfile: codemerge.py,v $ $Revision: 1.1 $ $Release$ $Date: 2006/08/07 14:44:59 $ $Author: itglp $
#
import sys
import os
if(len(sys.argv) != 4):
# we don't want to expose this to users
print "codemerge: for internal use only, see genCastor"
sys.exit(1)
source = open(sys.argv[1], 'r')
tobeadded = open(sys.argv[2], 'r')
dest = open(sys.argv[3], 'w')
header = tobeadded.readline()
# at the beginning, dest = source
currentline = ''
while currentline != header:
currentline = source.readline()
dest.write(currentline)
# append now the tobeadded part
dest.write(tobeadded.read())
source.readline()
source.readline()
# append the rest of source
dest.write(source.read())
source.close()
tobeadded.close()
dest.close()
......@@ -64,6 +64,7 @@ int main(int argc, char *argv[]) {
policy->setOutputDirectory(QDir(args->getOption("o")));
}
// Now generate code
std::cout << "Generation started" << std::endl;
if (1 == args->count()) {
gen->writeCodeToFile();
} else {
......@@ -81,11 +82,11 @@ int main(int argc, char *argv[]) {
}
}
args->clear();
std::cout << "Generation ended" << std::endl;
} else {
std::cout << "Invalid number of arguments\n"
<< "syntax : " << argv[0] << " <xmi File>"
<< std::endl;
}
std::cout << "Generation ended !" << std::endl;
uml->close();
}
#!/usr/bin/tcsh
#
# A wrapper script for gencastor.bin, to put files in the proper places and avoid to overwrite not modified ones.
# It also manages the generated SQL scripts.
#
# @author Castor dev team, castor-dev@cern.ch
#
# @(#)$RCSfile: gencastor,v $ $Revision: 1.14 $ $Release$ $Date: 2006/08/07 14:44:59 $ $Author: itglp $
#
if ("$1" == "-h") then
echo "Usage :"
......@@ -36,8 +44,10 @@ grep 'CREATE OR REPLACE' ${TMPDIR}/${TOPNS}/db/postgresTrailer.sql | grep -v 'TR
# hack to prevent Umbrello from overwriting the original XMI file
cp ${XMIFILE} ${TMPDIR}
set XMITOUSE=`echo ${XMIFILE} | awk -F'/' '{ print $NF }'`
set XMITOUSE=`basename ${XMIFILE}`
(/usr/bin/gencastor.bin -o ${TMPDIR} -c ${TOPNS} --nocrashhandler ${TMPDIR}/${XMITOUSE} > /dev/tty) >& /dev/null
sed 's/^END;/END;\n\//' ${TMPDIR}/${TOPNS}/db/${TOPNS}_oracle_create.sql | sed 's/^\(END castor[a-zA-Z]*;\)/\1\n\//' | sed 's/\(CREATE OR REPLACE TYPE .*\)$/\1\n\//' > ${TMPDIR}/${TOPNS}/db/${TOPNS}_oracle_create.sqlplus
set pushdsilent
......@@ -54,8 +64,13 @@ foreach f (`find . -type f`)
endif
echo "Creating $f"
cp ${TMPDIR}/${f} ${WORKDIR}/$f
else
set d = `diff -q ${WORKDIR}/${f} ${TMPDIR}/${f}`
else
if (-f ${WORKDIR}/${f}_clone) then
echo Merging clone before upgrading $f
`dirname $0`/codemerge.py ${TMPDIR}/${f} ${WORKDIR}/${f}_clone ${TMPDIR}/${f}_merge
mv ${TMPDIR}/${f}_merge ${TMPDIR}/${f}
endif
set d = `diff -q ${WORKDIR}/${f} ${TMPDIR}/${f}`
#echo "Diff gave --$d--"
if ("$d" != "") then
echo "Upgrading $f"
......
......@@ -34,7 +34,6 @@
CppWriter::CppWriter( ) :
CppCastorWriter(UMLApp::app()->getDocument(), "Cpp"), firstGeneration(true) {
std::cout << "Generation started !" << std::endl;
// Create all needed generators
hppw = new CppHClassWriter(m_doc, ".hpp file generator");
hw = new CHClassWriter(m_doc, ".h file generator for C interfaces");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment