#!@PERL@ # # Jakelib2 - General purpose C++ library # Copyright (C) 2001 Florian Wolff (florian@donuz.de) # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # $Id: jakelib2-newclass.in,v 1.14 2003/02/09 12:39:09 florian Exp $ # use Getopt::Long; use Symbol; my $SRC_DIR="src"; my $INCLUDE_DIR="src"; my $fullClassName; my $PROJECTNAME=""; my $PROJECTABSTRACT=""; my $AUTHOR=""; my $EMAIL="email\@domain.org"; my $INCLUDEMACROPREFIX="INCLUDED_"; my $YEAR="2003"; my $LICENCE="gpl"; my $SKIPFIRST; sub usage { print < [--src=] [--inc=] [--proj=] [--abstract=] [--year=] [--author=] [--email=] [--license=gpl|lgpl] [--skipfirst] EOF ; exit 1; } # Get command line options: &GetOptions('src=s' => \$SRC_DIR, 'include|inc=s' => \$INCLUDE_DIR, 'proj=s' => \$PROJECTNAME, 'abstract=s' => \$PROJECTABSTRACT, 'year=s' => \$YEAR, 'author=s' => \$AUTHOR, 'email=s' => \$EMAIL, 'license=s' => \$LICENSE, 'skipfirst' => \$SKIPFIRST ); $fullClassName = $ARGV[0]; if (!defined $fullClassName) { usage(); } # Check class name: my @package = split("\\.|::|/", $fullClassName); my $className; foreach(@package) { if ($_ eq "") { print "Invalid classname: '$fullClassName'\n"; exit 2; } } # Display info: print <".$headerFile) || die; print $output $text; close ($output); # Create .JLC file: my $sourceFile = "$srcDir/$className.jlc"; my $text; print " . creating $sourceFile\n"; my $jakelibPackage = ""; foreach(@package) { $jakelibPackage .= "$_."; } $jakelibPackage = substr($jakelibPackage, 0, length($jakelibPackage) -1) . "." . $className; my $cppPackage = ""; foreach(@package) { $cppPackage .= $_ . "::"; } $cppPackage = substr($cppPackage, 0, length($cppPackage) -2); my $comment = " * $className" . substr(" ", 0, 75-length($className)) . "|"; $text = < #include #include "$headerFile" using namespace jakelib::lang; using namespace $cppPackage; JAKELIB_IMPLEMENT_CLASS("$jakelibPackage", $className, Object); JAKELIB_IMPLEMENT_ARRAY($className); /*****************************************************************************\\ $comment *****************************************************************************/ ${className}::$className() { } EOF ; my $output = &gensym; open ($output, ">".$sourceFile) || die; print $output $text; close ($output);