Commit 67247534 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

replace perl scripts by gen-introspect, rename gidlgen to

2007-10-26  Juerg Billeter  <j@bitron.ch>

	* configure.ac, doc/Makefile.am, doc/gidlgen.1,
	  doc/vala-gen-introspect.1, doc/vapigen.1, vapigen/gidlgen/Makefile.am,
	  vapigen/gidlgen/gapi2xml.pl, vapigen/gidlgen/gapi_pp.pl,
	  vapigen/gidlgen/gidlgen.in, vapigen/gidlgen/vala-gen-introspect.in,
	  vapigen/valagidlparser.vala: replace perl scripts by gen-introspect,
	  rename gidlgen to vala-gen-introspect

svn path=/trunk/; revision=661
parent b70d052d
2007-10-26 Jürg Billeter <j@bitron.ch>
* configure.ac, doc/Makefile.am, doc/gidlgen.1,
doc/vala-gen-introspect.1, doc/vapigen.1, vapigen/gidlgen/Makefile.am,
vapigen/gidlgen/gapi2xml.pl, vapigen/gidlgen/gapi_pp.pl,
vapigen/gidlgen/gidlgen.in, vapigen/gidlgen/vala-gen-introspect.in,
vapigen/valagidlparser.vala: replace perl scripts by gen-introspect,
rename gidlgen to vala-gen-introspect
2007-10-26 Jürg Billeter <j@bitron.ch>
* configure.ac, gobject-introspection/Makefile.am,
......
......@@ -65,6 +65,6 @@ AC_CONFIG_FILES([Makefile
gobject-introspection/Makefile
vapigen/Makefile
vapigen/gidlgen/Makefile
vapigen/gidlgen/gidlgen])
vapigen/gidlgen/vala-gen-introspect])
AC_OUTPUT
......@@ -6,7 +6,7 @@ SUBDIRS = \
if ENABLE_VAPIGEN
VAPIGEN_MANS = \
gidlgen.1 \
vala-gen-introspect.1 \
vapigen.1 \
$(NULL)
endif
......@@ -18,7 +18,7 @@ man_MANS = \
EXTRA_DIST = \
valac.1 \
gidlgen.1 \
vala-gen-introspect.1 \
vapigen.1 \
$(NULL)
.TH gidlgen 1 "28 August 2007" "vala-0.1.2" "Vala"
.IX gidlgen
.TH vala-gen-introspect 1 "26 October 2007" "vala-0.1.5" "Vala"
.IX vala-gen-introspect
.SH NAME
gidlgen \- generate a GAPI file for GObject and glib based packages
vala-gen-introspect \- generate a GI file for GObject and glib based packages
.SH SYNOPSIS
.B gidlgen \fISOURCE\fP \fIPKGBASE\fP
.B vala-gen-introspect \fIPKGNAME\fP \fIPKGBASE\fP
.SH DESCRIPTION
.B gidlgen
is a utility which generates GAPI files from GObject and glib
.B vala-gen-introspect
is a utility which generates GI files from GObject and glib
based packages. It can be used in combination with vapigen(1) to
generate an API for Vala, and allow it's usage in Vala for compiling
to native code. \fISOURCE\fP is the source package bundle (tarball)
to native code. \fIPKGNAME\fP is the pkg-config name of the library
and \fIPKGBASE\fP specifies the base directory for that package.
.SH EXAMPLES
.TP
After compilation, the following command generates a GAPI for pango:
.B gidlgen pango-1.16.1.tar.bz2 packages/pango/pango
After compilation, the following command generates a GI for pango:
.B vala-gen-introspect pango packages/pango
.SH OPTIONS
.TP
......@@ -25,7 +25,7 @@ This command currenly takes no command line options.
.BR vapigen (1)
.SH AUTHOR
gidlgen for Vala was written by Juerg Billeter <j@bitron.ch> and
vala-gen-introspect for Vala was written by Juerg Billeter <j@bitron.ch> and
Raffaele Sandrini <rasa@gmx.ch>.
.PP
This manual page was written by Kumar Appaiah <akumar@ee.iitm.ac.in>,
......
.TH vapigen 1 "28 August 2007" "vala-0.1.2" "Vala"
.TH vapigen 1 "26 October 2007" "vala-0.1.5" "Vala"
.IX vapigen
.SH NAME
vapigen \- generate a Vala API
......@@ -7,16 +7,16 @@ vapigen \- generate a Vala API
[\fIOPTION\fR]... [\fIFILE\fR]...
.SH DESCRIPTION
.B vapigen
is a utility which generates Vala API (VAPI) files from GAPI files,
which may be generated using the gidlgen(1) utility.
is a utility which generates Vala API (VAPI) files from GI files,
which may be generated using the vala-gen-introspect(1) utility.
.SH EXAMPLES
.TP
After compilation, the following command generates a GAPI for pango:
.B gidlgen pango-1.16.1.tar.bz2 packages/pango/pango
After compilation, the following command generates a GI for pango:
.B vala-gen-introspect pango packages/pango
.TP
This can then be converted to a Vala API as follows:
.B vapigen --pkg cairo --vapidir . --library pango packages/pango/pango.gidl
.B vapigen --pkg cairo --vapidir . --library pango packages/pango/pango.gi
.SH OPTIONS
.TP
......@@ -39,7 +39,7 @@ Specify output directory as \fIDIRECTORY\fP
Display version number and exit.
.SH SEE ALSO
.BR gidlgen (1)
.BR vala-gen-introspect (1)
.SH AUTHOR
vapigen for Vala was written by Juerg Billeter <j@bitron.ch> and
......
NULL =
bin_SCRIPTS = \
gidlgen \
$(NULL)
pkglibexecdir = $(libdir)/vala
dist_pkglibexec_SCRIPTS = \
gapi2xml.pl \
gapi_pp.pl \
vala-gen-introspect \
$(NULL)
EXTRA_DIST = \
gidlgen.in
vala-gen-introspect.in
$(NULL)
This diff is collapsed.
#!/usr/bin/perl
#
# gapi_pp.pl : A source preprocessor for the extraction of API info from a
# C library source directory.
#
# Authors: Mike Kestner <mkestner@speakeasy.net>
# Martin Willemoes Hansen <mwh@sysrq.dk>
#
# Copyright (c) 2001 Mike Kestner
# Copyright (c) 2003 Martin Willemoes Hansen
# Copyright (c) 2003-2004 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
$private_regex = '^#if.*(ENABLE_BACKEND|ENABLE_ENGINE)';
$eatit_regex = '^#if(.*(__cplusplus|DEBUG|DISABLE_COMPAT|ENABLE_BROKEN)|\s+0\s*$)';
$ignoreit_regex = '^\s+\*|#ident|#error|#\s*include|#\s*else|#\s*undef|G_(BEGIN|END)_DECLS|GDKVAR|GTKVAR|GTKMAIN_C_VAR|GTKTYPEUTILS_VAR|VARIABLE|GTKTYPEBUILTIN';
foreach $arg (@ARGV) {
if (-d $arg && -e $arg) {
@hdrs = (@hdrs, `ls $arg/*.h`);
@srcs = (@srcs, `ls $arg/*.c`);
} elsif (-f $arg && -e $arg) {
@hdrs = (@hdrs, $arg) if ($arg =~ /\.h$/);
@srcs = (@srcs, $arg) if ($arg =~ /\.c$/);
} else {
die "unable to process arg: $arg";
}
}
foreach $fname (@hdrs) {
if ($fname =~ /test|private|internals|gtktextlayout|gtkmarshalers/) {
@privhdrs = (@privhdrs, $fname);
next;
}
open(INFILE, $fname) || die "Could open $fname\n";
$braces = 0;
$deprecated = -1;
$ifdeflevel = 0;
$prepend = "";
while ($line = <INFILE>) {
$braces++ if ($line =~ /{/ and $line !~ /}/);
$braces-- if ($line =~ /}/ and $line !~ /{/);
next if ($line =~ /$ignoreit_regex/);
$line =~ s/\/\*[^<].*?\*\///g;
next if ($line !~ /\S/);
$line = $prepend . $line;
$prepend = "";
if ($line =~ /#\s*define\s+\w+\s+\"/) {
$def = $line;
while ($def !~ /\".*\"/) {$def .= ($line = <INFILE>);}
print $def;
} elsif ($line =~ /#\s*define\s+\w+\s*\D+/) {
$def = $line;
while ($line =~ /\\\n/) {$def .= ($line = <INFILE>);}
if ($def =~ /_CHECK_\w*CAST|INSTANCE_GET_INTERFACE/) {
$def =~ s/\\\n//g;
print $def;
}
} elsif ($line =~ /^\s*\/\*[^<]/) {
while ($line !~ /\*\//) {$line = <INFILE>;}
} elsif ($line =~ /^extern/) {
while ($line !~ /;/) {$line = <INFILE>;}
} elsif ($line =~ /^#ifndef\s+\w+_H_*\b/) {
while ($line !~ /#define/) {$line = <INFILE>;}
} elsif ($line =~ /$private_regex/) {
$nested = 0;
while ($line = <INFILE>) {
last if (!$nested && ($line =~ /#else|#endif/));
if ($line =~ /#if/) {
$nested++;
} elsif ($line =~ /#endif/) {
$nested--
}
next if ($line !~ /^struct/);
print "private$line";
do {
$line = <INFILE>;
print $line;
} until ($line =~ /^\}/);
}
} elsif ($line =~ /$eatit_regex/) {
$nested = 0;
while ($line = <INFILE>) {
last if (!$nested && ($line =~ /#else|#endif/));
if ($line =~ /#if/) {
$nested++;
} elsif ($line =~ /#endif/) {
$nested--
}
}
} elsif ($line =~ /^#\s*ifn?\s*\!?def/) {
$ifdeflevel++;
#print "#ifn?def ($ifdeflevel): $line\n";
if ($line =~ /#ifndef.*DISABLE_DEPRECATED/) {
$deprecated = $ifdeflevel;
} elsif ($line =~ /#if !defined.*DISABLE_DEPRECATED/) {
$deprecated = $ifdeflevel;
}
} elsif ($line =~ /^#\s*endif/) {
#print "#endif ($ifdeflevel): $line\n";
if ($deprecated == $ifdeflevel) {
$deprecated = -1;
}
$ifdeflevel--;
} elsif ($line =~ /typedef struct\s*\{/) {
my $first_line = $line;
my @lines = ();
$line = <INFILE>;
while ($line !~ /^}\s*(\w+);/) {
push @lines, $line;
$line = <INFILE>;
}
$line =~ /^}\s*(\w+);/;
my $name = $1;
print "typedef struct _$name $name;\n";
print "struct _$name {\n";
foreach $line (@lines) {
if ($line =~ /(\s*.+\;)/) {
$field = $1;
$field =~ s/(\w+) const/const $1/;
print "$field\n";
}
}
print "};\n";
} elsif ($line =~ /^enum\s+\{/) {
while ($line !~ /^};/) {$line = <INFILE>;}
} elsif ($line =~ /^(typedef\s+)?union/) {
next if ($line =~ /^typedef\s+union\s+\w+\s+\w+;/);
while ($line !~ /^};/) {$line = <INFILE>;}
} elsif ($line =~ /(\s+)union\s*{/) {
# this is a hack for now, but I need it for the fields to work
$indent = $1;
$do_print = 1;
while ($line !~ /^$indent}\s*\w+;/) {
$line = <INFILE>;
next if ($line !~ /;/);
print $line if $do_print;
$do_print = 0;
}
} else {
if ($braces or $line =~ /;|\/\*/) {
if ($deprecated == -1) {
print $line;
} else {
print "deprecated$line";
}
} else {
$prepend = $line;
$prepend =~ s/\n/ /g;
}
}
}
}
foreach $fname (@srcs, @privhdrs) {
open(INFILE, $fname) || die "Could open $fname\n";
if ($fname =~ /builtins_ids/) {
while ($line = <INFILE>) {
next if ($line !~ /\{/);
chomp($line);
$builtin = "BUILTIN" . $line;
$builtin .= <INFILE>;
print $builtin;
}
next;
}
while ($line = <INFILE>) {
next if ($line !~ /^(struct|\w+_class_init|\w+_base_init|\w+_get_type\b|G_DEFINE_TYPE_WITH_CODE)/);
if ($line =~ /^G_DEFINE_TYPE_WITH_CODE/) {
my $macro;
my $parens = 0;
do {
chomp ($line);
$line =~ s/(.*)\\$/\1/;
$line =~ s/^\s+(.*)/ \1/;
$macro .= $line;
foreach $chr (split (//, $line)) {
if ($chr eq "(") {
$parens++;
} elsif ($chr eq ")") {
$parens--;
}
}
$line = <INFILE>;
} while ($parens > 0);
print "$macro\n";
next if ($line !~ /^(struct|\w+_class_init|\w+_base_init)/);
}
if ($line =~ /^struct/) {
# need some of these to parse out parent types
print "private";
if ($line =~ /;/) {
print $line;
next;
}
}
$comment = 0;
$begin = 0;
$end = 0;
do {
# Following ifs strips out // and /* */ C comments
if ($line =~ /\/\*/) {
$comment = 1;
$begin = 1;
}
if ($comment != 1) {
$line =~ s/\/\/.*//;
print $line;
}
if ($line =~ /\*\//) {
$comment = 0;
$end = 1;
}
if ($begin == 1 && $end == 1) {
$line =~ s/\/\*.*\*\///;
print $line;
}
$begin = 0;
$end = 0;
} until (($line = <INFILE>) =~ /^}/);
print $line;
}
}
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
pkglibdir=${libdir}/vala
SOURCE=$1
PKGBASE=$2/$3
if [ $# -ne 3 ]
then
echo "Usage: `basename $0` SOURCE BASEPATH PKGNAME"
exit 1
fi
EXCLUDES=
if [ -e $PKGBASE.excludes ]
then
EXCLUDES="-X $PKGBASE.excludes"
fi
rm -rf $PKGBASE-src $PKGBASE.raw
mkdir -p $PKGBASE-src
tar -C $PKGBASE-src -xf $SOURCE $EXCLUDES --strip-components=1
if [ -e $PKGBASE.patch ]
then
# use < instead of -i to use current working directory as base
patch -d $PKGBASE-src -Np1 < $PKGBASE.patch
fi
rm -f $PKGBASE.gidl
perl $pkglibdir/gapi_pp.pl `cat $PKGBASE.files | sed -e "s@^@$PKGBASE-src/@"` | perl $pkglibdir/gapi2xml.pl $(cat $PKGBASE.namespace) $PKGBASE.gidl
rm -rf $PKGBASE-src
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
pkglibdir=${libdir}/vala
if [ $# -ne 2 ]
then
echo "Usage: `basename $0` PKGNAME BASEPATH"
exit 1
fi
PKGNAME=$1
PKGBASE=$2/$1
PKGPREFIX=`pkg-config --variable=prefix $PKGNAME`
PKGFILES=`cat $PKGBASE.files | sed -e "s@^@$PKGPREFIX/@"`
if [ -e $PKGBASE.excludes ]
then
FILES=`find $PKGFILES -name "*.h" -or -name "*.so" | grep -v -f $PKGBASE.excludes`
else
FILES=`find $PKGFILES -name "*.h" -or -name "*.so"`
fi
$pkglibdir/gen-introspect --namespace=`cat $PKGBASE.namespace` -U__GNUC__ `pkg-config --cflags $PKGNAME` $FILES > $PKGBASE.gi
......@@ -88,13 +88,13 @@ public class Vala.GIdlParser : CodeVisitor {
}
public override void visit_source_file (SourceFile! source_file) {
if (source_file.filename.has_suffix (".gidl")) {
if (source_file.filename.has_suffix (".gi")) {
parse_file (source_file);
}
}
private void parse_file (SourceFile! source_file) {
string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.size () - ".gidl".size ()));
string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.size () - ".gi".size ()));
current_source_file = source_file;
......@@ -1208,10 +1208,6 @@ public class Vala.GIdlParser : CodeVisitor {
if (type == null) {
return null;
}
if (!field_node.readable) {
return null;
}
var attributes = get_attributes ("%s.%s".printf (current_data_type.get_cname (), node.name));
if (attributes != null) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment