Commit Graph

69 Commits

Author SHA1 Message Date
Owen Taylor
7fa1ffa6e7 Bug 560419 – Cache includes when parsing
Keep track of all modules parsed within a GIrParser, and when a
module is referenced a second time, use the existing parsed copy
instead of reparsing.

svn path=/trunk/; revision=906
2008-11-12 17:17:15 +00:00
Owen Taylor
9a36a18939 Fix management of ParseContext.includes_modules (#560419)
Fix some trivial bugs in managing the list of include modules.
(Add to module's list twice, not initialized to NULL, not freed.)

svn path=/trunk/; revision=905
2008-11-12 17:17:08 +00:00
Owen Taylor
b1c6e64049 Keep aliases and disguised_structures local to each module (#560419)
When parsing, keep keep a separate hash tables of aliases and
'disguised' flags for each module, and store that on the module.

After parsing an include merge the aliases/disguised flags to the
including module.

Remove 'prefix_aliases' flag and always prefix aliases/disguised
structure types when parsing; this simplifies the code considerably.

svn path=/trunk/; revision=904
2008-11-12 17:17:01 +00:00
Owen Taylor
102e08428b Only allow one <namespace/> element per <repository/> (#560419)
The logic in girparser.c didn't work very well if there were multiple
<namespace/> nodes within a single <repository/> (context->namespace
was always the overall filename and not the the name specified in the
<namespace/> element for one thing; this would cause aliases to
be mis-prefixed in include modules.) Also check that the "name" in
the <namespace/> node matches the filename.

svn path=/trunk/; revision=902
2008-11-12 17:16:49 +00:00
Owen Taylor
0faf142d0a Add a GirParser object to hold the state of a compilation
Add a toplevel GirParser object to hold state that is global across
a compilation. Currently just holds the include path, but will
eventually also keep a cached list of parsed modules.

svn path=/trunk/; revision=901
2008-11-12 17:16:42 +00:00
Johan Bilien
7bada628b9 Bug 560474 – g-ir-compiler crashes when compiling the glib gir
2008-11-12  Johan Bilien  <jobi@via.ecp.fr>

	Bug 560474 – g-ir-compiler crashes when compiling the glib gir

	* girepository/girparser.c: avoid freeing an uninitialized pointer


svn path=/trunk/; revision=891
2008-11-12 12:12:04 +00:00
Owen Taylor
744f3a3004 Bug 560404 – Prefix types when resolving aliases in included modules
* girepository/girparser.c: When resolving aliases in an included
module, prefix types before looking them up.

svn path=/trunk/; revision=889
2008-11-11 22:02:37 +00:00
Owen Taylor
ecc78cf338 Search provided include dirs before the default directories.
2008-11-11  Owen Taylor  <otaylor@redhat.com>

        * girepository/girparser.c: Search provided include dirs before
        the default directories.

svn path=/trunk/; revision=885
2008-11-11 15:25:59 +00:00
Owen Taylor
01fda94550 girepository/girparser.c: Remove an unused variable.
svn path=/trunk/; revision=879
2008-11-11 05:11:05 +00:00
Owen Taylor
d680962438 Remove field offsets from g-ir-generate output and test inputs
Field offsets are a) architecture dependent so they shouldn't be part
of the architecture-independent gir format which is installed in
datadir. b) Are architecture-dependent so they shouldn't be in test
expected output. Remove field offsets from girs.
(Virtual function and discriminator offsets are not removed, as they
aren't fully hooked up to the field-offset computation machinery yet.)

svn path=/trunk/; revision=877
2008-11-11 05:10:47 +00:00
Owen Taylor
6d9212674a Bug 560250 - Fully parse included modules
For some things, like computing structure offsets to put into the typelib
we need more than just the aliases from included modules. Do a completel
parse of included modules and store in module->included_modules.

Also add g_ir_find_node() to find node information from within the
active set of modules and their includes.

svn path=/trunk/; revision=874
2008-11-11 00:48:17 +00:00
Owen Taylor
8c88777cfb Bug 560248 – "disguised structures"
Certain types like GIConv and GdkAtom are pointers internally but don't
look like pointers when referenced. They have the form.

 typedef struct _X *X;

Parse these as structures/records but mark them in the gir with a 'disguised'
attribute so that we know that they need special handling.

In the typelib treat them like any other structure.

svn path=/trunk/; revision=872
2008-11-10 23:58:49 +00:00
Colin Walters
832328d59a Bug 557786 - support fixed size arrays
svn path=/trunk/; revision=814
2008-10-25 15:20:54 +00:00
Tommi Komulainen
2d0f1b3093 Bug 556739 – transfer-ownership attribute should be mandatory in .gir
2008-10-23  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* girepository/girparser.c (parse_param_transfer):
	* giscanner/transformer.py (_create_parameter, _create_return):
	* giscanner/girwriter.py (_write_return, _write_parameter):
	* tools/generate.c (write_callable_info): always write and
	require "transfer-ownership" for return-values and parameters

	* tests/boxed.gir:
	* tests/invoke/testfns-1.0.gir:
	* tests/object.gir:
	* tests/scanner/DrawableAdditions.xml:
	* tests/scanner/GtkFrob-1.0-expected.tgir:
	* tests/scanner/annotation-1.0-expected.tgir:
	* tests/scanner/drawable-1.0-expected.tgir:
	* tests/scanner/drawable-injected-1.0-expected.gir:
	* tests/scanner/drawable-injected-1.0-expected.tgir:
	* tests/scanner/foo-1.0-expected.tgir: Updated

svn path=/trunk/; revision=797
2008-10-23 17:42:25 +00:00
Lucas Rocha
9a32d9b093 fix some build warnings.
2008-10-22  Lucas Rocha  <lucasr@gnome.org>

	* girepository/girmodule.c, girepository/gtypelib.c,
	girepository/girparser.[ch]: fix some build warnings.

svn path=/trunk/; revision=783
2008-10-22 14:31:58 +00:00
Tommi Komulainen
04c5badd69 Bug 557405 – Use 'allow-none' consistently
2008-10-22  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* docs/typelib-format.txt:
	* girepository/ginfo.c (g_arg_info_may_be_null):
	* girepository/girnode.c (g_ir_node_build_typelib):
	* girepository/girnode.h (struct _GIrNodeParam):
	* girepository/girparser.c (start_parameter):
	* girepository/girwriter.c (function_generate):
	* girepository/gtypelib.h (ArgBlob):
	* tests/errors.gir:
	* tests/function.gir:
	* tools/generate.c (write_callable_info): Use 'allow-none'
	consistently throughout

svn path=/trunk/; revision=782
2008-10-22 14:02:02 +00:00
Johan Bilien
727bb01805 Bug 557241 – "throws" flag for functions
2008-10-21  Johan Bilien  <jobi@via.ecp.fr>

	Bug 557241 – "throws" flag for functions

	* tests/scanner/drawable-1.0-expected.gir,
	tests/scanner/drawable-injected-1.0-expected.gir,
	tests/scanner/drawable.[ch]: add simple test for throwing
	function (has GError ** as last argument)

	* giscanner/ast.py: add a 'throws' flag to Function
	* giscanner/glibtransformer.py: if a function's last paramerter is
	a GError, set the 'throws' flag and remove that parameter
	* giscanner/girwriter.py: write out the 'throws' attribute
	* giscanner/girparser.py: support parsing the 'throws' attribute

	* tests/repository/gitestthrows.c: add a simple test to check the
	throws flag in a typelib and invoke the function

	* girepository/ginfo.c, girepository/girnode.[ch],
	girepository/girnode.h, girepository/girparser.c,
	girepository/girepository.h: Add and parse the GI_FUNCTION_THROWS flag

	* girepository/ginvoke.c: if a function throws, add a GError as last
	arguments, and propagate the error to the invoker.


svn path=/trunk/; revision=773
2008-10-21 17:04:11 +00:00
Colin Walters
c3330c06c7 Bug 557011 - Add g_object_info_get_abstract
svn path=/trunk/; revision=757
2008-10-20 17:04:17 +00:00
Tommi Komulainen
0de03983be Bug 556732 – generate gir files consistently
2008-10-17  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556732 – generate gir files consistently

	* girepository/girparser.c (start_parameter):
	* tests/boxed.gir:
	* tests/invoke/testfns-1.0.gir:
	* tools/generate.c (write_callable_info): write
	'transfer-ownership' attribute consistently with both
	return-value and parameter elements

svn path=/trunk/; revision=745
2008-10-17 14:59:23 +00:00
Tommi Komulainen
0fa82c6a4c Bug 556732 – generate gir files consistently
2008-10-17  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556732 – generate gir files consistently

	* giscanner/ast.py (Field): add readable and writable properties
	* giscanner/girparser.py (_parse_field): copy 'readable' and
	'writable' attributes
	* giscanner/transformer.py (_create_member): create fields as
	read-write
	* giscanner/glibtransformer.py (_introspect_object,
	_pair_class_struct): make object instance and class fields
	read-only
	* giscanner/girwriter.py (_write_field):
	* tools/generate.c (write_field_info): write field 'readable'
	and 'writable' attributes only if non-default (read-only)
	* girepository/girparser.c (start_field): in the absence of
	attributes assume fields are read-only
	* tests/boxed.gir:
	* tests/struct.gir: remove redundant readable="1" from fields
	* tests/scanner/foo-1.0-expected.gir:
	* tests/scanner/utility-1.0-expected.gir: add writable="1" to
	all record and union fields

svn path=/trunk/; revision=743
2008-10-17 14:58:37 +00:00
Tommi Komulainen
4fb5b001bb Bug 556543 – reduce compiler warnings
2008-10-16  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556543 – reduce compiler warnings

	* girepository/ginfo.c:
	* girepository/girepository.c (register_internal,
	count_interfaces, find_interface, find_namespace_version,
	parse_version, g_irepository_require):
	* girepository/girmodule.c (g_ir_module_build_typelib):
	* girepository/girnode.c (init_stats, dump_stats,
	_g_irnode_init_stats, _g_irnode_dump_stats,
	g_ir_node_can_have_member):
	* girepository/girparser.c (firstpass_end_element_handler,
	locate_gir, parse_basic, parse_type_internal, resolve_aliases,
	start_alias, start_type, end_type_top, parse_include, cleanup,
	post_filter):
	* girepository/gtypelib.c (validate_function_blob, validate_enum_blob):
	* giscanner/giscannermodule.c (directive_get_options,
	type_get_child_list):
	* giscanner/scannerlexer.l (parse_gtkdoc):
	* giscanner/scannerparser.y (ctype_free):
	* giscanner/sourcescanner.c:
	* giscanner/sourcescanner.h (gi_source_scanner_parse_macros):
	* tests/types/gitesttypes.c:
	* tools/compiler.c (main):
	* tools/generate.c (write_repository): Remove unused variables
	and code, add missing includes, declarations and case
	statements.

svn path=/trunk/; revision=730
2008-10-16 17:07:05 +00:00
Colin Walters
7db23628b0 Merge branch 'bug556331-includecleanup'
svn path=/trunk/; revision=724
2008-10-16 01:40:29 +00:00
Tommi Komulainen
9153ef51ae Bug 556174 – parse types for lists etc.
2008-10-15  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556174 – parse types for lists etc.

	* girepository/girparser.c (end_type_recurse):
	* tests/boxed.gir:
	* tools/generate.c (write_type_info, write_field_info,
	write_callable_info, write_callable_info, write_constant_info,
	write_property_info): use nested <type>s for lists and hashes

svn path=/trunk/; revision=717
2008-10-15 22:08:26 +00:00
Tommi Komulainen
6e266d5f53 Bug 556400 – Fails to build on OS X 10.4
2008-10-15  Tommi Komulainen  <tommi.komulainen@iki.fi>

	Bug 556400 – Fails to build on OS X 10.4

	* configure.ac: check for functions backtrace and backtrace_symbols
	* girepository/girparser.c (backtrace_stderr): Comment out
	implementation if the functions are not available.
	* gcov.mak (clean-gcov, clean-gcno): always call 'find' with a
	directory for better portability

svn path=/trunk/; revision=711
2008-10-15 20:44:29 +00:00
Tommi Komulainen
a940cef8c7 handle "transfer-ownership" attribute
2008-10-12  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* girepository/girparser.c (start_return_value): handle
	"transfer-ownership" attribute

svn path=/trunk/; revision=690
2008-10-12 21:07:33 +00:00
Tommi Komulainen
25e43d53d1 use "container" for container/shallow ownership transfer (not "shallow")
2008-10-12  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* girepository/girparser.c (parse_param_transfer):
	* tools/generate.c (write_callable_info): use "container" for
	container/shallow ownership transfer (not "shallow")

svn path=/trunk/; revision=689
2008-10-12 21:07:28 +00:00
Tommi Komulainen
bc54751766 Refactor handling of transfer=none/shallow/full to separate function
2008-10-12  Tommi Komulainen  <tommi.komulainen@iki.fi>

	* girepository/girparser.c (parse_param_transfer,
	start_parameter): Refactor handling of transfer=none/shallow/full
	to separate function

svn path=/trunk/; revision=688
2008-10-12 21:07:22 +00:00
Colin Walters
3be641f836 Bug 552858: versioning
This is a big patch.  You should probably remove your installation
	tree to be cleaner.

	* docs/typelib-format.txt: Add nsversion entry which holds
	version of namespace.
	* girepository/girepository.h: Add 'version' parameter to
	g_irepository_require.  This may be NULL.  Normally
	bindings should pass an explicit version though.
	* girepository/girepository.c: Lots of infrastructure to
	support versioning.  Add some more documentation.  Disallow
	some usage of NULL namespaces.
	* girepository/girmodule.c: Add version parameter.
	* girepository/gtypelib.c: Update header size.
	* giscanner/ast.py: Add version to Namespace.
	* giscanner/girparser.py: Parse version attribute from
	XML, pass to Namespace.
	* giscanner/girwriter.py: Write out version parameter.
	* giscanner/transformer.py: Clean up include registration.
	* tests/*: Add version attribute.
	* tests/invoke/invoke.c: Don't try looking up test before
	it's loaded in repository.
	* tools/generate.c: Output version parameter.
	* gir/Makefile.am: Add 2.0 version to .gir files.

svn path=/trunk/; revision=677
2008-10-12 04:51:48 +00:00
Colin Walters
d982b65391 Remove debug print
svn path=/trunk/; revision=644
2008-10-02 14:07:42 +00:00
Colin Walters
a99fdaf755 Merge branch 'bug552393-varargs'
svn path=/trunk/; revision=643
2008-10-02 14:07:38 +00:00
Colin Walters
b26d8d2dce Bug 554632: Create type tag for GType
svn path=/trunk/; revision=641
2008-10-02 13:25:46 +00:00
Colin Walters
9893df46cb Ensure we always have types for container nodes
svn path=/trunk/; revision=638
2008-09-29 19:03:46 +00:00
Colin Walters
ff654e2d4e Rework to use recursive XML
svn path=/trunk/; revision=637
2008-09-29 19:03:44 +00:00
Colin Walters
f32239577e Remove non-repository types from GIR
* giscanner/ast.py: The canonical name is 'utf8', not
	'string'.
	* giscanner/glibast.py: A few more glib type mappings.
	* girepository/girparser.c: We only parse repository types.
	* tests/*.gir: Update.

svn path=/trunk/; revision=628
2008-09-25 22:33:57 +00:00
Colin Walters
8fc943f941 Merge branch 'bug552566-timet/wip'
svn path=/trunk/; revision=624
2008-09-23 18:20:25 +00:00
Colin Walters
0ab7337756 Bug 552065: Add deprecation information to GIR
* giscanner/ast.py: Add deprecation attributes.
	* giscanner/girwriter.py: Write out deprecation data.
	* girepository/girparser.c: Relax parsing; deprecated
	attribute now includes freeform string.
	* giscanner/scannerlexer.l: Parse Deprecated.
	* giscanner/transformer.py: Look for deprecated attribute
	on functions.
	* tests/scanner/*: Add a Deprecated test.

svn path=/trunk/; revision=603
2008-09-15 14:46:19 +00:00
Colin Walters
7a55bd25d9 Write out and parse full GObject property information (readable, writable, etc)
* girepository/girparser.c: Default to "readable" for properties.
	* giscanner/ast.py: Add readable, writable etc.
	* giscanner/girwriter.py: Writ them.
	* giscanner/glibtransformer.py: Inspect them.
	* tests/*: Update.

svn path=/trunk/; revision=587
2008-09-08 22:24:09 +00:00
Colin Walters
8f09203dda Allow both union and struct to be boxed or not
* girepository/girnode.c: Allow gtype_name
	and gtype_init in struct and union.
	* girepository/girparser.c: Parse glib:
	boxed bits for both structure and union.
	* girepository/gtypelib.c: Don't barf
	if structure is boxed.
	* giscanner/girparser.py: Parse new XML
	format.
	* giscanner/girwriter.py: Write out new
	XML format.
	* giscanner/glibast.py: Define new classes
	which are both Boxed and Struct/Union, as
	well as an "Other" for everything else.
	* giscanner/glibtransformer.py: Handle
	boxed types specially; we try to merge
	them with a struct/union if one exists,
	otherwise fall back to generic boxed.
	* tests/*: Update.
	* tools/generate.c: Write out new format.

svn path=/trunk/; revision=575
2008-09-06 20:33:51 +00:00
Colin Walters
71473eb033 Look in c:type to determine pointer nature
* girepository/girparser.c: Look at c:type to determine
	whether or not an item is a pointer.

svn path=/trunk/; revision=571
2008-09-01 18:52:34 +00:00
Colin Walters
ae48f17999 Don't lose if we have no includedirs
* girepository/girparser.c: Don't lose if we
	have no includedirs

svn path=/trunk/; revision=551
2008-08-31 16:01:02 +00:00
Colin Walters
6e656b4498 Put dependencies in typelibs, resolve them when loading
* gir/Makefile.am: Dep on Makefile
	* girepository/ginfo.c: Print out a nicer error
	message if we failed to load something.
	* girepository/girepository.c: Clean up
	default typelib handling; remove global
	default_typelib variable.  Ensure we handle
	NULL repository in more places.
	Support dependency resolution.
	* tests/Makefile.am: Kill off gobject.gir,
	it conflicts with the real one.
	* tests/Object.gir: Depend on GObject.
	* tools/generate.c: Take --includedir
	argument to say which directories to search
	for typelibs.  Print out dependencies.

svn path=/trunk/; revision=541
2008-08-30 20:31:07 +00:00
Colin Walters
8baadb8611 Handle alias chains correctly
* girepository/girparser.c: Handle chains of aliases
	across modules by ensuring we fully qualify aliases
	from includes.

svn path=/trunk/; revision=531
2008-08-29 20:41:26 +00:00
Colin Walters
63bb95c0db Avoid searching aliases for basic types
* girepository/girparser.c: Don't search aliases
	for basic types.

svn path=/trunk/; revision=529
2008-08-29 20:06:10 +00:00
Colin Walters
da9249d559 Fix type parsing for both GLib case and GLib.List
* girepository/girparser.c: Rewrite type parsing
	to handle both GLib parsing case as well as correctly
	handling GLib.List and friends.  Don't try to treat
	e.g. ListStore as a List.

svn path=/trunk/; revision=527
2008-08-29 19:33:09 +00:00
Colin Walters
a633e4b1f3 Correctly handle GLib.List, GLib.Error etc
* girepository/girparser.c: Accept both List (for
	compiling GLib) and GLib.List (what the scanner
	generates).
	* tests/ - Update.
	* tools/generate.c: Generate canonical form.

svn path=/trunk/; revision=522
2008-08-29 18:19:26 +00:00
Colin Walters
b31a2ae395 Fix --includedir handling
* tests/scanner/Makefile.am: Pass the right
	--includedir args.  Add a Makefile dep.
	* tools/compiler.c: Pass includedirs down.
	* girepository/girparser.c: Actually put
	includedirs in context, pass down.  Fix
	locate_gir.

svn path=/trunk/; revision=514
2008-08-28 22:13:00 +00:00
Colin Walters
7fd9cd094d Expand aliases when generating typelibs
* gir/Makefile.am: Use --includedir
	* girepository/girparser.c: Recursively parse
	includes to pull in aliases and expand them.
	We need this to	avoid putting unknown names in
	the typelibs.
	* tools/compiler.c: Add --includedir option.

svn path=/trunk/; revision=512
2008-08-28 21:19:22 +00:00
Tor Lillqvist
2bb80a1209 Make g-ir-scanner work on Windows. Still problems with the typelib code.
2008-08-27  Tor Lillqvist  <tml@novell.com>

	Make g-ir-scanner work on Windows. Still problems with the typelib
	code. Changes okayed by jdahlin.

	* configure.ac: Check for Windows, set Automake conditional
	OS_WIN32. Change backslashes to forward slashes in pyexecdir to
	avoid shell quoting issues
	
	* girepository/Makefile.am: Use -no-undefined so that libtool
	agrees to build a shared library on Windows.

	* girepository/girparser.c (backtrace_stderr): No backtrace() on
	Windows. Empty implementation on Windows so far.

	* girepository/gtypelib.c (g_typelib_check_sanity): Give more
	informative error message for the assertion failures. Tell also
	what the expected size of the struct is. Check all sizes first and
	fail afterwards if at least one size was different from expected.

	* tools/Makefile.am: Reorder libraries into proper logical
	dependency order.

	* tools/generate.c: Don't include <dlfcn.h>, not used.

	* giscanner/Makefile.am: On Windows, link with the Python library,
	and install the module DLL as _giscanner.pyd. Remove the
	unnecessary import library and libtool library that libtool has
	installed.

	* giscanner/scannerlexer.l: Recognize the gcc __attribute__ syntax
	and just skip it. Recognize also two "l" suffixes for long long
	constants. Recognize also __inline__.

	* giscanner/grealpath.h (g_realpath): Implement on Windows, using
	GetFullPathName(). As such, GetFullPathName() does more than the
	UNIX realpath(). It also changes relative paths into absolute
	paths. But for our purposes that shouldn't matter.

	* giscanner/giscannermodule.c (pygi_source_scanner_parse_file): On
	Windows the file descriptor passed to us is from Python. Python
	Python2.5 uses the msvcr71.dll C library, while mingw-built code
	uses msvcrt.dll. On Windows, file descriptors are specific to
	which C library is used. So we must find out what underlying OS
	handle corresponds to the file descriptor Python passes us, and
	then make that into a file descriptor valid for the C library this
	code uses.

	* giscanner/sourcescanner.py (_parse): Don't need to bypass
	__attribute__ as the lexer now handles it. The definition as empty
	was ineffective for mingw anyway, as mingw's _mingw.h undefines
	__attribute__. Close the temp file before unlinking it.

	* giscanner/cgobject.py: Use correct library name for the gobject
	DLL on Windows.

	* gir/Makefile.am: Must pass the full basename of the DLLs on
	Windows to g-ir-scanner. It's a bit ugly that we have to "know"
	that the names of the GLib DLLs are like libglib-2.0-0.dll, but in
	reality they won't change, until there is a GLib 3, and then also
	the Unix code here needs changing.

	Must pass CPPFLAGS to g-ir-scanner when building GLib.gir so that
	libintl.h is found.


svn path=/trunk/; revision=503
2008-08-27 13:33:21 +00:00
Colin Walters
777cc726a4 Parse new implements syntax, drop gapi one. Update. Generate new syntax.
2008-08-25  Colin Walters  <walters@verbum.org>

	* girepository/girparser.c: Parse new implements
	syntax, drop gapi one.
	* tests/object.gir: Update.
	* tools/generate.c: Generate new syntax.

svn path=/trunk/; revision=492
2008-08-25 15:22:39 +00:00
Johan Dahlin
ed13aae5f2 Refactor a couple of parsing functions to be simpler to follow. Avoid huge
2008-08-24  Johan Dahlin  <johan@gnome.org>

    * girepository/girparser.c (start_glib_boxed), (start_function),
    (start_field), (start_alias):
    Refactor a couple of parsing functions to be simpler to follow.
    Avoid huge ifs.


svn path=/trunk/; revision=481
2008-08-24 11:01:44 +00:00