Update embedded kalyptus installation

bug/266/move-to-usr
Timothy Pearson 13 years ago
parent 795a0355a4
commit cf5706eb5a

@ -1,3 +1,306 @@
2005-09-26 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Some fixes/enhancements from the trunk version. Most
importantly generating accessor methods to get and set
public instance variables.
2005-02-17 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added a '--qt4' option to parse Qt 4 headers
2005-02-06 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* The KWin class was bracketed with '#ifdef Q_OS_UNIX.. #endif', and was being skipped
by kalyptus. Fixes a problem reported by Ian Monroe.
CCMAIL: ian.monroe@gmail.com
2004-10-02 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Fixed problem where a call to super in java TQWidet.polish() caused a loop
* DCOPArg and DCOPReply are ignored for java bindings generation
2004-09-10 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Fixed Smoke library generation for KDE 3.1
2004-09-05 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Removed forward declarations for classes embedded in method return types.
For instance:
virtual class View *createView ( TQWidget *parent, const char *name = 0 ) = 0;
virtual TQPtrList<class View> views () const = 0;
* Added kate as a KDE include header subdirectory
2004-09-05 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added kontact to the expected KDE header subdirectory names
* Fixed a bug in the code generation for this method:
virtual TQValueList<Kontact::Plugin*> pluginList() const = 0;
It was being incorrectly treated as a pointer type, because it contained as asterisk.
2004-08-19 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* A namespace such as KIO:: can be spread over several header files, the source
names are now kept in a property list so that all the includes can be generated.
2004-07-26 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* TQMap and TQPair template types such as 'TQMap<TQCString, DCOPRef>' with an
embedded comma, were not being correctly normalised. A space was left in
the smoke type.
2004-07-25 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* When the Smoke code for accessing an enum was generated, it was assuming
that the enum was in the same source file as the class. This doesn't work
for namespaces like KIO:: where enums can be spread over several source
files.
* The solution is to add a source file property to each enum, and when the
accessor code for the enum is generated a suitable include can be added.
* Fixes problem reported by Luca Perossa
CCMAIL: kde-bindings@kde.org
2004-07-07 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* After discussion with Germain Garand, TQChars have been returned to
the Smoke runtime as first class members.
2004-07-07 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* The TQChar class is now treated as a primitive type just like TQString.
2004-06-30 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added DCOPRef to the Smoke runtime. But the various template methods for send(), call() and callExt()
need to be reimplemented in the scripting language.
2004-06-29 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Java methods now generated for qCompress and qUncompress methods - Michal Ceresna
reported that the methods missing from the QtJava api.
2004-06-25 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Reinstated the KMultiTabBarTab and KMultiTabBarButton classes in the Smoke runtime
* It makes more sense to fix the parser to handle arg types starting with
'class '. They are now stripped off and ignored.
2004-06-24 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Removed KMultiTabBarTab and KMultiTabBarButton from the Smoke runtime
* Added an instance variable '_smokeObject' to generated C# Kimono classes
2004-06-09 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* New flags were added for Smoke methods - mf_internal and mf_copyctor.
This allows copy constructors which are only used internally by the ruby
or perl runtime, to be excluded from the standard api.
2004-06-07 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added patch from Michal Ceresna to fix code generation for TQImage.bits() and
TQImage.colorTable()
* Fixed bug reported by Maik Schulz caused by unwanted KListViewItem copy constructor.
An 'enhancement' was added for KDE 3.2 - for any class which didn't have a copy
constructor, but which could still be copied, a copy constructor was generated.
Unfortunately this had unforseen consequences, such as messing up KListView logic,
hence they're no longer generated.
2004-05-27 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* The methods TQPainter::pos() and TQFontInfo::font() are skipped for
Qt2 embedded as they don't link to the ARM version of Qt/E
* Thanks to Fabien Renaud for testing QtJava/E on an ARM box
2004-05-25 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added the correct macro expansion for Q_OBJECT with Qt/E 2.3.x
* kalyptus can now generate the SMOKE library for Qt Embedded
2004-05-22 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* More tweaks to the QtJava Embedded code generation.
The code now compiles without error, links and runs..
* However, the Qt framebuffer emulator plasters the KDE desktop in
lurid green and doesn't seem to have a way of accepting mouse
input. How do you get mouse events into a named pipe that it reads?
2004-05-21 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added code generation for Qt/Embedded 2.3.4 with a '--qte' option to
be used in conjunction with the '-fjni' option.
* Example usage - this command will parse the Qt embedded headers in
directory 'test', and generate the .java and .cpp files in the same dir:
$ kalyptus -fjni -dtest --globspace --qte test/*.h
2004-05-20 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* The java '-fjni' option now generates correct java code with Qt/E 2.3.4
* KMainWindow.toolBar() and KMainWindow.menuBar() rename ktoolBar() and
kmenuBar(). This is because java doesn't have covariant return types
and the methods with the same names in TQMainWindow return a TQToolBar
and TQMenuBar, rather than their KDE equivalent subclasses.
2004-05-19 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Namespaces were being omitted from the SMOKE runtime, and so methods
such as the ones in KStdAction were missing. They are now included and
appear to be ordinary classes containing static methods.
For example, in ruby:
quit = KDE::StdAction.quit( self, SLOT("quit()"), actionCollection() )
2004-04-26 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Now only 55 Qt C# warnings, too much use of the 'new' inheritance directive
though.
2004-04-26 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Reduced the number of compiler warnings for C# Dispose() methods. Now down to
'only' 130 warnings for the Qt classes
2004-04-13 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* When a class includes equality operator overloading, an implementation of
GetHashCode() is generated (along with Equals() too) to avoid compiler warnings.
* If a method was originally inherited via C++ MI, but is now copied from the superclass
to the current class in C# instead, then it isn't labelled with a 'new' modifier
2004-04-12 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Kimono C# code generation improvements
- Added the 'out' modifier for args which are references to mutable primitive types
- Improved doc comment to C# xml comment translation, with <remarks> tags bracketing
the body of the comment
- Enum types are only given a 'E_' prefix if they clash with a C# method name after
the first character has been uppercased
2004-03-26 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Removed quite a few compiler warnings from the C# code generated by -fkimono
- A lot of warnings about virtual methods not needing the 'new' keyword fixed
- If you define operator==, but not operator!= you get a warning.
A smarter compiler might be able to work one out from the other?
But added a corresponding 'operator!=' always.
- If you define operator== or operator!=, you get a warning for not defining
GetHashCode(). There must be some sort of logic in that, but not fixed yet.
2004-03-25 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Removed obsolete C and Objective-C code generation options
2004-03-19 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* 'KDE Integrates Mono'; added -fkimono option to generate C# bindings
* It doens't use the Qt C bindings, like Qt# but the Smoke lib instead
* To generate the code and review the api, edit tdebindings/smoke/kde/generate.pl.in
and change '-fsmoke' to '-fkimono'. Then configure tdebindings with the
'--with-smoke=kde' option. The sources will be generated in smoke/kde.
* It uses custom real proxies as AOP style interceptors, one per instance
and a static interceptor per class.
- Every method call in the api is forwarded to SmokeInvocation.Invoke()
via the proxies, and is effectively a pointcut.
- In Invoke() the method call will be looked up dynamically from the Smoke runtime
- The arguments are marsalled from C# to C++ on the Smoke::Stack, and the method
invoked.
* The KDE doc comments are converted to C# xml style tags (eg KApplication.cs)
* Problems
- A small fix was need for RealProxies with Mono 0.30. DotGnu doesn't have
RealProxies/remoting yet.
- It should be possible to use ContextBoundObjects and custom ContextAttributes
as described here, but they aren't implemented in Mono yet.
http://msdn.microsoft.com/msdnmag/issues/03/03/ContextsinNET/
- In interfaces the 'ref' keyword can't be used
- Doesn't use event handlers as delegates like Qt#, they are just overriden
like normal virtual methods
- Many compiler warnings about 'new virtual' not being needed. Some work needed
to only add new to overriden ones.
2004-02-17 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Aligned the forthcoming KDE 3.3 dynamic proxy/SMOKE library based java
code generation with the current 3.2 JNI based ones (-fjava vs. -fjni).
2004-01-28 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* When two methods differed only in 'constness', it wasn't possible to
resolve which to call from ruby. For example:
KProgress* progressBar();
const KProgress* progressBar() const;
So only the const variant is generated in the Smoke runtime.
2004-01-05 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* When a java method needed to be renamed, because in the type signature
only the return type differed in C++, when that isn't allowed in java,
the JNI function name was not using the new name.
* Fixed error in JNI function names when the C++ method had an underscore.
2003-12-29 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Fixed a problem with parsing one line namespace declarations
* Added support for the QT_WORKSPACE_WINDOWMODE macro, to solve build problem
* Added some more primitive type definitions such as KIO::filesize_t
2003-12-23 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added a '-fjni' option to generate code for the current KDE 3.2 JNI based java
bindings The '-fjava' option generates code for the forthcoming Dynamic
Proxy/Smoke library based java bindings in KDE 3.3.
* The Qt and KDE bindings just checked in were generated by changing the kalyptus
option '-fsmoke' to '-fjni' in tdebindings/smoke/kde/generate.pl.in. Then
configure tdebindings with '--enable-smoke=kde' option to generate the .cpp
and .java sources. The .h files are generated by using javah on the compiled
java .class files.
2003-11-29 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Fixed parsing of casts inside enums in kfileitem.h:
enum { Unknown = (mode_t) - 1 };
Hmm, not sure what that's up to anyway..
* Added a special Source property to method nodes in TQGlobalSpace.
In java, this allows Qt friend methods to be grouped under the
Qt.java class, and KDE ones under KDE.java according to which
source file they originated from.
2003-11-05 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Fixed parsing default argument values cast to a numeric literal, eg:
mode_t mode = (mode_t)-1
* Excluded a couple of structs from kparts/browserextension
2003-11-04 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* KDE MI has some diamond shaped cycles, such as for the children of
KXMLGUIClient. When the code for casts to all the parents of a class
was generated in the Smoke runtime, this meant there were some
duplicate entries in the switch statement. Duplicates now removed.
2003-10-11 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Avoid generating wrappers for private classes with 'Private',
'Impl' or 'Internal' in the name. Other unneeded classes also
dropped.
2003-10-08 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added SmokeKDE namespace class code generation
- Fixed bug in kalyptus where it couldn't detect the end of a namespace
- resolveType() in kalyptusDataDict.pm now looks in parent namespace for symbols
- Namespace enclosed class code generation added to kalyptusCxxToSmoke.pm
2003-09-16 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Added various parser and code generation fixes so that a libsmokekde.so
can be generated from the tdelibs headers.
2003-08-30 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Applied Germain Garand's patch to no longer rename operator methods
@ -16,7 +319,7 @@
2003-08-21 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
* Rewritten java code generation for a Dynamic Proxy based SMOKE adaptor version of TQtJava.
* Rewritten java code generation for a Dynamic Proxy based SMOKE adaptor version of QtJava.
* Based on David Faure's SMOKE generation code in the '-fsmoke' option.
2003-08-11 Richard Dale <Richard_Dale@tipitina.demon.co.uk>
@ -56,7 +359,7 @@
* Perl .pig generation improved
2002-01-25 Richard Dale <duke@tipitina.demon.co.uk>
* Added '-fperl' option to autogenerate .pig (Perl Interface
Generator) files, suitable for generating Ashley Winters' PerlTQt/KDETQt
Generator) files, suitable for generating Ashley Winters' PerlQt/KDEQt
bindings
2002-01-23 Richard Dale <duke@tipitina.demon.co.uk>
* Made dispose() public, added isDisposed() after SWT.

@ -0,0 +1,5 @@
all: configure
configure: configure.in
autoconf

@ -0,0 +1,53 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
perl = @perl@
install = @INSTALL@
bin = kalyptus
pm = kdocUtil.pm kdocAstUtil.pm kdocParseDoc.pm kdocLib.pm \
Ast.pm kalyptusDataDict.pm kalyptusCxxToC.pm \
kalyptusCxxToObjc.pm kalyptusCxxToJava.pm \
kalyptusCxxToSmoke.pm kalyptusCxxToCSharp.pm \
Iter.pm
pmextra =
bindir = ${exec_prefix}/bin
pmdir = ${prefix}/share/kalyptus
srcdocdir= .
VERSION=@Version@
all: kalyptus.local
kalyptus.local: @srcdir@/kalyptus
cp @srcdir@/kalyptus kalyptus.local
perl -npi -e 's%^#\!.*$$%#!'${perl}' -I'${pmdir}'%g;' kalyptus.local
perl -npi -e 's#\$$Version\\\$$#'"${VERSION}"'#g;' kalyptus.local
install: all
${install} -d $(DESTDIR)${bindir}
${install} -m 755 kalyptus.local $(DESTDIR)${bindir}/kalyptus
${install} -d $(DESTDIR)${pmdir}
for file in ${pm} ${pmextra}; do \
${install} -m 644 @srcdir@/$$file $(DESTDIR)${pmdir}; \
done
uninstall:
(cd $(DESTDIR)${bindir} && rm -f ${bin})
(cd $(DESTDIR)${pmdir} && rm -f ${pm})
-rmdir $(DESTDIR)${bindir}
-rmdir $(DESTDIR)${pmdir}
clean:
rm -f kalyptus.local
distclean: clean
rm -f Makefile config.status config.log config.cache perlbin
srcdoc:
pod2html --flush --title KALYPTUS $(bin) $(pm) \
--outfile $(srcdocdir)/kalyptus-doc.html
tags:
perltags kalyptus *.pm
check:
@for dir in $(bin) $(pm); do \
echo "** Checking: $$dir"; \
perl -wc $$dir; done

@ -3,7 +3,7 @@ KALYPTUS -- C, Objective-C and Java bindings generator
Version 0.9
KALYPTUS creates language bindings for TQt and KDE C++ libraries
KALYPTUS creates language bindings for Qt and KDE C++ libraries
directly from the headers. Documentation embedded in special doc
comments in the source is translated to an appropriate format for
the target language.
@ -47,12 +47,12 @@ JAVA
Here are some of the shell commands that were used in the conversion process:
Remove any TTQ_OVERRIDE macros from the TQt headers, and remove EXPORT_DOCKCLASS from the
Remove any Q_OVERRIDE macros from the Qt headers, and remove EXPORT_DOCKCLASS from the
KDE headers
# Generate Java and C++ sources. Copy all the target headers to directory 'test/tmp'
kalyptus -fjava test/tmp/*.h test/tmp/dom/*.h test/tmp/kio/*.h test/tmp/kdeprint/*.h \
test/tmp/kjs/*.h test/tmp/kparts/*.h test/tmp/kdesu/*.h test/ktextedit/*.h test/tmp/libkmid/*.h
kalyptus -fjava test/tmp/*.h test/tmp/dom/*.h test/tmp/kio/*.h test/tmp/tdeprint/*.h \
test/tmp/kjs/*.h test/tmp/kparts/*.h test/tmp/tdesu/*.h test/ktextedit/*.h test/tmp/libkmid/*.h
# Shorten generated filenames
mv DOM__Node.cpp DOMNode.cpp

@ -0,0 +1,28 @@
AC_INIT(kalyptus)
AC_DEFUN(AC_FIND_PERL,
[
AC_MSG_CHECKING(for perl 5 or greater)
if $srcdir/findperl; then
$1=`cat perlbin`
echo $$1
else
echo "Couldn't find perl 5 or later. kdoc will not run."
exit 1
fi
])
AC_DEFUN(AC_KALYPTUS_VERSION,
[
AC_MSG_CHECKING(kalyptus version)
$1=`cat $srcdir/Version | sed 's#Revision##g' | tr -d '\$:'`
echo $$1
])
AC_PROG_INSTALL
AC_FIND_PERL(perl)
AC_SUBST(perl)
AC_KALYPTUS_VERSION(Version)
AC_SUBST(Version)
AC_OUTPUT(Makefile)

@ -0,0 +1,12 @@
#!/bin/sh
if [[ -z $KALYPTUS || ! -d $KALYPTUS ]]
then
echo "Please set enviroment variable KALYPTUS to point to your tdebindings/kaltyptus checkout directory"
exit
fi
perl -I$KALYPTUS $KALYPTUS/kalyptus $2 --allow_k_dcop_accessors -f dcopidl $1 2>/tmp/dcopidlng.stderr.$$
if [[ $? -ne 0 ]]
then
cat /tmp/dcopidlng.stderr.$$
fi
rm /tmp/dcopidlng.stderr.$$

@ -0,0 +1,17 @@
#!/bin/sh
test -f perlbin && rm perlbin
for p in `echo $PATH | tr ":" " "`
do
if [ -x $p/perl ]
then
if $p/perl -e 'require 5.000;'
then
echo $p/perl > perlbin
exit 0
fi
fi
done
exit 1

@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

@ -1,8 +1,8 @@
#!/usr/bin/perl -I/Users/duke/src/kde/kdebindings/kalyptus
#!/usr/bin/perl
# KDOC -- C++ and CORBA IDL interface documentation tool.
# Sirtaj Singh Kang <taj@kde.org>, Jan 1999.
# $Id: kalyptus,v 1.9 2003/08/31 15:35:11 germaingarand Exp $
# $Id$
# All files in this project are distributed under the GNU General
# Public License. This is Free Software.
@ -22,12 +22,12 @@ use kdocParseDoc;
use vars qw/ %rootNodes $declNodeType @includes_list %options @formats_wanted $allow_k_dcop_accessors
@includeclasses $includeclasses $skipInternal %defines $defines $match_qt_defines
$libdir $libname $outputdir @libs $parse_global_space $striphpath $doPrivate $readstdin
$Version $quiet $debug $debuggen $parseonly $currentfile $cSourceNode $exe
$libdir $libname $outputdir @libs $parse_global_space $qt_embedded $qt4 $striphpath $doPrivate $readstdin
$Version $tquiet $debug $debuggen $parseonly $currentfile $cSourceNode $exe
%formats %flagnames @allowed_k_dcop_accesors $allowed_k_dcop_accesors_re $rootNode
@classStack $cNode $globalSpaceClassName
$lastLine $docNode @includes $cpp $defcppcmd $cppcmd $docincluded
$inExtern %stats %definitions @inputqueue @codeqobject /;
$inExtern $inNamespace %stats %definitions @inputqueue @codeqobject @qt4_codeqobject @qte_codeqobject /;
## globals
@ -52,7 +52,7 @@ $includeclasses = "";
$doPrivate = 0;
$Version = "0.9";
$quiet = 0;
$tquiet = 0;
$debug = 0;
$debuggen = 0;
$parseonly = 0;
@ -82,11 +82,36 @@ public:
private:
CODE
@qt4_codeqobject = split "\n", <<CODE;
public:
static const TQMetaObject staticMetaObject;
virtual const TQMetaObject *metaObject() const;
virtual void *qt_metacast(const char *);
static inline TQString tr(const char *s, const char *c = 0)
{ return staticMetaObject.tr(s, c); }
virtual int qt_metacall(TQMetaObject::Call, int, void **);
private:
CODE
@qte_codeqobject = split "\n", <<CODE;
public:
TQMetaObject *metaObject() const {
return staticMetaObject();
}
const char *className() const;
static TQMetaObject* staticMetaObject();
static TQString tr( const char *, const char * = 0 );
protected:
void initMetaObject();
private:
CODE
# Supported formats
%formats = ( "java" => "kalyptusCxxToJava", "c" => "kalyptusCxxToC",
"objc" => "kalyptusCxxToObjc", "dcopidl" => "kalyptusCxxToDcopIDL",
"smoke" => "kalyptusCxxToSmoke", "csharp" => "kalyptusCxxToCSharp",
"ECMA" => "kalyptusCxxToECMA", "swig" => "kalyptusCxxToSwig" );
%formats = ( "java" => "kalyptusCxxToJava", "jni" => "kalyptusCxxToJNI",
"dcopidl" => "kalyptusCxxToDcopIDL",
"smoke" => "kalyptusCxxToSmoke", "csharp" => "kalyptusCxxToCSharp", "kimono" => "kalyptusCxxToKimono",
"ECMA" => "kalyptusCxxToECMA", "swig" => "kalyptusCxxToSwig",
"KDOMECMA" => "kalyptusKDOMEcma");
# these are for expansion of method flags
%flagnames = ( v => 'virtual', 's' => 'static', p => 'pure',
@ -104,22 +129,23 @@ $allowed_k_dcop_accesors_re = join("|", @allowed_k_dcop_accesors);
_STYLE_PLATINUM => '',
_STYLE_SGI => '',
_STYLE_WINDOWS => '',
TQT_STATIC_CONST => 'static const',
TTQ_EXPORT => '',
TTQ_REFCOUNT => '',
QT_STATIC_CONST => 'static const',
Q_EXPORT => '',
Q_EXPORT_CODECS_BIG5 => '',
Q_REFCOUNT => '',
TQM_EXPORT_CANVAS => '',
TQM_EXPORT_DNS => '',
TQM_EXPORT_ICONVIEW => '',
TQM_EXPORT_NETWORK => '',
TQM_EXPORT_SQL => '',
TQM_EXPORT_WORKSPACE => '',
TQT_NO_REMOTE => 'TQT_NO_REMOTE',
TQT_ACCESSIBILITY_SUPPORT => 'TQT_ACCESSIBILITY_SUPPORT',
TTQ_WS_X11 => 'TTQ_WS_X11',
TTQ_DISABLE_COPY => 'TTQ_DISABLE_COPY',
TTQ_WS_TQWS => 'undef',
TTQ_WS_MAC => 'undef',
TTQ_OBJECT => <<'CODE',
QT_NO_REMOTE => 'QT_NO_REMOTE',
QT_ACCESSIBILITY_SUPPORT => 'QT_ACCESSIBILITY_SUPPORT',
Q_WS_X11 => 'Q_WS_X11',
Q_DISABLE_COPY => 'Q_DISABLE_COPY',
Q_WS_QWS => 'undef',
Q_WS_MAC => 'undef',
Q_OBJECT => <<'CODE',
public:
virtual TQMetaObject *metaObject() const;
virtual const char *className() const;
@ -164,6 +190,8 @@ GetOptions( \%options,
"xref|l=s", \@libs,
"classes|c=s", \@includeclasses,
"globspace", \$parse_global_space,
"qte", \$qt_embedded,
"qt4", \$qt4,
"allow_k_dcop_accessors", \$allow_k_dcop_accessors,
"cpp|P", \$cpp,
@ -173,7 +201,7 @@ GetOptions( \%options,
"define=s", \%defines, # define a single preprocessing symbol
"defines=s", \$defines, # file containing preprocessing symbols, one per line
"quiet|q", \$quiet,
"tquiet|q", \$tquiet,
"debug|D", \$debug, # debug the parsing
"debuggen", \$debuggen, # debug the file generation
"parse-only", \$parseonly )
@ -193,7 +221,7 @@ else {
if ($#includeclasses>=0)
{
$includeclasses = join (" ", @includeclasses);
print "Using Classes: $includeclasses\n" unless $quiet;
print "Using Classes: $includeclasses\n" unless $tquiet;
}
if ( $#includes >= 0 && !$cpp ) {
@ -222,13 +250,13 @@ if( $defines )
}
}
# Check the %defines hash for TQT_* symbols and compile the corresponding RE
# Check the %defines hash for QT_* symbols and compile the corresponding RE
# Otherwise, compile the default ones. Used for filtering in readCxxLine.
if ( my @qt_defines = map { ($_=~m/^TQT_(.*)/)[0] } keys %defines)
if ( my @qt_defines = map { ($_=~m/^QT_(.*)/)[0] } keys %defines)
{
my $regexp = "m/^#\\s*ifn?def\\s+TQT_(?:" . join('|', map { "\$qt_defines[$_]" } 0..$#qt_defines).")/o";
my $regexp = "m/^#\\s*ifn?def\\s+QT_(?:" . join('|', map { "\$qt_defines[$_]" } 0..$#qt_defines).")/o";
$match_qt_defines = eval "sub { my \$s=shift;
\$s=~/^#\\s*if(n)?def/ || return 0;
\$s=~/^#\\s*if(n)?def\\s+QT_/ || return 0;
if(!\$1) { return \$s=~$regexp ? 0:1 }
else { return \$s=~$regexp ? 1:0 }
}";
@ -236,18 +264,18 @@ if ( my @qt_defines = map { ($_=~m/^TQT_(.*)/)[0] } keys %defines)
}
else
{
$match_qt_defines = eval q£
$match_qt_defines = eval q{
sub
{
my $s = shift;
$s =~ m/^\#\s*ifndef\s+TQT_NO_(?:REMOTE| # not in the default compile options
$s =~ m/^\#\s*ifndef\s+QT_NO_(?:REMOTE| # not in the default compile options
NIS| # ...
XINERAMA|
IMAGEIO_(?:MNG|JPEG)|
STYLE_(?:MAC|INTERLACE|COMPACT)
)/x;
}
£;
};
die if $@;
}
# Check if there any files to process.
@ -302,7 +330,7 @@ sub readLibraries
require kdocLib;
foreach my $lib ( @libs ) {
print "$exe: reading lib: $lib\n" unless $quiet;
print "$exe: reading lib: $lib\n" unless $tquiet;
my $relpath = exists $options{url} ?
$options{url} : $outputdir;
@ -334,11 +362,11 @@ sub parseFiles
|| croak "Can't preprocess $currentfile";
}
else {
open( INPUT, "$currentfile" )
open( INPUT, "tqt-replace-stream $currentfile |" )
|| croak "Can't read from $currentfile";
}
print STDERR "$exe: processing $currentfile\n" unless $quiet;
print STDERR "$exe: processing $currentfile\n" unless $tquiet;
# reset vars
$rootNode = getRoot( $lang );
@ -356,6 +384,7 @@ sub parseFiles
@classStack = ();
$cNode = $rootNode;
$inExtern = 0;
$inNamespace = 0;
# parse
my $k = undef;
@ -386,7 +415,7 @@ sub writeDocumentation
require $pack.".pm";
print STDERR "Generating bindings for $format ",
"language...\n" unless $quiet;
"language...\n" unless $tquiet;
my $f = "$pack\::writeDoc";
&$f( $libname, $node, $outputdir, \%options );
@ -425,7 +454,7 @@ sub readSourceLine
=head2 readCxxLine
Reads a C++ source line, skipping comments, blank lines,
preprocessor tokens and the TTQ_OBJECT macro
preprocessor tokens and the Q_OBJECT macro
=cut
@ -453,12 +482,31 @@ LOOP:
}
}
if ( $p =~ /^\s*TTQ_OBJECT/ ) {
push @inputqueue, @codeqobject;
if ( $p =~ /^\s*Q_OBJECT/ ) {
if ($qt_embedded) {
push @inputqueue, @qte_codeqobject;
} elsif ($qt4) {
push @inputqueue, @qt4_codeqobject;
} else {
push @inputqueue, @codeqobject;
}
next;
}
# Hack, waiting for real handling of preprocessor defines
$p =~ s/TQT_STATIC_CONST/static const/;
$p =~ s/QT_MODULE\(\w+\)//;
$p =~ s/QT_STATIC_CONST/static const/;
$p =~ s/QT_WEAK_SYMBOL//;
$p =~ s/QT_MOC_COMPAT//;
$p =~ s/Q_EXPORT_CODECS_BIG5//;
$p =~ s/QT_COMPAT / /;
$p =~ s/Q_DISABLE_COPY\((\w+)\)/$1(const $1 &);\n$1 &operator=(const $1 &);/;
$p =~ s/TQWIDGETSIZE_MAX/32767/; # Qt/E uses this #define as an enum value - yuck!
$p =~ s/Q_SIGNALS/signals/;
$p =~ s/ASYNC/void/;
$p =~ s/[A-Z_]*_EXPORT_DEPRECATED//;
$p =~ s/[A-Z_]*_EXPORT\s/ /;
$p =~ s/EXPORT_DOCKCLASS//;
$p =~ s/DLL_IMP_EXP_KMDICLASS//;
$p =~ s/KSVG_GET/KJS::Value get();/;
$p =~ s/KSVG_BASECLASS_GET/KJS::Value get();/;
$p =~ s/KSVG_BRIDGE/KJS::ObjectImp *bridge();/;
@ -469,20 +517,44 @@ LOOP:
if ( $p =~ m/KSVG_DEFINE_PROTOTYPE\((\w+)\)/ ) {
push @inputqueue, split('\n',"namespace KSVG {\nclass $1 {\n};\n};");
}
# Bother the same again for KDOM :/
$p =~ s/KDOM_GET/KJS::Value get();/;
$p =~ s/KDOM_BASECLASS_GET/KJS::Value get();/;
$p =~ s/KDOM_FORWARDGET/KJS::Value getforward();/;
$p =~ s/KDOM_PUT/bool put();/;
$p =~ s/KDOM_FORWARDPUT/bool putforward();/;
$p =~ s/KDOM_BASECLASS/virtual KJS::Value cache();/;
$p =~ s/KDOM_CAST/KJS::Value cast();/;
if ( $p =~ m/KDOM_DEFINE_PROTOTYPE\((\w+)\)/ ) {
push @inputqueue, split('\n',"namespace KDOM {\nclass $1 {\n};\n};");
}
next if ( $p =~ /^\s*$/s ); # blank lines
# || $p =~ /^\s*TTQ_OBJECT/ # TQObject macro
# || $p =~ /^\s*Q_OBJECT/ # TQObject macro
# );
#
next if ( $p =~ /^\s*TTQ_ENUMS/ # ignore TTQ_ENUMS
|| $p =~ /^\s*TTQ_PROPERTY/ # and TTQ_PROPERTY
|| $p =~ /^\s*TTQ_OVERRIDE/ # and TTQ_OVERRIDE
|| $p =~ /^\s*TTQ_SETS/
|| $p =~ /^\s*TTQ_DUMMY_COMPARISON_OPERATOR/
next if ( $p =~ /^\s*Q_ENUMS/ # ignore Q_ENUMS
|| $p =~ /^\s*TQ_OBJECT/ # and TQ_OBJECT
|| $p =~ /^\s*Q_FLAGS/ # and Q_FLAGS
|| $p =~ /^\s*Q_DECLARE_FLAGS/ # and Q_DECLARE_FLAGS
|| ( !$qt4 && $p =~ /^\s*Q_PROPERTY/ ) # and Q_PROPERTY
|| $p =~ /^\s*TQDOC_PROPERTY/
|| $p =~ /^\s*Q_GADGET/
|| $p =~ /^\s*Q_OVERRIDE/ # and Q_OVERRIDE
|| $p =~ /^\s*Q_SETS/
|| $p =~ /^\s*Q_DUMMY_COMPARISON_OPERATOR/
|| $p =~ /^\s*K_SYCOCATYPE/ # and K_SYCOCA stuff
|| $p =~ /^\s*K_SYCOCAFACTORY/ #
|| $p =~ /^\s*KSVG_/ # and KSVG stuff ;)
|| $p =~ /^\s*KDOM_/ # and KDOM stuff :(
|| $p =~ /^\s*Q_DECLARE_FLAGS/
|| $p =~ /^\s*Q_DECLARE_OPERATORS_FOR_FLAGS/
|| $p =~ /^\s*Q_DECLARE_PRIVATE/
|| $p =~ /^\s*Q_DECLARE_TYPEINFO/
|| $p =~ /^\s*Q_PRIVATE_SLOT/
|| $p =~ /^\s*Q_DECLARE_SHARED/
);
push @includes_list, $1 if $p =~ /^#include\s+<?(.*?)>?\s*$/;
@ -503,14 +575,31 @@ LOOP:
else {
# Skip platform-specific stuff, or #if 0 stuff
# or #else of something we parsed (e.g. for TQKeySequence)
if ( $p =~ m/^#\s*ifdef\s*TTQ_WS_/ or
$p =~ m/^#\s*if\s+defined\(TTQ_WS_/ or
$p =~ m/^#\s*if\s+defined\(TTQ_OS_/ or
$p =~ m/^#\s*if\s+defined\(TTQ_CC_/ or
$p =~ m/^#\s*if\s+defined\(TQT_THREAD_SUPPORT/ or
if ( $p =~ m/^#\s*ifdef\s*Q_WS_/ or
$p =~ m/^#\s*if\s+defined\(Q_WS_/ or
($p =~ m/^#\s*ifdef\s+_WS_QWS_/ and $qt_embedded) or
($p =~ m/^#\s*ifndef\s+QT_NO_MIMECLIPBOARD/ and $qt_embedded) or
($p =~ m/^#\s*if\s+defined\(_WS_X11_/ and $qt_embedded) or
($p =~ m/^#\s*if\s+defined\(Q_WS_X11_/ and $qt_embedded) or
($p =~ m/^#\s*if\s+defined\(Q_WS_WIN_/ and $qt_embedded) or
($p =~ m/^#\s*if\s+defined\(_WS_MAC_/ and $qt_embedded) or
($p =~ m/^#\s*if\s+defined\(Q_INCOMPATIBLE_3_0_ADDONS/ and $qt_embedded) or
$p =~ m/^#\s*ifndef\s+QT_NO_STL/ or
$p =~ m/^#\s*if\s+defined\s*\(Q_OS_/ or
$p =~ m/^#\s*if\s+defined\(Q_CC_/ or
$p =~ m/^#\s*if\s+defined\(QT_THREAD_SUPPORT/ or
$p =~ m/^#\s*else/ or
$p =~ m/^#\s*if\s+defined\(TTQ_FULL_TEMPLATE_INSTANTIATION/ or
$p =~ m/^#\s*if\s+defined\(Q_FULL_TEMPLATE_INSTANTIATION/ or
$p =~ m/^#\s*ifdef\s+QT_WORKSPACE_WINDOWMODE/ or
$p =~ m/^#\s*ifdef\s+QT_COMPAT/ or
$p =~ m/^#\s*if\s+defined\s*\(?QT_COMPAT/ or
$p =~ m/^#\s*ifdef\s+CONTAINER_CUSTOM_WIDGETS/ or
$p =~ m/^#\s*ifdef\s+QT3_SUPPORT/ or
$p =~ m/^#\s*ifdef\s+Q_MOC_RUN/ or
$p =~ m/^#\s*if\s+defined\s*\(QT3_SUPPORT/ or
$p =~ m/^#\s*if\s+defined\s*\(qdoc/ or
$p =~ m/^#\s*ifndef\s+QT_NO_MEMBER_TEMPLATES/ or
$p =~ m/^#if\s*!defined\(Q_NO_USING_KEYWORD\)/ or
&$match_qt_defines( $p ) or
$p =~ m/^#\s*if\s+0\s+/ ) {
my $if_depth = 1;
@ -519,7 +608,7 @@ LOOP:
last if !defined $p;
$if_depth++ if $p =~ m/^#\s*if/;
$if_depth-- if $p =~ m/^#\s*endif/;
# Exit at #else in the #ifdef TQT_NO_ACCEL/#else/#endif case
# Exit at #else in the #ifdef QT_NO_ACCEL/#else/#endif case
last if $if_depth == 1 && $p =~ m/^#\s*else\s/;
#ignore elif for now
print "Skipping ifdef'ed line: $p" if $debug;
@ -638,6 +727,9 @@ sub readDecl
$declNodeType = "c";
return $l;
}
elsif ( $l =~ /Q_PROPERTY/ ) { # property
return $l;
}
do {
$decl .= $l;
@ -694,7 +786,11 @@ sub identifyDecl
my $newNode = undef;
my $skipBlock = 0;
my $isDeprecated = 0;
if ( $decl =~ s/KDE_DEPRECATED// ) {
$isDeprecated = 1;
}
# Doc comment
if ( $declNodeType eq "c" ) {
$docNode = kdocParseDoc::newDocComment( $decl );
@ -713,7 +809,12 @@ sub identifyDecl
elsif ( $declNodeType eq "k" ) {
$cNode->AddProp( "DcopExported", 1 );
}
# properties
elsif ( $decl =~ s/Q_PROPERTY// ) {
print "Property: <$1>\n" if $debug;
$newNode = newProperty( $decl );
}
# Typedef struct/class
elsif ( $decl =~ /^\s*typedef
\s+(struct|union|class|enum)
@ -737,8 +838,8 @@ sub identifyDecl
# Typedef
elsif ( $decl =~ /^\s*typedef\s+
(?:typename\s+)? # `typename' keyword
(.*?\s*[\*&]?) # type
\s+([-\w_\:]+) # name
(.*?\s*[\*&>]?) # type
\s*([-\w_\:]+) # name
\s*((?:\[[-\w_\:<>\s]*\])*) # array
\s*[{;]\s*$/xs ) {
@ -758,15 +859,16 @@ sub identifyDecl
# Class/Struct
elsif ( $decl =~ /^\s*((?:template\s*<.*>)?) # 1 template
\s*(class|struct|union|namespace) # 2 struct type
(?:\s*TQ[A-Z_]*EXPORT[A-Z_]*)?
(?:\s*Q[A-Z_]*EXPORT[A-Z_]*)?
(?:\s*TTQ_PACKED)?
(?:\s*TTQ_REFCOUNT)?
(?:\s*Q_PACKED)?
(?:\s*Q_REFCOUNT)?
\s+([\w_]+ # 3 name
(?:<[\w_ :,]+?>)? # maybe explicit template
# (eat chars between <> non-hungry)
(?:::[\w_]+)* # maybe nested
)
(.*?) # 4 inheritance
([^\(]*?) # 4 inheritance
([;{])/xs ) { # 5 rest
print "Class: [$1]\n\t[$2]\n\t[$3]\n\t[$4]\n\t[$5]\n" if $debug;
@ -781,7 +883,14 @@ sub identifyDecl
}
}
if ($ntype eq 'namespace') {
if ($decl =~ /}/) {
return 0;
}
# Set a flag to indicate we're in a multi-line namespace declaration
$inNamespace = 1;
}
my @inherits = ();
$tmpl =~ s/<(.*)>/$1/ if $tmpl ne "";
@ -793,7 +902,15 @@ sub identifyDecl
}
$newNode = newClass( $tmpl, $ntype,
$name, $endtag, @inherits );
$name, $endtag, $isDeprecated, @inherits );
if ($decl =~ /};/) {
# If the declaration was all on one line ending with a '};',
# then pop the new node
$cNode = pop @classStack;
print "end decl: popped $cNode->{astNodeName}\n"
if $debug;
}
}
# IDL compound node
elsif( $decl =~ /^\s*(module|interface|exception) # struct type
@ -819,9 +936,10 @@ sub identifyDecl
$newNode = newIDLstruct( $type, $name, $fwd, $complete, @in );
}
# Method
elsif ( $decl =~ /^\s*([^=]+?(?:operator\s*(?:\(\)|.?=)\s*)?) # ret+nm
elsif ( $decl =~ /^\s*(?:(?:class|struct)\s*)?([^=]+?(?:operator\s*(?:\(\)|.?=)\s*)?) # ret+nm
\( (.*?) \) # parameters
\s*((?:const)?)\s*
(?:throw\s*\(.*?\))?
\s*((?:=\s*0(?:L?))?)\s* # Pureness. is "0L" allowed?
\s*[;{]+/xs ) { # rest
@ -836,16 +954,17 @@ sub identifyDecl
my $const = $3 eq "" ? 0 : 1;
my $pure = $4 eq "" ? 0 : 1;
$tpn =~ s/\s+/ /g;
$tpn =~ s/operator\s+([^\w])/operator$1/g;
$params =~ s/\s+/ /g;
print "Method: R+N:[$tpn]\n\tP:[$params]\n\t[$const]\n" if $debug;
if ( $tpn =~ /((?:\w+\s*::\s*)?operator.*?)\s*$/ # operator
|| $tpn =~ /((?:\w*\s*::\s*~?)?[-\w:]+)\s*$/ ) { # normal
|| $tpn =~ /((?:\w*\s*::\s*~?)?[-\w:]+)\s*$/ ) { # normal
my $name = $1;
$tpn = $`;
$newNode = newMethod( $tpn, $name,
$params, $const, $pure );
$params, $const, $pure, $isDeprecated );
}
$skipBlock = 1; # FIXME check end token before doing this!
@ -877,8 +996,10 @@ sub identifyDecl
my $val = $4;
my $end = $5;
if ( $type !~ /^friend\s+class\s*/ ) {
print "Var: [$name] type: [$type$arr] val: [$val]\n"
$type =~ s/\s+/ /g;
if ( $type !~ /^friend\s+class\s*/ && $type.$name ne "struct" ) {
print "Var: [$name] type: [$type$arr] val: [$val]\n"
if $debug;
$newNode = newVar( $type.$arr, $name, $val );
@ -931,12 +1052,11 @@ sub identifyDecl
$skipBlock = 1 if $end eq '{';
}
# end of an "extern" block
elsif ( $decl =~ /^\s*}\s*$/ ) {
elsif ( $decl =~ /^\s*}\s*$/ && $inExtern ) {
$inExtern = 0;
}
# end of an in-block declaration
elsif ( $decl =~ /^\s*}\s*(.*?)\s*;\s*$/ ) {
elsif ( $decl =~ /^\s*}\s*(.*?)\s*;\s*$/ || ($decl =~ /^\s*}\s*$/ && $inNamespace) ) {
if ( $cNode->{astNodeName} eq "--" ) {
# structure typedefs should have no name preassigned.
# If they do, then the name in
@ -950,6 +1070,11 @@ sub identifyDecl
$siblings->{ $1 } = $cNode;
}
# C++ namespaces end with a '}', and not '};' like classes
if ($decl =~ /^\s*}\s*$/ ) {
$inNamespace = 0;
}
if ( $#classStack < 0 ) {
confess "close decl found, but no class in stack!" ;
$cNode = $rootNode;
@ -966,9 +1091,13 @@ sub identifyDecl
$skipBlock = 1;
}
# explicit template instantiation, or friend template
elsif ( $decl =~ /(template|friend)\s+class\s+(?:Q[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) {
elsif ( $decl =~ /(template|friend)\s+class\s+(?:TQ[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) {
# Nothing to be done with those.
}
# explicit template instantiation, or friend template
elsif ( $decl =~ /(template|friend)\s+class\s+(?:Q[A-Z_]*EXPORT[A-Z_]*\s*)?\w+\s*<.*>\s*;/x ) {
# Nothing to be done with those (same as above, but for QT not TQT).
}
else {
## decl is unidentified.
@ -1060,13 +1189,15 @@ sub initEnum
($name = $end) if $name eq "" && $end ne "";
$params =~ s#\s+# #sg; # no newlines
$params =~ s#\s*/\*([^\*]/|\*[^/]|[^\*/])*\*/##g; # strip out comments
$params = $1 if $params =~ /^\s*{?(.*)}/;
$params =~ s/,\s*$/ /;
print "$name params: [$params]\n" if $debug;
my ( $node ) = Ast::New( $name );
$node->AddProp( "NodeType", "enum" );
$node->AddProp( "Params", $params );
$node->AddProp( "Source", $cSourceNode );
makeParamList( $node, $params, 1 ); # Adds the ParamList property containing the list of param nodes
kdocAstUtil::attachChild( $cNode, $node );
@ -1125,7 +1256,7 @@ sub newIDLstruct
=head2 newClass
Parameters: tmplArgs, cNodeType, name, endTag, @inheritlist
Parameters: tmplArgs, cNodeType, name, endTag, isDeprecated, @inheritlist
Handles a class declaration (also fwd decls).
@ -1133,7 +1264,7 @@ sub newIDLstruct
sub newClass
{
my( $tmplArgs, $cNodeType, $name, $endTag ) = @_;
my( $tmplArgs, $cNodeType, $name, $endTag, $isDeprecated ) = @_;
my $access = "private";
$access = "public" if $cNodeType ne "class";
@ -1150,6 +1281,8 @@ sub newClass
$node->AddProp( "KidAccess", $access );
kdocAstUtil::attachChild( $cNode, $node );
}
# Discard any doc comment against a forward decl
undef $docNode;
return $node;
}
@ -1160,17 +1293,23 @@ sub newClass
$node->AddProp( "NodeType", $cNodeType );
$node->AddProp( "Compound", 1 );
$node->AddProp( "Source", $cSourceNode );
if ($cNodeType eq 'namespace') {
$node->AddPropList( "Sources", $cSourceNode );
}
$node->AddProp( "KidAccess", $access );
$node->AddProp( "Tmpl", $tmplArgs ) unless $tmplArgs eq "";
$node->AddProp( "Deprecated", $isDeprecated );
if ( !defined $oldnode ) {
kdocAstUtil::attachChild( $cNode, $node );
}
# inheritance
foreach my $ances ( splice (@_, 4) ) {
foreach my $ances ( splice (@_, 5) ) {
my $type = "";
my $name = $ances;
my $intmpl = undef;
@ -1323,7 +1462,7 @@ sub newTypedefComp
=head2 newMethod
Parameters: retType, name, params, const, pure?
Parameters: retType, name, params, const, pure?, deprecated?
Handles a new method declaration or definition.
@ -1334,7 +1473,7 @@ my $theSourceNode = $cSourceNode;
sub newMethod
{
my ( $retType, $name, $params, $const, $pure ) = @_;
my ( $retType, $name, $params, $const, $pure, $deprecated ) = @_;
my $parent = $cNode;
my $class;
@ -1405,9 +1544,12 @@ sub newMethod
$opsNode->AddProp( "KidAccess", "public" );
kdocAstUtil::attachChild( $cNode, $opsNode );
}
# Add a special 'Source' property for methods in global space
$cNode->AddProp( "Source", $theSourceNode );
unless( $theSourceNode == $cSourceNode ) {
$theSourceNode = $cSourceNode;
$opsNode->AddPropList( "Sources", $theSourceNode ); # sources are scattered across TQt
$opsNode->AddPropList( "Sources", $theSourceNode ); # sources are scattered across Qt
}
$parent = $opsNode;
}
@ -1434,6 +1576,11 @@ sub newMethod
$retType =~ s/virtual//g;
}
if( $retType =~ /explicit\s*/ ) {
$flags .= "t";
$retType =~ s/explicit\s*//g;
}
print "\n" if $flags ne "" && $debug;
if ( !defined $parent->{KidAccess} ) {
@ -1458,11 +1605,14 @@ sub newMethod
$flags .= "n";
}
$retType =~ s/TQM?_EXPORT[_A-Z]*\s*//;
$retType =~ s/QM?_EXPORT[_A-Z]*\s*//;
$retType =~ s/inline\s+//;
$retType =~ s/extern\s+//;
$retType =~ s/^\s*//g;
$retType =~ s/\s*$//g;
$retType =~ s/^class\s/ /; # Remove redundant class forward decln's
$retType =~ s/<class\s/</;
# node
@ -1472,10 +1622,13 @@ sub newMethod
$node->AddProp( "ReturnType", $retType );
$node->AddProp( "Params", $params ); # The raw string with the whole param list
makeParamList( $node, $params, 0 ); # Adds the ParamList property containing the list of param nodes
$node->AddProp( "Deprecated", $deprecated );
$parent->AddProp( "Pure", 1 ) if $pure;
kdocAstUtil::attachChild( $parent, $node );
return $node;
}
@ -1505,7 +1658,8 @@ sub makeParamList($$$)
{
my ( $methodNode, $params, $isEnum ) = @_;
$params =~ s/\s+/ /g; # normalize multiple spaces/tabs into a single one
$params =~ s/\s*([,\*\&])\s*/$1 /g; # normalize spaces before and after *, & and ','
$params =~ s/\s*([\*\&])\s*/$1 /g; # normalize spaces before and after *, &
$params =~ s/\s*(,)([^'\s])\s*/$1 $2/g; # And after ',', but not if inside single quotes
$params =~ s/^\s*void\s*$//; # foo(void) ==> foo()
$params =~ s/^\s*$//;
# Make sure the property always exists, makes iteration over it easier
@ -1520,12 +1674,19 @@ sub makeParamList($$$)
my $defaultparam;
$arg =~ s/\s*([^\s].*[^\s])\s*/$1/; # stripWhiteSpace
$arg =~ s/(\w+)\[\]/\* $1/; # Turn [] array into *
$arg =~ s/^class //; # Remove any redundant 'class' forward decln's
# The RE below reads as: = ( string constant or char
# The RE below reads as: = ( string constant or char or cast to numeric literal
# or some word/number, with optional bitwise shifts, OR'ed or +'ed flags, and/or function call ).
if ( $arg =~ s/\s*=\s*(("[^\"]*")|(\'.\')|(([-\w:~]*)\s*([<>\|\+-]*\s*\w*\s*)*(\([^(]*\))?))// ) {
if ( $arg =~ s/\s*=\s*(("[^\"]*")|\([^)]*\)\s*[\+-]?\s*[0-9]+|(\'.\')|(([-\w:~]*)\s*([<>\|\+-]*\s*[\w:._]*\s*)*(\([^(]*\))?))// ) {
$defaultparam = $1;
}
if (defined $defaultparam && $isEnum) {
# Remove any casts in enum values, for example this in kfileitem.h:
# 'enum { Unknown = (mode_t) - 1 };'
$defaultparam =~ s/\([^\)]+\)(.*[0-9].*)/$1/;
}
# Separate arg type from arg name, if the latter is specified
if ( $arg =~ /(.*)\s+([\w_]+)\s*$/ || $arg =~ /(.*)\(\s*\*\s([\w_]+)\)\s*\((.*)\)\s*$/ ) {
@ -1611,6 +1772,36 @@ sub newVar
return $node;
}
=head2 newProperty
Parameters: property
Handles a property
=cut
sub newProperty
{
my ( $property ) = @_;
$property =~ s/^\s+|\s+$//g;
my @items = split(/ /,$property);
do {
my ( $node ) = Ast::New( $items[1] );
$node->AddProp( "NodeType", "property" );
$node->AddProp( "type", $items[0] );
$node->AddProp( "READ", $items[3] );
$node->AddProp( "WRITE", $items[5] );
$node->AddProp( "NOTIFY", $items[7] );
$cNode->{KidAccess} = "public";
kdocAstUtil::attachChild( $cNode, $node );
return $node;
} if defined $items[1];
}
=head2 show_usage

@ -0,0 +1,62 @@
# You might want to change the next 2 lines, the rest should be ok
%define qtdir /usr/lib/qt-3.0.0
Prefix: /opt/trinity
Name: kalyptus
Icon: kde-icon.xpm
Summary: Bindings generation tools for the K Desktop Environment (KDE) 3.0.
Version: @VERSION@
Release: 1
Epoch: 1
#Source: ftp://ftp.kde.org/pub/kde/stable/%{version}/distribution/tar/generic/source/kdoc-%{version}.tar.bz2
Group: Bindings
BuildRoot: /var/tmp/%{name}-buildroot
Copyright: GPL
BuildArch: noarch
%description
Bindings generation tools for the K Desktop Environment 3.0.
%prep
rm -rf $RPM_BUILD_ROOT
%setup -q -n %{name}
make -f Makefile.cvs
%build
export TDEDIR=%{prefix} QTDIR=%{qtdir}
CXXFLAGS="$RPM_OPT_FLAGS -I%{prefix}/include/kde" ./configure \
--prefix=%{prefix}
make CXXFLAGS="$RPM_OPT_FLAGS -DNO_DEBUG -DNDEBUG"
%install
make install DESTDIR=$RPM_BUILD_ROOT
cd $RPM_BUILD_ROOT
find . -type d | sed '1,3d;s,^\.,\%attr(-\,root\,root) \%dir ,' > \
$RPM_BUILD_DIR/file.list.%{name}
perl -pi -e "s|\%attr\(-,root,root\) \%dir %{prefix}/man/man1||" $RPM_BUILD_DIR/file.list.%{name}
perl -pi -e "s|\%attr\(-,root,root\) \%dir %{prefix}/man||" $RPM_BUILD_DIR/file.list.%{name}
perl -pi -e "s|\%attr\(-,root,root\) \%dir %{prefix}/bin||" $RPM_BUILD_DIR/file.list.%{name}
perl -pi -e "s|\%attr\(-,root,root\) \%dir %{prefix}/lib$||" $RPM_BUILD_DIR/file.list.%{name}
find . -type f | sed -e 's,^\.,\%attr(-\,root\,root) ,' \
-e '/\/config\//s|^|%config|' >> \
$RPM_BUILD_DIR/file.list.%{name}
find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> \
$RPM_BUILD_DIR/file.list.%{name}
sed -e "s,%{prefix}/man/.*,&*,g" $RPM_BUILD_DIR/file.list.%{name} >$RPM_BUILD_DIR/file.list.%{name}.new
mv -f $RPM_BUILD_DIR/file.list.%{name}.new $RPM_BUILD_DIR/file.list.%{name}
echo "%docdir %{prefix}/doc/kde" >> $RPM_BUILD_DIR/file.list.%{name}
%clean
rm -rf $RPM_BUILD_ROOT $RPM_BUILD_DIR/file.list.%{name}
%files -f ../file.list.%{name}
%changelog
* Thu May 11 2000 Bernhard Rosenkraenzer <bero@redhat.com>
- initial

@ -0,0 +1,764 @@
#***************************************************************************
# copyright : (C) 2000-2001 Lost Highway Ltd. All Rights Reserved.
# (C) 2002 Adam Treat. All Rights Reserved.
# email : manyoso@yahoo.com
# author : Adam Treat & Richard Dale.
#***************************************************************************/
#/***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
#***************************************************************************/
package kalyptusCxxToCSharp;
use File::Path;
use File::Basename;
use Carp;
use Ast;
use kdocAstUtil;
use kdocUtil;
use Iter;
use kalyptusDataDict;
use strict;
no strict "subs";
use vars qw/ @clist $host $who $now $gentext %functionId $docTop
$lib $rootnode $outputdir $opt $debug $typeprefix $eventHandlerCount
$pastaccess $pastname $pastreturn $pastparams $nullctor $constructorCount *CLASS *HEADER *TQTCTYPES *KDETYPES /;
BEGIN
{
@clist = ();
# Page footer
$who = kdocUtil::userName();
$host = kdocUtil::hostName();
$now = localtime;
$gentext = "$who using kalyptus $main::Version.";
$docTop =<<EOF
// begin : $now
// copyright : (C) 2002 Adam Treat. All rights reserved.
// email : manyoso\@yahoo.com
// generated by : $gentext
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
EOF
}
sub cplusplusToCSharp
{
my ( $cplusplusType ) = @_;
if ( $cplusplusType =~ /bool/ && kalyptusDataDict::ctypemap($cplusplusType) eq "int" ) {
return "bool";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*void\s*\**/ ) {
return "int";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*int\s*\&*/ ) {
return "int";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*int\s*\*/) {
return "int[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*double\s*\*/ ) {
return "double[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*short\s*\*/ ) {
return "short[]";
} elsif ( $cplusplusType =~ /TQByteArray/ || $cplusplusType =~ /TQBitArray/ ) {
return "byte[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*char\s*\*\*/ ) {
return "string[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*char\s*\**/ ) {
return "string";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned int\s*\**/ ) {
return "uint";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned short\s*\**/ ) {
return "ushort";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned long\s*\**/ ) {
return "ulong";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned char\s*\**/ ) {
return "string";
} elsif ( $cplusplusType =~ /^GUID/ ) {
return "System.Guid";
} elsif ( $cplusplusType =~ /^FILE/ ) {
return "string";
} elsif ( $cplusplusType =~ /^_NPStream/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQPtrCollection/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQStyleHintReturn/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^type/i ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^Key/ || $cplusplusType =~ /^key_type/ || $cplusplusType =~ /^K/) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQUnknownInterface/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^GDHandle/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQTextParag/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQDiskFont/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQDomNodePrivate/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^Display/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQUuid/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^Q_REFCOUNT/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^EventRef/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^MSG/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQWSEvent/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^XEvent/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^CGContextRef/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQWSDecoration/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQTextFormat/ || $cplusplusType =~ /^TQTextDocument/ || $cplusplusType =~ /^TQTextCursor/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^TQSqlRecordPrivate/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^Text/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^Event/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /^NavDirection/ ) {
return "IntPtr";
} elsif (
$cplusplusType =~ /^pointer$/
|| $cplusplusType =~/T\*$/
|| $cplusplusType =~/T\&*$/
|| $cplusplusType =~/T1\&*$/
|| $cplusplusType =~/T2\&*$/
|| $cplusplusType =~/^Iterator/i
|| $cplusplusType =~/^_iterator/i
|| $cplusplusType =~/^reference/
|| $cplusplusType =~/^_reference/) {
return "IntPtr";
} elsif ($cplusplusType =~ /::/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /::/ ||
$cplusplusType =~ /&$/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /&$/ ||
$cplusplusType =~ /\*/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /\*/) {
$cplusplusType =~ s/::/./g;
$cplusplusType =~ s/&//g;
$cplusplusType =~ s/\*//g;
return $cplusplusType;
} else {
return kalyptusDataDict::ctypemap($cplusplusType);
}
}
sub cplusplusToPInvoke
{
my ( $cplusplusType ) = @_;
if ( $cplusplusType =~ /bool/ && kalyptusDataDict::ctypemap($cplusplusType) eq "int" ) {
return "bool";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*void\s*\*/ ) {
return "int";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*int\s*\&*/ ) {
return "int";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*int\s*\*/) {
return "int[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*double\s*\*/ ) {
return "double[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*short\s*\*/ ) {
return "short[]";
} elsif ( $cplusplusType =~ /TQByteArray/ || $cplusplusType =~ /TQBitArray/ ) {
return "byte[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*char\s*\*\*/ ) {
return "string[]";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*char\s*\**/ ) {
return "string";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned int\s*\**/ ) {
return "uint";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned short\s*\**&*/ ) {
return "ushort";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned long\s*\**/ ) {
return "ulong";
} elsif ( kalyptusDataDict::ctypemap($cplusplusType) =~ /\s*unsigned char\s*\**/ ) {
return "string";
} elsif ( $cplusplusType =~ /^GUID/ ) {
return "System.Guid";
} elsif ( $cplusplusType =~ /^FILE/ ) {
return "string";
} elsif ( $cplusplusType =~ /^_NPStream/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQPtrCollection/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQStyleHintReturn/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^type/i ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^Key/ || $cplusplusType =~ /^key_type/ || $cplusplusType =~ /^K/) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQUnknownInterface/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^GDHandle/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQTextParag/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQDiskFont/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQDomNodePrivate/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^Display/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQUuid/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^Q_REFCOUNT/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^EventRef/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^MSG/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQWSEvent/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^XEvent/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^CGContextRef/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQWSDecoration/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQTextFormat/ || $cplusplusType =~ /^TQTextDocument/ || $cplusplusType =~ /^TQTextCursor/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^TQSqlRecordPrivate/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^Text/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^Event/ ) {
return "RawObject";
} elsif ( $cplusplusType =~ /^NavDirection/ ) {
return "RawObject";
} elsif (
$cplusplusType =~ /^pointer$/
|| $cplusplusType =~/T\*$/
|| $cplusplusType =~/T\&*$/
|| $cplusplusType =~/T1\&*$/
|| $cplusplusType =~/T2\&*$/
|| $cplusplusType =~/^iterator/i
|| $cplusplusType =~/^_iterator/i
|| $cplusplusType =~/^reference/
|| $cplusplusType =~/^_reference/) {
return "RawObject";
} elsif ( $cplusplusType =~ /&$/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /&$/ ) {
return "IntPtr";
} elsif ( $cplusplusType =~ /\*/ || kalyptusDataDict::ctypemap($cplusplusType) =~ /\*/ ) {
return "IntPtr";
} else {
return kalyptusDataDict::ctypemap($cplusplusType);
}
}
sub checkReserved
{
my ( $name ) = @_;
if ( $name =~ /^lock$/i ) {
return "res_$name";
} elsif ( $name =~ /^object$/i ) {
return "res_$name";
} elsif ( $name =~ /^ref$/i ) {
return "res_$name";
} elsif ( $name =~ /^base$/i ) {
return "res_$name";
} elsif ( $name =~ /^string$/i ) {
return "res_$name";
} elsif ( $name =~ /^const$/i ) {
return "res_$name";
} elsif ( $name =~ /^event$/i ) {
return "res_$name";
} elsif ( $name =~ /^internal$/i ) {
return "res_$name";
} else {
return $name;
}
}
sub writeDoc
{
( $lib, $rootnode, $outputdir, $opt ) = @_;
$debug = $main::debuggen;
mkpath( $outputdir ) unless -f $outputdir;
# Document all compound nodes
Iter::LocalCompounds( $rootnode, sub { writeClassDoc( shift ); } );
}
sub writeClassDoc
{
my( $node ) = @_;
print "Enter: $node->{astNodeName}\n" if $debug;
if( exists $node->{ExtSource} ) {
warn "Trying to write doc for ".$node->{AstNodeName}.
" from ".$node->{ExtSource}."\n";
return;
}
my $typeName = $node->{astNodeName}."*";
if ( kalyptusDataDict::ctypemap($typeName) eq "" ) {
$typeprefix = ($typeName =~ /^Q/ ? "qt_" : "kde_");
kalyptusDataDict::setctypemap($typeName, $typeprefix.$node->{astNodeName}."*");
print "'$typeName' => '$typeprefix$typeName',\n";
} elsif ( kalyptusDataDict::ctypemap($typeName) =~ /^qt_/ ) {
$typeprefix = "qt_";
} elsif ( kalyptusDataDict::ctypemap($typeName) =~ /^kde_/ ) {
$typeprefix = "kde_";
} else {
$typeprefix = "kde_";
}
my $file = "$outputdir/".join("__", kdocAstUtil::heritage($node)).".cs";
my $docnode = $node->{DocNode};
my @list = ();
my $version = undef;
my $author = undef;
if( $#{$node->{Kids}} < 0 || $node->{Access} eq "private") {
return;
}
open( CLASS, ">$file" ) || die "Couldn't create $file\n";
$file =~ s/\.h/.cpp/;
my $short = "";
my $extra = "";
print CLASS "// ", $node->{astNodeName}, ".cs - ", $node->{astNodeName}, " c-sharp implementation.";
print CLASS $docTop;
print CLASS "\nnamespace Qt {";
print CLASS "\n\n\tusing Qt;";
print CLASS "\n\tusing System;";
print CLASS "\n\tusing System.Runtime.InteropServices;";
# ancestors
my @ancestors = ();
Iter::Ancestors( $node, $rootnode, undef, undef,
sub { # print
my ( $ances, $name, $type, $template ) = @_;
push @ancestors, $name;
},
undef
);
if ( $#ancestors < 0 ) {
print CLASS "\n\n\tpublic class ", $node->{astNodeName}, " : QtSupport {";
if ( kalyptusDataDict::interfacemap($node->{astNodeName}) ne () ) {
$file = "$outputdir/".join("__", kdocAstUtil::heritage($node)).".cs";
my $interfaceName = kalyptusDataDict::interfacemap($node->{astNodeName});
$file =~ s/$node->{astNodeName}/$interfaceName/;
open( INTERFACE, ">$file" ) || die "Couldn't create $file\n";
print INTERFACE "// ", kalyptusDataDict::interfacemap($node->{astNodeName}), ".cs - ", kalyptusDataDict::interfacemap($node->{astNodeName}), " c-sharp implementation.";
print INTERFACE $docTop;
print INTERFACE "\nnamespace Qt {";
print INTERFACE "\n\n\tusing Qt;";
print INTERFACE "\n\n\tpublic interface ", kalyptusDataDict::interfacemap($node->{astNodeName}), " {";
}
} else {
my $ancestor;
foreach $ancestor ( @ancestors ) {
if ( kalyptusDataDict::interfacemap($ancestor) eq () ) {
if ( $ancestor eq ("Qt") ){
print CLASS "\n\n\tpublic class ", $node->{astNodeName}, " : TQNameSpace ";
} else {
print CLASS "\n\n\tpublic class ", $node->{astNodeName}, " : $ancestor";
}
last;
} elsif ($ancestor eq @ancestors[$#ancestors] ) {
if ( $ancestor eq ("Qt") ){
print CLASS "\n\n\tpublic class ", $node->{astNodeName}, " : TQNameSpace ";
} else {
print CLASS "\n\n\tpublic class ", $node->{astNodeName}, " : ";
}
print CLASS @ancestors[$#ancestors], "";
}
}
if ( $#ancestors >= 1 ) {
foreach $ancestor ( @ancestors ) {
if ( kalyptusDataDict::interfacemap($ancestor) ne () ) {
print CLASS ", ".kalyptusDataDict::interfacemap($ancestor);
}
}
}
if ( kalyptusDataDict::interfacemap($node->{astNodeName}) ne () ) {
print CLASS ",".kalyptusDataDict::interfacemap($node->{astNodeName});
}
print CLASS " {";
}
Iter::MembersByType ( $node,
sub { print CLASS "", $_[0], ""; print JNISOURCE "", $_[0], ""; },
sub { my ($node, $kid ) = @_;
generateClassMethodForEnum( $node, $kid );
},
sub { print CLASS ""; print JNISOURCE ""; }
);
%functionId = ();
$eventHandlerCount = 0;
Iter::MembersByType ( $node,
sub { print CLASS "", $_[0], ""; print CLASS "", $_[0], ""; },
sub { my ($node, $kid ) = @_;
listMember( $node, $kid );
},
sub { print CLASS ""; print CLASS ""; }
);
if ($nullctor ne (1) ) {
if ( $#ancestors >= 0 ) {
print CLASS "\n\n\t\tpublic ", $node->{astNodeName}, "() : base() {";
print CLASS "\n\n\t\t\t// Dummy constructor for inherited classes.";
print CLASS "\n\t\t}";
#print CLASS "\n\n\t\t// This is a convenience constructor for instantiating by passing a RawObject.";
#print CLASS "\n\t\tpublic ", $node->{astNodeName}, "(IntPtr raw) : base((Class) null) {";
#print CLASS "\n\n\t\t\tRawObject = raw;";
#print CLASS "\n\t\t}";
} else {
print CLASS "\n\n\t\tpublic ", $node->{astNodeName}, "() : base() {";
print CLASS "\n\n\t\t\t// Dummy constructor for inherited classes.";
print CLASS "\n\t\t}";
#print CLASS "\n\n\t\t// This is a convenience constructor for instantiating by passing a RawObject.";
#print CLASS "\n\t\tpublic ", $node->{astNodeName}, "(IntPtr raw) {";
#print CLASS "\n\n\t\t\tRawObject = raw;";
#print CLASS "\n\t\t}";
}
}
print CLASS "\n\t}\n}\n";
close CLASS;
$nullctor = 0;
if ( kalyptusDataDict::interfacemap($node->{astNodeName}) ne () ) {
print INTERFACE "\n\t}\n}\n";
close INTERFACE;
}
}
sub listMember
{
my( $class, $m, $ancestorCount) = @_;
my $name;
my $function;
my $csharpaccess;
my $csharpparams;
my $returnType;
$name = $m->{astNodeName} ;
my $type = $m->{NodeType};
my $docnode = $m->{DocNode};
if ( $m->{ReturnType} =~ /~/ ) {
$name = "~".$name;
}
if ( $functionId{$name} eq "" ) {
$functionId{$name} = 0;
$function = $name;
} else {
$functionId{$name}++;
$function = $name.$functionId{$name};
}
$function =~ s/~//;
if( $type eq "method" && $m->{Access} ne "private" && $m->{Access} ne "private_slots" && $m->{Access} ne "signals" ) {
if ( $m->{ReturnType} =~ /[<>]/ || $m->{Params} =~ /[<>]/ || $m->{Params} =~ /\.\.\./ || $m->{Params} =~ /Impl/
|| $m->{ReturnType} =~ /TQAuBucket/ || $m->{Params} =~ /TQAuBucket/
|| $m->{ReturnType} =~ /TQMember/ || $m->{Params} =~ /TQMember/ ) {
return;
}
$returnType = $m->{ReturnType};
$returnType =~ s/const\s*//;
$returnType =~ s/inline\s*//;
$returnType =~ s/\s*([,\*\&])\s*/$1/;
$returnType =~ s/^\s*//;
$returnType =~ s/\s*$//;
if ( $returnType ne "" && cplusplusToPInvoke($returnType) eq () ) {
$returnType =~ s/^.*::.*$/int/;
} else {
$returnType = cplusplusToPInvoke($returnType);
}
if ( $returnType eq "RawObject") {
$returnType = "IntPtr";
}
my $cparams = $m->{Params};
my $cplusplusparams;
my $pinvokeparams;
my $pinvokeargs;
# TODO port to $m->{ParamList}
$cparams =~ s/\s+/ /g;
$cparams =~ s/\s*([,\*\&])\s*/$1 /g;
$cparams =~ s/^\s*void\s*$//;
my $argId = 0;
my @cargs = kdocUtil::splitUnnested(",", $cparams);
$cparams = "";
foreach my $arg ( @cargs ) {
my $argType;
my $cargType;
my $csharpargType;
my $pinvokeargType;
if ( $arg =~ /^\s*$/ ) {
next;
}
# A '<arg> = <value>' default parameter
$arg =~ s/\s*([^\s].*[^\s])\s*/$1/;
$arg =~ s/(\w+)\[\]/\* $1/;
$arg =~ s/=\s*(("[^\"]*")|(\'.\')|(([-\w:.]*)\s*(\|\s*[-\w]*)*(\(\w*\))?))//;
if ( $arg =~ /^(.*)\s+(\w+)\s*$/ ) {
$argType = $1;
$arg = $2;
} else {
$argType = $arg;
$argId++;
$arg = "arg".$argId;
}
$arg =~ s/^id$/identifier/;
$argType =~ s/\s*([^\s].*[^\s])\s*/$1/;
$argType =~ s/\s*const//g;
$argType =~ s/^\s*//;
$argType =~ s/([\*\&])\s*([\*\&])/$1$2/;
$cargType = kalyptusDataDict::ctypemap($argType);
$csharpargType = cplusplusToCSharp($argType);
$pinvokeargType = cplusplusToPInvoke($argType);
if ( $csharpargType eq "" ) {
$csharpargType = $argType;
$csharpargType =~ s/\&/\*/;
$csharpargType =~ s/^.*::.*$/int/;
}
if ( $pinvokeargType eq "" ) {
$pinvokeargType = $argType;
$pinvokeargType =~ s/\&/\*/;
$pinvokeargType =~ s/^.*::.*$/int/;
}
$arg = checkReserved($arg);
if ( $pinvokeargType =~ /IntPtr/ ) {
$pinvokeargs .= "$arg.Ptr, ";
} elsif ( $csharpargType =~ /\./ ) {
$pinvokeargs .= "($pinvokeargType)$arg, ";
} else {
$pinvokeargs .= "$arg, ";
}
if ( $pinvokeargType =~ /RawObject/ ) {
$pinvokeargType =~ s/RawObject/IntPtr/;
}
$csharpparams .= "$csharpargType $arg, ";
$pinvokeparams .= "$pinvokeargType $arg, ";
}
$cparams =~ s/, $//;
$cplusplusparams =~ s/, $//;
$csharpparams =~ s/, $//;
$pinvokeparams =~ s/, $//;
$pinvokeargs =~ s/, $//;
my $flags = $m->{Flags};
if ( !defined $flags ) {
warn "Method ".$m->{astNodeName}. " has no flags\n";
}
my $extra = "";
$extra .= "static " if $flags =~ "s";
if ( $name =~ /operator/ ) {
return;
}
if ( $m->{Access} =~ /protected/ && $name ne $class->{astNodeName} ) {
if ( $class->{Pure} ) {
return;
}
$name = "protected_".$name;
}
$m->{Access} =~ /([^_]*)(.*)?\s*/;
$csharpaccess = $1;
if ( $extra =~ /static/ ) {
$csharpaccess .= " static";
}
if ( $name eq $class->{astNodeName} && $class->{Pure} ) {
return;
}
if ( defined $docnode ) {
if ( defined $docnode->{Text} ) {
print CLASS "\n/** ";
my $node;
my $line;
foreach $node ( @{$docnode->{Text}} ) {
next if $node->{NodeType} ne "DocText";
$line = $node->{astNodeName};
print CLASS $line, "\n";
}
print CLASS "*/\n";
}
}
#This is to make sure we have no duplicate methods...
my $currentmethod .= "$name $returnType $csharpparams";
my $pastmethod .= "$pastname $pastreturn $pastparams";
if($currentmethod ne $pastmethod) {
if ( $name eq $class->{astNodeName} ) {
#All the constructors are generated here except the dummy constructor
#print CLASS "\n// DLLImport goes here...";
print CLASS "\n\n\t\t[DllImport(\"libqtc.so\", CharSet=CharSet.Ansi)]";
print CLASS "\n\t\tprivate static extern IntPtr ", $typeprefix, "new_", $function, "(", $pinvokeparams, ");";
print CLASS "\n\t\t", $csharpaccess, " ", $class->{astNodeName}, "(", $csharpparams, ") ";
if ($ancestorCount >= 0) {
print CLASS ": base() {";
}
else {
print CLASS "{";
}
print CLASS "\n\n\t\t\tRawObject = ", $typeprefix, "new_", $function, "(", $pinvokeargs, ");";
print CLASS "\n\t\t}";
if ($csharpparams eq () ) {
$nullctor = 1;
}
} elsif ( $returnType =~ /~/ ) {
#The deconstructor is here
print CLASS "\n\n\t\t// Deconstructor goes here...";
print CLASS "\n\t\t", $csharpaccess, " void ", "del_", $function, "( ", $class->{astNodeName}, " p ){}";
} else {
if ( $name =~ /.*Event$/ ) {
return;
}
# Class or instance method
my $selfstring;
if ( $extra =~ /static/ ) {
if ( exists $class->{Pure} || $constructorCount == 0 ) {
$selfstring = kalyptusDataDict::addNamespace($class->{astNodeName})."::";
} else {
$selfstring = $class->{astNodeName}."Bridge::";
}
#Static Methods are generated here
#print CLASS "\n\n\t\t// DLLImport method goes here...";
print CLASS "\n\n\t\t[DllImport(\"libqtc.so\", CharSet=CharSet.Ansi)]";
print CLASS "\n\t\tprivate static extern", " ", $returnType, " ", $typeprefix, $class->{astNodeName}, "_", $function, "(", $pinvokeparams, ");";
print CLASS "\n\t\t", $csharpaccess, " ", $returnType, " ", $name, "(", $csharpparams, ") {";
if ($returnType =~ /void/ ) {
print CLASS "\n\n\t\t\t",$typeprefix, $class->{astNodeName}, "_", $function, "(", $pinvokeargs, ");";
} else {
print CLASS "\n\n\t\t\treturn ", $typeprefix, $class->{astNodeName}, "_", $function, "(", $pinvokeargs, ");";
}
print CLASS "\n\t\t}";
} else {
if ( exists $class->{Pure} || $constructorCount == 0 ) {
$selfstring = "((".kalyptusDataDict::addNamespace($class->{astNodeName})."*)instPointer)->";
} else {
$selfstring = "((".$class->{astNodeName}."Bridge*)instPointer)->";
}
#Methods are generated here
#print CLASS "\n\n\t\t// DLLImport method goes here...";
print CLASS "\n\n\t\t[DllImport(\"libqtc.so\", CharSet=CharSet.Ansi)]";
print CLASS "\n\t\tprivate static extern", " ", $returnType, " ", $typeprefix, $class->{astNodeName}, "_", $function, "(", "IntPtr raw", ($pinvokeparams eq "" ? "" : ", "), $pinvokeparams, ");";
print CLASS "\n\t\t", $csharpaccess, " ", $returnType, " ", checkReserved($name), "(", $csharpparams, ") {";
if ($returnType =~ /void/ ) {
print CLASS "\n\n\t\t\t",$typeprefix, $class->{astNodeName}, "_", $function, "(", "RawObject", ($pinvokeargs eq "" ? "" : ", "), $pinvokeargs, ");";
} else {
print CLASS "\n\n\t\t\treturn ", $typeprefix, $class->{astNodeName}, "_", $function, "(", "RawObject", ($pinvokeargs eq "" ? "" : ", "), $pinvokeargs, ");";
}
print CLASS "\n\t\t}";
}
}
}
}
#Part of the duplicate methods check.
$pastname = $name;
$pastreturn = $returnType;
$pastparams = $csharpparams;
$csharpparams = "";
}
sub generateClassMethodForEnum
{
my( $class, $m ) = @_;
my $enum = $m->{astNodeName};
my $csharpaccess;
$m->{Access} =~ /([^_]*)(.*)?\s*/;
$csharpaccess = $1;
if( $m->{NodeType} eq "enum" ) {
my $enum = $m->{astNodeName};
my @enums = split(",", $m->{Params});
my $enumCount = 0;
if($enum ne " ") {
print CLASS "\n\n\t\t$csharpaccess enum", $enum,":long {";
foreach my $enum ( @enums ) {
$enum =~ s/\s//g;
$enum =~ s/::/./g;
if($#enums == $enumCount){
if ( $enum =~ /(.*)=(.*)/ ) {
print CLASS "\n\t\t\t$1 = $2";
} else {
print CLASS "\n\t\t\t$enum = $enumCount";
}
} else {
if ( $enum =~ /(.*)=(.*)/ ) {
print CLASS "\n\t\t\t$1 = $2,";
} else {
print CLASS "\n\t\t\t$enum = $enumCount,";
}
}
$enumCount++;
}
print CLASS "\n\t\t}";
}
}
}
1;

File diff suppressed because it is too large Load Diff

@ -0,0 +1,570 @@
#***************************************************************************
# kalyptusCxxToEMA.pm - Generates class info for ECMA bindings in KDE
# -------------------
# begin : Fri Jan 25 12:00:00 2000
# copyright : (C) 2002 Lost Highway Ltd. All Rights Reserved.
# email : david@mandrakesoft.com
# author : David Faure.
#***************************************************************************/
#/***************************************************************************
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation; either version 2 of the License, or *
# * (at your option) any later version. *
# * *
#***************************************************************************/
package kalyptusCxxToECMA;
use File::Path;
use File::Basename;
use Carp;
use Ast;
use kdocAstUtil;
use kdocUtil;
use Iter;
use kalyptusDataDict;
use strict;
no strict "subs";
use vars qw/
$libname $rootnode $outputdir $opt $debug
%skippedClasses %hasHashTable %hasFunctions %hasBridge %hasGet %hasPut/;
sub writeDoc
{
( $libname, $rootnode, $outputdir, $opt ) = @_;
print STDERR "Starting writeDoc for $libname...\n";
$debug = $main::debuggen;
mkpath( $outputdir ) unless -f $outputdir;
# Preparse everything, to prepare some additional data in the classes and methods
Iter::LocalCompounds( $rootnode, sub { preParseClass( shift ); } );
print STDERR "Writing generateddata.cpp...\n";
writeInheritanceFile($rootnode);
print STDERR "Done.\n";
}
=head2 preParseClass
Called for each class
=cut
sub preParseClass
{
my( $classNode ) = @_;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
if ( $className =~ /Proto$/ ) {
my $c = $className;
$c =~ s/Proto$//;
#print STDERR "$c -> $className\n";
$hasFunctions{$c} = $className; # Associate class -> proto
#print STDERR "Found proto $className -> skipping\n";
$skippedClasses{$className} = 1; # Skip proto
return;
}
if( $classNode->{Access} eq "private" ||
$classNode->{Access} eq "protected" || # e.g. TQPixmap::TQPixmapData
exists $classNode->{Tmpl} ||
$className eq 'KJS' || $className eq 'KSVG' || # namespaces
$className =~ /^KSVG::KSVG/ || $className eq 'KSVG::CachedGlyph' || # Not DOM classes
$className eq 'KSVG::ImageStreamMap' ||
$className eq 'KSVG::SVGBBoxTarget' ||
$className eq 'KSVG::SVGLoader' ||
$className eq 'KSVG::SVGElementImpl::MouseEvent' ||
$className eq 'KSVG::SVGRegisteredEventListener' ||
$classNode->{NodeType} eq 'union' # Skip unions for now, e.g. TQPDevCmdParam
) {
print STDERR "Skipping $className "; #if ($debug);
#print STDERR "(nothing in it)\n" if ( $#{$classNode->{Kids}} < 0 );
if ( exists $classNode->{Tmpl} ) {
print STDERR "(template)\n";
} elsif ( $classNode->{Access} eq "private" or $classNode->{Access} eq "protected" ) {
print STDERR "(not public)\n";
} elsif ( $classNode->{NodeType} eq 'union') {
print STDERR "(union)\n";
} elsif ( $className =~ /^KSVG::KSVG/ || $className eq 'KSVG::CachedGlyph' ) {
print STDERR "(not a DOM class)\n";
} else {
print STDERR "\n";
}
$skippedClasses{$className} = 1;
#delete $classNode->{Compound}; # Cheat, to get it excluded from Iter::LocalCompounds
# Can't do that, it's recursive (KSVG::* disappears)
return;
}
# Iterate over methods
Iter::MembersByType ( $classNode, undef,
sub { my ($classNode, $methodNode ) = @_;
if ( $methodNode->{NodeType} eq 'method' ) {
if ( $methodNode->{astNodeName} eq 'get' ) {
$hasGet{$className} = '1';
} elsif ( $methodNode->{astNodeName} eq 'getforward' ) {
$hasGet{$className} = '2';
} elsif ( $methodNode->{astNodeName} eq 'put' ) {
$hasPut{$className} = '1';
} elsif ( $methodNode->{astNodeName} eq 'putforward' ) {
$hasPut{$className} = '2';
} elsif ( $methodNode->{astNodeName} eq 'getValueProperty' ) {
$hasHashTable{$className} = '1';
} elsif ( $methodNode->{astNodeName} eq 'bridge' ) {
$hasBridge{$className} = '1';
}
}
} );
}
# List of all super-classes for a given class
sub superclass_list($)
{
my $classNode = shift;
my @super;
Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
push @super, @_[0];
push @super, superclass_list( @_[0] );
}, undef );
return @super;
}
# Adds the header for node $1 to be included in $2 if not already there
# Prints out debug stuff if $3
sub addIncludeForClass($$$)
{
my ( $node, $addInclude, $debugMe ) = @_;
my $sourcename = $node->{Source}->{astNodeName};
$sourcename =~ s!.*/(.*)!$1!m;
unless ( defined $addInclude->{$sourcename} ) {
print " Including $sourcename\n" if ($debugMe);
$addInclude->{$sourcename} = 1;
}
else { print " $sourcename already included.\n" if ($debugMe); }
}
=head2
Write out the smokedata.cpp file containing all the arrays.
=cut
sub writeInheritanceFile($) {
my $rootnode = shift;
# Make list of classes
my %allIncludes; # list of all header files for all classes
my @classlist;
push @classlist, ""; # Prepend empty item for "no class"
Iter::LocalCompounds( $rootnode, sub {
my $classNode = $_[0];
my $className = join( "::", kdocAstUtil::heritage($classNode) );
return if ( defined $skippedClasses{$className} );
push @classlist, $className;
$classNode->{ClassIndex} = $#classlist;
addIncludeForClass( $classNode, \%allIncludes, undef );
} );
my %classidx = do { my $i = 0; map { $_ => $i++ } @classlist };
#foreach my $debugci (keys %classidx) {
# print STDERR "$debugci: $classidx{$debugci}\n";
#}
my $file = "$outputdir/generateddata.cpp";
open OUT, ">$file" or die "Couldn't create $file\n";
print OUT "#include <ksvg_lookup.h>\n";
print OUT "#include <ksvg_ecma.h>\n";
foreach my $incl (keys %allIncludes) {
die if $incl eq '';
print OUT "#include <$incl>\n";
}
print OUT "\n";
# Prepare descendants information for each class
my %descendants; # classname -> list of descendant nodes
#my $SVGElementImplNode;
Iter::LocalCompounds( $rootnode, sub {
my $classNode = shift;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
# Get _all_ superclasses (up any number of levels)
# and store that $classNode is a descendant of $s
my @super = superclass_list($classNode);
for my $s (@super) {
my $superClassName = join( "::", kdocAstUtil::heritage($s) );
Ast::AddPropList( \%descendants, $superClassName, $classNode );
}
# Found SVGElementImpl itself
if ( $className eq 'KSVG::SVGElementImpl' ) {
$classNode->{IsSVGElement} = '1';
#$SVGElementImplNode = $classNode;
}
} );
# Mark all SVGElementImpl descendants as svg elements
if ( defined $descendants{'KSVG::SVGElementImpl'} ) {
my @desc = @{$descendants{'KSVG::SVGElementImpl'}};
for my $d (@desc) {
$d->{IsSVGElement} = '1' ;
print STDERR $d->{astNodeName}. " is an SVGElement\n" if($debug);
}
}
# Propagate $hasPut and $hasGet
Iter::LocalCompounds( $rootnode, sub {
my $classNode = shift;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
if ( defined $descendants{$className} ) {
my @desc = @{$descendants{$className}};
for my $d (@desc) {
my $c = join( "::", kdocAstUtil::heritage($d) );
$hasPut{$c} = '2' if (!$hasPut{$c} && $hasPut{$className});
$hasGet{$c} = '2' if (!$hasGet{$c} && $hasGet{$className});
}
}
# This code prints out the base classes - useful for KSVG_BASECLASS_GET
if ( 0 && defined $descendants{$className} ) {
my $baseClass = 1;
Iter::Ancestors( $classNode, $rootnode, sub { # called if no ancestors
}, undef, sub { # called for each ancestor
my $superClassName = join( "::", kdocAstUtil::heritage($_[0]) );
$baseClass = 0 if ( $superClassName ne '' ); # happens with unknown parents;
} );
print STDERR "$className is a base class.\n" if ($baseClass);
}
} );
# Write namespaces
print OUT "using namespace KSVG;\n";
print OUT "using namespace KJS;\n\n";
# Write classInfos
print OUT "// For all classes with generated data: the ClassInfo\n";
Iter::LocalCompounds( $rootnode, sub {
my $classNode = shift;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
# We use namespace declartions!
my $printName = $className;
$printName =~ s/KSVG:://;
# Write tagNames
if ($hasBridge{$className}) {
my $tagName = $printName;
$tagName =~ s/SVG//;
$tagName =~ s/ElementImpl//;
$tagName = lcfirst($tagName);
# Special cases, otherwhise they'd be "tRef" / "tSpan" / "sVG"
if($printName eq "SVGTRefElementImpl" or
$printName eq "SVGTSpanElementImpl" or
$printName eq "SVGSVGElementImpl") {
$tagName =~ tr/A-Z/a-z/;
}
while($tagName =~ /[A-Z]/g) {
# Special case: color-profile instead of ie. animateColor/animateMotion
if($printName eq "SVGColorProfileElementImpl") {
$tagName = substr($tagName, 0, pos($tagName) - 1) . "-" . lc($&) . substr($tagName, pos($tagName));
}
}
# Special cases: gradient & poly aren't element!
if($tagName ne "" and $tagName ne "gradient" and $tagName ne "poly") {
print OUT "const DOM::DOMString ${printName}::s_tagName = \"$tagName\";\n";
}
}
# Skip classes without KSVG_GENERATEDDATA
if (!$hasGet{$className} && !$skippedClasses{$className}) {
$skippedClasses{$className} = '1' ;
print STDERR "Skipping $className, no get()\n";
}
return if ( defined $skippedClasses{$className} );
my $ok = $hasHashTable{$className};
print STDERR "$className has get() but no hashtable - TODO\n" if (!$ok && $hasGet{$className} eq '1');
print OUT "const ClassInfo ${printName}::s_classInfo = {\"$className\",0,";
if ($ok) {
print OUT "\&${printName}::s_hashTable";
} else {
print OUT "0";
}
print OUT ",0};\n";
#die "problem with $className" unless defined $classinherit{$className};
#print OUT "const short int ${className}::s_inheritanceIndex = $classinherit{$className};\n";
} );
# Generated methods
print OUT "\n";
Iter::LocalCompounds( $rootnode, sub {
my $classNode = shift;
my $className = join( "::", kdocAstUtil::heritage($classNode) );
return if ( defined $skippedClasses{$className} );
# We use namespace declartions!
my $printName = $className;
$printName =~ s/KSVG:://;
my $paramsUsed = 0;
print OUT "bool ${printName}::hasProperty(ExecState *p1,const Identifier &p2) const\n";
print OUT "{\n";
if ($hasHashTable{$className}) {
print OUT " const HashEntry *e = Lookup::findEntry(\&${printName}::s_hashTable,p2);\n";
print OUT " if(e) return true;\n";
$paramsUsed=1;
}
# Now look in prototype, if it exists
if ( defined $hasFunctions{$className} ) {
# We use namespace declartions!
my $output = $hasFunctions{$className};
$output =~ s/KSVG:://;
print OUT " Object proto = " . $output . "::self(p1);\n";
print OUT " if(proto.hasProperty(p1,p2)) return true;\n";
}
# For each direct ancestor...
Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
my $superClassName = join( "::", kdocAstUtil::heritage($_[0]) );
# We use namespace declartions!
my $printSuperClassName = $superClassName;
$printSuperClassName =~ s/KSVG:://;
if ( $superClassName ne '' ) { # happens with unknown parents
return if ( defined $skippedClasses{$superClassName} );
print OUT " if(${printSuperClassName}::hasProperty(p1,p2)) return true;\n";
$paramsUsed=2;
}
}, undef );
if ($paramsUsed == 1 && !defined $hasFunctions{$className}){
print OUT " Q_UNUSED(p1);\n";
}
if ($paramsUsed == 0){
print OUT " Q_UNUSED(p1); Q_UNUSED(p2);\n";
}
print OUT " return false;\n";
print OUT "}\n\n";
my @ancestorsWithGet;
Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
my $superClassName = join( "::", kdocAstUtil::heritage($_[0]) );
if ( $superClassName ne '' # happens with unknown parents
&& ! defined $skippedClasses{$superClassName} ) {
if ( $hasGet{$superClassName} ) {
push @ancestorsWithGet, $superClassName;
}
}
}, undef );
if ($hasHashTable{$className}) {
die unless $hasGet{$className};
if ( $hasGet{$className} eq '1' ) {
print OUT "Value ${printName}::get(GET_METHOD_ARGS) const\n";
print OUT "{\n";
if ( defined $hasFunctions{$className} ) {
# We use namespace declartions!
my $output = $hasFunctions{$className};
$output =~ s/KSVG:://;
print OUT " return lookupGet<${output}Func,${printName}>(p1,p2,&s_hashTable,this,p3);\n";
} else {
print OUT " return lookupGetValue<${printName}>(p1,p2,&s_hashTable,this,p3);\n";
}
print OUT "}\n\n";
if ( defined $hasFunctions{$className} ) {
# We use namespace declartions!
my $output = $hasFunctions{$className};
$output =~ s/KSVG:://;
my $methodName = "${output}Func::cast";
my $const = 'const';
# Special case - we also need that code in toNode()
if ($methodName eq 'SVGDOMNodeBridgeProtoFunc::cast') {
print OUT "${printName} *$methodName(const ObjectImp *p1) const\n";
$methodName = 'KSVG::toNodeBridge';
print OUT "{\n";
print OUT " return $methodName(p1);\n";
print OUT "}\n\n";
$const = '';
}
# Type resolver for the Func class
print OUT "${printName} *$methodName(const ObjectImp *p1) $const\n";
print OUT "{\n";
my @toTry;
push @toTry, $classNode;
if ( defined $descendants{$className} ) {
push @toTry, @{$descendants{$className}};
}
foreach my $d (@toTry) {
my $c = join( "::", kdocAstUtil::heritage($d) );
# We use namespace declartions!
my $d = $c;
$d =~ s/KSVG:://;
print OUT " { const KSVGBridge<$d> *test = dynamic_cast<const KSVGBridge<$d> * >(p1);\n";
print OUT " if(test) return test->impl(); }\n";
}
print OUT " return 0;\n";
print OUT "}\n\n";
}
}
}
my $methodName = $hasGet{$className} eq '1' ? 'getInParents' : 'get';
print OUT "Value ${printName}::$methodName(GET_METHOD_ARGS) const\n";
print OUT "{\n";
my $paramsUsed = 0;
# Now look in prototype, if it exists
if ( defined $hasFunctions{$className} ) {
# Prototype exists (because the class has functions)
# We use namespace declartions!
my $output = $hasFunctions{$className};
$output =~ s/KSVG:://;
print OUT " Object proto = " . $output . "::self(p1);\n";
print OUT " if(proto.hasProperty(p1,p2)) return proto.get(p1,p2);\n"; ## TODO get() directly
$paramsUsed = 1;
}
foreach my $anc (@ancestorsWithGet) {
# We use namespace declartions!
my $printAnc = $anc;
$printAnc =~ s/KSVG:://;
print OUT " if(${printAnc}::hasProperty(p1,p2)) return ${printAnc}::get(p1,p2,p3);\n"; ## TODO get() directly
$paramsUsed = 2;
}
if ($paramsUsed == 0 ){
print OUT " Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3);\n";
} elsif ( $paramsUsed == 1 ) {
print OUT " Q_UNUSED(p3);\n";
}
print OUT " return Undefined();\n";
print OUT "}\n\n";
if ( $hasPut{$className} )
{
if ( $hasPut{$className} eq '1' ) {
if ($hasHashTable{$className}) {
print OUT "bool ${printName}::put(PUT_METHOD_ARGS)\n";
print OUT "{\n";
print OUT " return lookupPut<${printName}>(p1,p2,p3,p4,&s_hashTable,this);\n";
print OUT "}\n\n";
}
print OUT "bool ${printName}::putInParents(PUT_METHOD_ARGS)\n";
} else { # forward put
print OUT "bool ${printName}::put(PUT_METHOD_ARGS)\n";
}
print OUT "{\n";
my $paramsUsed = 0;
Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
my $superClassName = join( "::", kdocAstUtil::heritage($_[0]) );
# We use namespace declartions!
my $printSuperClassName = $superClassName;
$printSuperClassName =~ s/KSVG:://;
if ( $superClassName ne '' ) { # happens with unknown parents
if ( $hasPut{$superClassName} ) {
print OUT " if(${printSuperClassName}::hasProperty(p1,p2)) {\n";
print OUT " ${printSuperClassName}::put(p1,p2,p3,p4);\n";
print OUT " return true;\n";
print OUT " }\n";
$paramsUsed=1;
}
}
}, undef );
if (!$paramsUsed){
print OUT " Q_UNUSED(p1); Q_UNUSED(p2); Q_UNUSED(p3); Q_UNUSED(p4);\n";
}
print OUT " return false;\n";
print OUT "}\n\n";
}
# Write prototype method
print OUT "Object ${printName}::prototype(ExecState *p1) const\n";
print OUT "{\n";
if ( defined $hasFunctions{$className} ) {
# We use namespace declartions!
my $output = $hasFunctions{$className};
$output =~ s/KSVG:://;
# Prototype exists (because the class has functions)
print OUT " if(p1) return " . $output . "::self(p1);\n";
} else {
# Standard Object prototype
print OUT " if(p1) return p1->interpreter()->builtinObjectPrototype();\n";
}
print OUT " return Object::dynamicCast(Null());\n"; # hmm
print OUT "}\n\n";
# Process classes only with KSVG_BRIDGE
if ($hasBridge{$className}) {
#print STDERR "Writing bridge() for $className...\n";
# Write bridge method
print OUT "ObjectImp *${printName}::bridge(ExecState *p1) const\n";
print OUT "{\n";
if ($hasPut{$className})
{
print OUT " return new KSVGRWBridge<${printName}>(p1,const_cast<${printName} *>(this));\n";
}
else
{
print OUT " return new KSVGBridge<${printName}>(p1,const_cast<${printName} *>(this));\n";
}
print OUT "}\n\n";
}
if ($hasGet{$className}) {
# Write cache method
print OUT "Value ${printName}::cache(ExecState *p1) const\n";
print OUT "{\n";
if ($hasPut{$className})
{
print OUT " return KJS::Value(cacheDOMObject<${printName},KSVGRWBridge<${printName}> >(p1,const_cast<${printName} *>(this)));\n";
}
else
{
print OUT " return KJS::Value(cacheDOMObject<${printName},KSVGBridge<${printName}> >(p1,const_cast<${printName} *>(this)));\n";
}
print OUT "}\n\n";
}
} );
}
1;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,996 @@
package kalyptusCxxToSwig;
use File::Path;
use File::Basename;
use Carp;
use Ast;
use kdocAstUtil;
use kdocUtil;
use Iter;
use kalyptusDataDict;
use strict;
no strict "subs";
use vars qw/ @clist $host $who $now $gentext %functionId $docTop %typedeflist
$lib $rootnode $outputdir $opt $debug $typeprefix $eventHandlerCount
$constructorCount *CLASS *HEADER *TQTCTYPES *KDETYPES /;
BEGIN
{
@clist = ();
%typedeflist =
(
'signed char' => 'char',
'unsigned char' => 'uchar',
'signed short' => 'short',
'unsigned short' => 'ushort',
'signed' => 'int',
'signed int' => 'int',
'unsigned' => 'uint',
'unsigned int' => 'uint',
'signed long' => 'long',
'unsigned long' => 'ulong',
'TQWSEvent*' => 'void*',
'TQDiskFont*' => 'void*',
'XEvent*' => 'void*',
'TQStyleHintReturn*' => 'void*',
'FILE*' => 'void*',
'TQUnknownInterface*' => 'void*',
'GDHandle' => 'void*',
'_NPStream*' => 'void*',
'TQTextFormat*' => 'void*',
'TQTextDocument*' => 'void*',
'TQTextCursor*' => 'void*',
'TQTextParag**' => 'void*',
'TQTextParag* *' => 'void*',
'TQTextParag*' => 'void*',
'TQRemoteInterface*' => 'void*',
'TQSqlRecordPrivate*' => 'void*',
'TQTSMFI' => 'void*', # TQTextStream's TQTSManip
'const GUID&' => 'void*',
'TQWidgetMapper*' => 'void*',
'TQWidgetMapper *' => 'void*',
'MSG*' => 'void*',
'const TQSqlFieldInfoList&' => 'void*', # TQSqlRecordInfo - TODO (templates)
'TQPtrCollection::Item' => 'void*', # to avoid a warning
'mode_t' => 'long',
'TQProcess::PID' => 'long',
'size_type' => 'int', # TQSqlRecordInfo
'TQt::ComparisonFlags' => 'uint',
'TQt::ToolBarDock' => 'int', # compat thing, Qt shouldn't use it
'TQIODevice::Offset' => 'ulong',
'WState' => 'int',
'WId' => 'ulong',
'TQRgb' => 'uint',
'TQRgb *' => 'uint*',
'TQRgb*' => 'uint*',
'const TQCOORD*' => 'const int*',
'TQCOORD*' => 'int*',
'TQCOORD' => 'int',
'TQCOORD &' => 'int&',
'TQTSMFI' => 'int',
'TQt::WState' => 'int',
'TQt::WFlags' => 'int',
'TQt::HANDLE' => 'uint',
'TQEventLoop::ProcessEventsFlags' => 'uint',
'TQStyle::SCFlags' => 'int',
'TQStyle::SFlags' => 'int',
'TQStyleOption&' => 'int&',
'const TQStyleOption&' => 'const int&',
'Q_INT16' => 'short',
'Q_INT32' => 'int',
'Q_INT8' => 'char',
'Q_LONG' => 'long',
'Q_UINT16' => 'ushort',
'Q_UINT32' => 'uint',
'Q_UINT8' => 'uchar',
'Q_ULONG' => 'long',
);
# Page footer
$who = kdocUtil::userName();
$host = kdocUtil::hostName();
$now = localtime;
$gentext = "$who\@$host on $now, using kalyptus $main::Version.";
$docTop =<<EOF
begin : $now
copyright : (C) 2003 Ian Geiser, Zack Rusin
email : geiseri\@kde.org, zack\@kde.org
generated by : $gentext
***************************************************************************/
/***************************************************************************
* *
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
EOF
}
# Returns 1 if the $kid of the $node should be skipped
sub skipMethod($$)
{
my ($node, $kid) = @_;
if ( $kid->{NodeType} ne "method" ) {
return 1;
}
my $access = $kid->{Access};
# if ( $access eq "private" || $access eq "private_slots" || $access eq "signals" ) {
if ( $access eq "private_slots" || $access eq "signals" ) {
return 1;
}
return undef;
}
# returns 1 if the $kid is not a protected method of object $node
sub isNotProtectedMethod($$)
{
my ($node, $kid) = @_;
print "HERE $node->{NodeType} $node->{astNodeName}, $kid->{NodeType} $kid->{astNodeName} \n";
if ( $kid->{NodeType} ne "method" ) {
return 1;
}
my $access = $kid->{Access};
if ( $access ne "protected" && $access ne "protected_slots" ) {
return 1;
}
return undef;
}
# Returns the list of all classes this one inherits
# If $recurse is defined function returns also all the parents
# of the classes $classNode inherits from
sub superClassList($;$)
{
my $classNode = shift;
my $recurse = shift;
my @super;
my @nodes;
Iter::Ancestors( $classNode, $rootnode, undef, undef, sub {
push @super, @_[0];
if ( defined $recurse ) {
push @super, superClassList( @_[0] );
}
}, undef );
return @super;
}
# Returns the names of the classes the $classNode
# inherits from
sub parentClassNames($)
{
my $classNode = shift;
my @names;
my @supers = superClassList($classNode);
foreach my $class (@supers) {
push @names, $class->{astNodeName};
}
return @names;
}
#doesn't do anything, for me to test
sub hasPublicConstructors($)
{
my ($node) = @_;
our $exists;
Iter::MembersByType ( $node,
sub { print SWIG_HEADER "1) @_\n"; },
sub { my ($node, $kid ) = @_;
print SWIG_HEADER "\%$node->{NodeType} $node->{astNodeName}\% $kid->{NodeType} $kid->{astNodeName}\n";
},
sub { print SWIG_HEADER "3 @_ \n"; }
);
}
# Returns string representing $child method declaration or definition.
# $child is the method node for which the code should be generated,
# $parentName is the name of the parent for which the code should be generated,
# this is one is tricky, the reason for it is that $child node belongs
# to some class e.g. TQWidget and we want to generate a code for $child
# but in a class called TQWidget_bridge therefore we need to pass tha name
# $mangleProtected will mangle the name of the method to look like normalNameProtected
# $definition - if set the code generated will be a definition (without the opening
# and closing {} )
sub generateMethodsCode($$$;$$)
{
my ($child, $parentName, $mangleProtected, $definition, $inline ) = @_;
my $ret = "";
if ( !(defined $definition) ) {
if ( $child->{Flags} =~ "s" ) {
$ret = "\tstatic ";
} elsif ( $child->{Flags} =~ "v" ) {
$ret = "\tvirtual ";
} else {
$ret = "\t";
}
}
if ( defined $definition && !(defined $inline)) {
if ( $mangleProtected ) {
$ret .= "$child->{ReturnType} $parentName"."::"."$child->{astNodeName}Protected";
} else {
$ret .= "$child->{ReturnType} $parentName"."::"."$child->{astNodeName}";
}
} else {
if ( defined $inline ) {
$ret .= "\t";
}
if ( $mangleProtected ) {
$ret .="$child->{ReturnType} $child->{astNodeName}Protected";
} else {
$ret .= convertType($child->{ReturnType})." $child->{astNodeName}";
}
}
$ret .= "(";
#$ret .= " $child->{Params} "; #can't be used because it includes names and default values
my @params = $child->{ParamList};
foreach my $arg (@params) {
if ( $arg ) {
my @arr = @{$arg};
my $num = @arr;
my $defParam = 'a';
foreach my $param ( @{$arg} ) {
#print "Node: $param->{ArgType} is a $param->{NodeType}\n";
# if ($param->{NodeType} eq "enum" ) {
#fix up enums
# $ret .= $parentName."::".$param->{astNodeName};
#}
#else{
$ret .= convertType($param->{ArgType})." ";
#}
# Apparently some languages do not appreciate the names and default values
## FIXME: generate argument names for functions that do not have them
if ( ! $param->{ArgName} ) {
$param->{ArgName} = $defParam++;
$ret .= $param->{ArgName};
} else {
$ret .= " $param->{ArgName}";
}
# For some reason we are not getting all of these...
#if ( ! (defined $definition) ) {
# $ret .= "=$param->{DefaultValue}" if $param->{DefaultValue};
#}
--$num;
$ret .= ", " if $num;
}
}
}
$ret .= ")";
if ( $child->{Flags} =~ "c" ) {
$ret .= " const";
}
if ( defined $definition ) {
$ret .= "\n";
} else {
$ret .= ";\n";
}
}
sub normalMethodDeclarations($$;$&$)
{
my ($node, $parentName, $definition, $writerSub, $inline) = @_;
my $accessType = "";
my $defaultConstructor = 0;
my $hasPublicProtectedConstructor = 0;
my $hasDestructor = 1;
my $hasPublicDestructor = 1;
my $hasCopyConstructor = 0;
my $hasPrivateCopyConstructor = 1;
my $enums = "";
my @methods;
my $ret = "";
Iter::MembersByType ( $node, undef,
sub { my ($classNode, $methodNode ) = @_;
if ( $methodNode->{NodeType} eq "method" ||
$methodNode->{NodeType} eq "enum" ||
$methodNode->{NodeType} eq "typedef" ) {
if ( $methodNode->{Access} ne "protected" &&
$methodNode->{Access} ne "protected_slots" &&
#$methodNode->{Access} eq "private" &&
$methodNode->{Access} ne "private_slots" &&
$methodNode->{Access} ne "signals" &&
!$methodNode->{Pure} &&
$methodNode->{astNodeName} !~ /qt_/ &&
$methodNode->{astNodeName} !~ /operator/ &&
$methodNode->{Params} !~ /std\:\:/ &&
$methodNode->{Params} !~ /\.\.\./){
push @methods, $methodNode;
}
}
}, undef );
foreach my $child ( @methods ) {
if ( $child->{Access} ne $accessType ) {
$accessType = $child->{Access};
if ( ! (defined $definition ) ) {
if ( $accessType eq "public_slots" ) {
$ret .= "public: //slots\n";
} else {
$ret .= "$accessType:\n";
}
}
}
## check for private ctor, dtor or copy ctor...
# print " public $node->{astNodeName}, $child->{astNodeName}\n";
if ( $node->{astNodeName} eq $child->{astNodeName} ) {
# print "Constructor...";
if ( $child->{ReturnType} =~ /~/ ) {
# A destructor
$hasPublicDestructor = 0 if $child->{Access} ne 'public';
$hasDestructor = 1;
} else {
if ( $child->{Params} eq '' && $child->{Access} ne 'private'){
# A constructor
$defaultConstructor = 1;
}
}
# $hasPublicProtectedConstructor = 1 if ( $child->{Access} ne 'private' );
# Copy constructor?
if ( $#{$child->{ParamList}} == 0 ) {
my $theArgType = @{$child->{ParamList}}[0]->{ArgType};
if ($theArgType =~ /$parentName\s*\&/) {
$hasCopyConstructor = 1;
$hasPrivateCopyConstructor = 1 if ( $child->{Access} eq 'private' );
}
}
# Hack the return type for constructors, since constructors return an object pointer
#$child->{ReturnType} = $node->{astNodeName}."*";
}
if( $child->{NodeType} eq "enum"){
$ret .= "\tenum ".$child->{astNodeName}." {".$child->{Params}."};\n";
$enums .= "\tenum ".$child->{astNodeName}." {".$child->{Params}."};\n";
}
else{
if ( $child->{NodeType} eq "typedef"){
$ret .= "\t".$child->{NodeType}." ".$child->{Type}." ".$child->{astNodeName}.";\n";
$enums .= "\t".$child->{NodeType}." ".$child->{Type}." ".$child->{astNodeName}.";\n";
}
else{
$ret .= generateMethodsCode( $child, $parentName, 0, $definition, $inline );
}
}
if ( defined $definition && defined $writerSub ) {
if ( defined $inline ) { $ret .= "\t"; }
$ret .= "{\n";
$ret .= &$writerSub( $child );
if ( defined $inline ) { $ret .= "\t"; }
$ret .= "}\n";
}
}
if ( $defaultConstructor == 0)
{
#print "Private ctor for $node->{astNodeName}\n";
$ret .= "private:\n\t";
$ret .= $node->{astNodeName}."();\n";
}
if ( $hasCopyConstructor == 1 && $hasPrivateCopyConstructor == 1)
{
#print "Private copy ctor for $node->{astNodeName}\n";
$ret .= "private:\n\t";
$ret .= $node->{astNodeName}."(const ".$node->{astNodeName}."& );\n";
}
if ( $hasPublicDestructor == 0)
{
#print "Private dtor for $node->{astNodeName}\n";
$ret .= "private:\n\t";
$ret .= "~".$node->{astNodeName}."();\n";
}
if ( $enums ne "")
{
print "inlineing enums...\n";
$ret .= "\n\n%{\n";
$ret .= $enums;
$ret .= "%}\n";
}
return $ret;
}
sub definitionParentWriter
{
my ($child) = @_;
my $ret = "\t\t$child->{Parent}->{astNodeName}::$child->{astNodeName}\( ";
$ret .= pureParamNames( $child );
$ret .= ");\n";
return $ret;
}
sub bridgeWriter
{
my ($child) = @_;
my $ret = "\t\t$child->{astNodeName}Protected\( ";
$ret .= pureParamNames( $child );
$ret .= ");\n";
return $ret;
}
# returns a list of parameter names for $method in the form:
# "a,b,c,d", suitable to call another method with the same
# parameters
sub pureParamNames($)
{
my $method = shift;
my $ret = "";
my @params = $method->{ParamList};
foreach my $arg (@params) {
if ( $arg ) {
my @arr = @{$arg};
my $num = @arr;
foreach my $param ( @{$arg} ) {
$ret .= " $param->{ArgName}";
--$num;
$ret .= ", " if $num;
}
}
}
return $ret;
}
sub mangledProtectedDeclarations($$$;$$$)
{
my ($node, $parentName, $mangle, $definition, $writerSub, $inline) = @_;
my $accessType = "";
my @methods;
my $ret = "";
Iter::MembersByType ( $node, undef,
sub { my ($classNode, $methodNode ) = @_;
if ( $methodNode->{NodeType} eq "method" ) {
if ( $methodNode->{Access} eq "protected" ||
$methodNode->{Access} eq "protected_slots" ) {
push @methods, $methodNode;
}
}
}, undef );
foreach my $child ( @methods ) {
if ( $child->{Access} ne $accessType ) {
$accessType = $child->{Access};
if ( ! (defined $definition ) ) {
if ( $accessType eq "protected_slots" ) {
$ret .= "protected: //slots\n";
} else {
$ret .= "$accessType:\n";
}
}
}
$ret .= generateMethodsCode( $child, $parentName, $mangle, $definition, $inline );
if ( defined $definition && defined $writerSub ) {
if ( defined $inline ) { $ret .= "\t"; }
$ret .= "{\n";
#FIXME : from which of the parents does the method come from?
$ret .= &$writerSub( $child );
if ( defined $inline ) { $ret .= "\t"; }
$ret .= "}\n";
}
}
return $ret;
}
sub neededImportsForObject($)
{
my ($node) = @_;
# our @imports;
my @imports;
Iter::MembersByType ( $node,
sub { },
sub { my ($node, $kid ) = @_;
if ( $kid->{NodeType} eq "method" &&
$kid->{Access} eq "public" &&
$kid->{astNodeName} !~ /qt_/
) {
#print "Method: $kid->{ReturnType} $kid->{astNodeName}\n";
my @params = $kid->{ParamList};
foreach my $arg (@params) {
if ( $arg ) {
foreach my $param ( @{$arg} ) {
my $pname = convertType($param->{ArgType});
if ( $pname !~ /\bQ_[A-Z0-9_]+/ &&
$pname =~ /\bQ[A-Za-z0-9_]+/ &&
$& ne $node->{astNodeName}
) {
push @imports, checkObj($&);
#print "Adding $&\n";
}
}
}
}
my $pname = convertType($kid->{ReturnType});
if ( $pname !~ /\bQ_[A-Z0-9_]+/ &&
$pname =~ /\bQ[A-Za-z0-9_]+/ &&
$& ne $node->{astNodeName}
) {
push @imports, checkObj($&);
#print "Adding $&\n";
}
}
},
sub { }
);
my %seen = ();
my @uniq;
foreach my $item (@imports) {
push(@uniq, $item) unless $seen{$item}++;
}
return @uniq;
}
sub convertType($)
{
my ($item) = @_;
#print "-$item-\n";
if (exists $typedeflist{$item}) {
print "$item change to $typedeflist{$item}\n";
return $typedeflist{$item};
} else {
return $item;
}
}
sub checkObj($)
{
my ($item) = @_;
# Yes some of this is in kalyptusDataDict's ctypemap
# but that one would need to be separated (builtins vs normal classes)
my $node = kdocAstUtil::findRef( $rootnode, $item );
#print "Data item $item is a $node->{Access} node $node->{astNodeName}\n";
return $node->{astNodeName};
}
sub generateNeededTemplatesForObject($)
{
my ($node) = @_;
Iter::MembersByType ( $node,
sub { },
sub { my ($node, $kid ) = @_;
if ( $kid->{NodeType} eq "method" ) {
my @params = $kid->{ParamList};
foreach my $arg (@params) {
if ( $arg ) {
foreach my $param ( @{$arg} ) {
my $pname = $param->{ArgType};
if ( $pname =~ /\b(Q[A-Za-z0-9_]+)\<([A-Za-z0-9_]+)\>/ ) {
my $cname = $1;
my $tname = $2;
if ( $tname eq "type" || $tname eq "T"){
$tname = "int";
}else{
print "Template $1::$2 in $pname\n";
print SWIG_HEADER "\%template($tname",$cname,") $cname"."<",$tname,">;\n";
}
}
}
}
}
my $returnName = $kid->{ReturnType};
if ( $returnName =~ /\b(Q[A-Za-z0-9_]+)\<([A-Za-z0-9_]+)\>/ ) {
my $cname = $1;
my $tname = $2;
if ( $tname eq "type" || $tname eq "T"){
$tname = "int";
#}else{
print "Template $1::$2 in $returnName\n";
print SWIG_HEADER "\%template($tname",$cname,") $cname"."<",$tname,">;\n";
}
}
}
},
sub { }
);
}
sub generateHeader($$)
{
my ($node, $filename) = @_;
open ( HEADER, ">$outputdir/$filename" ) || die "Can't open header $filename\n";
print HEADER documentationHeader( $filename, "header file" );
my $macro = uc $filename;
$macro =~ s/\./_/g;
print HEADER "#ifndef ", $macro, "\n";
print HEADER "#define ", $macro, "\n";
print HEADER "class $node->{astNodeName}Bridge;\n";
my @parentNames = parentClassNames($node);
my $len = @parentNames;
if ( $len ) {
print HEADER "\n";
print HEADER "$node->{NodeType} ",$typeprefix,$node->{astNodeName}," ";
my $idx = 0;
my $start = 0;
while ( $len-- ) {
if ( $len ) {
if ($parentNames[$idx] ) {
if ( !$start ) {
print HEADER ": ";
$start = 1;
}
print HEADER " public ",$typeprefix,"$parentNames[$idx],\n\t" if $parentNames[$idx];
}
} else {
if ($parentNames[$idx] ) {
if ( !$start ) {
print HEADER ": ";
$start = 1;
}
print HEADER " public ",$typeprefix,"$parentNames[$idx]\n" if $parentNames[$idx];
}
}
++$idx;
}
} else {
print HEADER "$node->{NodeType} $node->{astNodeName} ";
}
print HEADER "{\n";
print HEADER normalMethodDeclarations( $node, $typeprefix + $node->{NodeType} );
my $prot = mangledProtectedDeclarations( $node, $typeprefix + $node->{NodeType}, 0 );
$prot =~ s/protected\:/public\:/g;
print HEADER $prot;
print HEADER "private:\n";
print HEADER "\t$node->{astNodeName}Bridge *mBridge;\n";
print HEADER "};\n\n";
print HEADER "#endif //", uc $filename, "\n";
close HEADER;
}
sub generateBridge($*)
{
my($node, $fh) = @_;
print $fh "$node->{NodeType} $node->{astNodeName}Bridge : public $node->{astNodeName}\n";
print $fh "{\n";
# print $fh "public:\n";
# print $fh normalMethodDeclarations( $node, $node->{astNodeName}."Bridge" , 1, sub { definitionParentWriter(@_) }, 1 );
print $fh "public:\n";
print $fh mangledProtectedDeclarations( $node, $node->{astNodeName}."Bridge", 1, 1, sub { definitionParentWriter(@_) }, 1 );
print $fh "protected:\n";
print $fh mangledProtectedDeclarations( $node, $node->{astNodeName}."Bridge", 0, 1, sub { bridgeWriter(@_) }, 1 );
print $fh "\n";
print $fh "\n";
print $fh "};\n";
}
sub generateWrapper($*)
{
my($node, $fh) = @_;
}
sub generateSource
{
my ($node, $filename) = @_;
open ( SOURCE, ">$outputdir/$filename" ) || die "Can't open $filename\n";
$filename =~ s/\.cpp$/\.h/;
print SOURCE "#include \"$filename\";\n\n\n";
generateBridge( $node, *SOURCE );
generateWrapper( $node, *SOURCE );
close SOURCE;
}
sub protectedMethods($)
{
}
sub documentationHeader($$)
{
my ($file, $descr) = @_;
my $ret = "/***************************************************************************\n";
$ret .= " File: $file - $descr\n";
$ret .= $docTop;
return $ret;
}
sub writeDoc
{
( $lib, $rootnode, $outputdir, $opt ) = @_;
$debug = $main::debuggen;
mkpath( $outputdir ) unless -f $outputdir;
unlink $outputdir."/interfaces_all.i";
# Document all compound nodes
Iter::LocalCompounds( $rootnode, sub { writeClassDoc( shift ); } );
}
sub addInterface($$$)
{
my ($outputdir,$typeprefix,$node) = @_;
my $interfacesFile = "interfaces_all.i";
open( IFILE, ">>$outputdir/$interfacesFile" ) || die "Can't open $outputdir/$interfacesFile";
print IFILE "%include \"$typeprefix", kdocAstUtil::heritage($node),".i\"\n";
close IFILE;
}
sub writeClassDoc
{
my( $node ) = @_;
if( exists $node->{ExtSource} ) {
print "Trying to write doc for ".$node->{AstNodeName}.
" from ".$node->{ExtSource}."\n";
return;
}
if( $node->{Access} eq "private" ||
$node->{Access} eq "protected" ) {
return;
}
my $typeName = $node->{astNodeName}."*";
if ( kalyptusDataDict::ctypemap($typeName) eq "" ) {
$typeprefix = ($typeName =~ /^Q/ ? "qt_" : "kde_");
kalyptusDataDict::setctypemap($typeName, $typeprefix.$node->{astNodeName}."*");
print "'$typeName' => '$typeprefix$typeName',\n";
} elsif ( kalyptusDataDict::ctypemap($typeName) =~ /^qt_/ ) {
$typeprefix = "qt_";
} elsif ( kalyptusDataDict::ctypemap($typeName) =~ /^kde_/ ) {
$typeprefix = "kde_";
} else {
$typeprefix = "kde_";
}
my $basefile = "$typeprefix".join("__", kdocAstUtil::heritage($node)).".i";
my $cppfile = $basefile;
$cppfile =~ s/\.i/_wrap\.cpp/;
my $file = "$outputdir/$typeprefix".join("__", kdocAstUtil::heritage($node)).".i";
my $docnode = $node->{DocNode};
my @list = ();
my $version = undef;
my $author = undef;
addInterface( $outputdir, $typeprefix, $node );
# if( $#{$node->{Kids}} < 0 || $node->{Access} eq "private" || exists $node->{Tmpl} ) {
if( $#{$node->{Kids}} < 0 || $node->{Access} eq "private") {
return;
}
open( SWIG_HEADER, ">$file" ) || die "Couldn't create $file\n";
# Header
my $short = "";
my $extra = "";
my $f = $typeprefix . $node->{astNodeName} . ".h";
my $descr = documentationHeader( $f, "header" );
print SWIG_HEADER $descr;
generateHeader( $node, $f );
$f =~ s/\.h$/\.cpp/;
generateSource( $node, $f );
if ( defined $docnode ) {
print SWIG_HEADER "/**\n";
if ( defined $docnode->{Text} ) {
my $node;
foreach $node ( @{$docnode->{Text}} ) {
next if $node->{NodeType} ne "DocText";
print SWIG_HEADER $node->{astNodeName}, "\n";
}
}
exists $docnode->{Author} && print SWIG_HEADER " \@author ", $docnode->{Author}, "\n";
exists $docnode->{Version} && print SWIG_HEADER " \@version ", $docnode->{Version}, "\n";
exists $docnode->{ClassShort} && print SWIG_HEADER " \@short ", $docnode->{ClassShort}, "\n";
print SWIG_HEADER "*/\n";
}
my $sourcename = $node->{Source}->{astNodeName};
if ( $sourcename =~ m!.*(dom|kabc|tdeprint|tdesu|kio|kjs|kparts|ktexteditor|libkmid)/([^/]*$)! ) {
$sourcename = $1."/".$2;
} else {
$sourcename =~ s!.*/([^/]*$)!$1!;
}
print SWIG_HEADER "\%module ",$typeprefix,$node->{astNodeName},"\n\n";
print SWIG_HEADER "\%{\n#include <",$sourcename , ">\n\%}\n\n";
#print SWIG_HEADER "\%import \"interfaces_all.i\"\n";
#print SWIG_HEADER "\%import \"", $basefile ,"\"\n";
# make this smarter i guess...
# my @types = neededImportsForObject($node);
# foreach my $f ( @types ) {
# print SWIG_HEADER "\%import \"qt_".$f.".i\"\n";
# }
# print SWIG_HEADER "\%import \"qt_Qt.i\"\n";
# my @impor = parentClassNames($node);
# foreach my $f ( @impor ) {
# print SWIG_HEADER "\%import \"qt_".$f.".i\"\n";
# }
# Iter::LocalCompounds( $node, sub { my ($node) = @_; print STDERR "$node->{NodeType}||$node->{astNodeName} \n"; } );
# Iter::Generic( $node, undef,
# &isNotProtectedMethod,
# sub { my ($node, $kid) = @_; debugPrint "This is :: ", $node->{astNodeName}, " | ", $kid->{astNodeName}, "\n"; },
# undef );
# Iter::MembersByType ( $node, undef,
# sub { my ($classNode, $methodNode ) = @_;
#
# if ( $methodNode->{NodeType} eq "method" ) {
# print SWIG_HEADER generateMethodsCode( $methodNode, 0 );
# }
# }, undef );
my @parentNames = parentClassNames($node);
my $len = @parentNames;
if ( $len ) {
print SWIG_HEADER "\n";
print SWIG_HEADER "$node->{NodeType} ",$node->{astNodeName}," ";
my $idx = 0;
my $start = 0;
while ( $len-- ) {
if ( $len ) {
if ($parentNames[$idx] ) {
if ( !$start ) {
print SWIG_HEADER ": ";
$start = 1;
}
print SWIG_HEADER " public $parentNames[$idx],\n\t" if $parentNames[$idx];
}
} else {
if ($parentNames[$idx] ) {
if ( !$start ) {
print SWIG_HEADER ": ";
$start = 1;
}
print SWIG_HEADER " public $parentNames[$idx]\n" if $parentNames[$idx];
}
}
++$idx;
}
} else {
print SWIG_HEADER "$node->{NodeType} $node->{astNodeName} ";
}
print SWIG_HEADER "{\n";
# my $name = $node->{astNodeName}."Bridge";
# print SWIG_HEADER normalMethodDeclarations( $node, $name, 1 );
print SWIG_HEADER normalMethodDeclarations( $node, $typeprefix + $node->{NodeType} );
print SWIG_HEADER "};\n\n\n";
# generateNeededTemplatesForObject( $node );
print SWIG_HEADER "\n";
#print SWIG_HEADER "\%inline \%{\n\n";
#print SWIG_HEADER "class ",$node->{astNodeName},";\n";
#print SWIG_HEADER "#include <",$sourcename , ">\n";
#print SWIG_HEADER $node->{astNodeName}, " *",$node->{astNodeName},"Null()\n";
#print SWIG_HEADER "{\n";
#print SWIG_HEADER "\treturn ($node->{astNodeName}*)0L;\n";
#print SWIG_HEADER "}\n\n";
#print SWIG_HEADER "\%}\n";
$constructorCount = 0;
# Iter::MembersByType ( $node,
# sub { print SWIG_HEADER "", $_[0], ""; },
# sub { my ($node, $kid ) = @_;
# preParseMember( $node, $kid );
# },
# sub { print SWIG_HEADER ""; }
# );
# if ( ! exists $node->{Pure} && $constructorCount > 0 ) {
# print SWIG_HEADER "CLASS HEADER = class ", $node->{astNodeName}, "Bridge : public ", kalyptusDataDict::addNamespace($node->{astNodeName}), "\n{\npublic:\n";
# Iter::MembersByType ( $node,
# sub { print SWIG_HEADER "", $_[0], ""; },
# sub { my ($node, $kid ) = @_;
# generateBridgeClass( $node, $kid );
# },
# sub { print SWIG_HEADER ""; }
# );
# generateBridgeEventHandlers($node);
# }
%functionId = ();
$eventHandlerCount = 0;
# Iter::MembersByType ( $node,
# sub { print SWIG_HEADER "", $_[0], ""; },
# sub { my ($node, $kid ) = @_;
# listMember( $node, $kid );
# },
# sub { print SWIG_HEADER ""; }
# );
# ancestors
# my @ancestors = ();
# Iter::Ancestors( $node, $rootnode, undef, undef,
# sub { # print
# my ( $ances, $name, $type, $template ) = @_;
#
# push @ancestors, $name;
#
# },
# undef
# );
# if ( $#ancestors > 0 ) {
# # 'type transfer' functions to cast for correct use of multiple inheritance
# foreach my $ancestor (@ancestors) {
# print SWIG_HEADER "\n/\*\* Casts a '$typeprefix", $node->{astNodeName}, " *' to a '", kalyptusDataDict::ctypemap($ancestor."\*"), "' \*/\n";
# print SWIG_HEADER kalyptusDataDict::ctypemap($ancestor."\*"), " ", $typeprefix, $node->{astNodeName}, "_", $ancestor;
# print SWIG_HEADER "(", $typeprefix, $node->{astNodeName}, "* instPointer);\n";
# print CLASS kalyptusDataDict::ctypemap($ancestor."\*"), " ", $typeprefix, $node->{astNodeName}, "_", $ancestor;
# print CLASS "(", $typeprefix, $node->{astNodeName}, "* instPointer){\n";
# print CLASS "\treturn (", kalyptusDataDict::ctypemap($ancestor."\*"), ") (", $ancestor, " *) (", $node->{astNodeName}, " *) instPointer;\n}\n";
# }
# }
close SWIG_HEADER;
}
###################################################################################
1;

File diff suppressed because it is too large Load Diff

@ -442,6 +442,33 @@ sub inheritedBy
}
}
=head2 inheritsAsVirtual
Parameters: (selfNode) classNode
Tells if C<classNode> is a virtual ancestor of C<selfNode>
e.g: $self->kdocAstUtil::inheritsAsVirtual($other)
=cut
sub inheritsAsVirtual
{
my ( $self, $node ) = @_;
return 0 unless exists $self->{InList};
for my $in( @{ $self->{InList} } )
{
return 1 if
inheritName($in) eq $node->{astNodeName} and
$in->{Type} =~ /virtual/;
return 1 if $in->{Node} &&
$in->{Node}->kdocAstUtil::inheritsAsVirtual( $node );
}
return 0
}
=head2 hasLocalInheritor
Parameter: node

@ -29,7 +29,7 @@ NOTES ON THE NEW FORMAT
<! KDOC Library HTML Reference File>
<VERSION="2.0">
<BASE URL="http://www.kde.org/API/kdecore/">
<BASE URL="http://www.kde.org/API/tdecore/">
<C NAME="KApplication" REF="KApplication.html">
<IN NAME="TQObject">

@ -85,6 +85,9 @@ PARSELOOP:
elsif ( $text =~ /^\s*\@deprecated\s*/ ) {
codeProp( "Deprecated", 1 );
}
elsif ( $text =~ /^\s*\@obsolete\s*/ ) {
codeProp( "Deprecated", 1 );
}
elsif ( $text =~ /^\s*\@reimplemented\s*/ ) {
codeProp( "Reimplemented", 1 );
}

@ -161,23 +161,28 @@ sub splitUnnested($$) {
my $depth = 0;
my $start = 0;
my $indoublequotes = 0;
while($string =~ /($delim|<<|>>|[][}{)(><\"])/g) {
my $insinglequotes = 0;
while($string =~ /($delim|<<|>>|[][}{)(><\"\'])/g) {
my $c = $1;
if(!$depth and !$indoublequotes and $c eq $delim) {
my $len = pos($string) - $start - 1;
push @ret, substr($string, $start, $len);
$start = pos($string);
} elsif($open{$c}) {
$depth++;
} elsif($close{$c}) {
$depth--;
} elsif($c eq '"') {
if ($indoublequotes) {
$indoublequotes = 0;
} else {
if(!$insinglequotes and !$indoublequotes) {
if(!$depth and $c eq $delim) {
my $len = pos($string) - $start - 1;
push @ret, substr($string, $start, $len);
$start = pos($string);
} elsif( $c eq "'") {
$insinglequotes = 1;
} elsif( $c eq '"') {
$indoublequotes = 1;
}
}
} elsif($open{$c}) {
$depth++;
} elsif($close{$c}) {
$depth--;
}
} elsif($c eq '"' and $indoublequotes) {
$indoublequotes = 0;
} elsif ($c eq "'" and $insinglequotes) {
$insinglequotes = 0;
}
}
my $subs = substr($string, $start);

@ -0,0 +1 @@
/usr/bin/perl
Loading…
Cancel
Save