From: Jürg Billeter Date: Fri, 18 Aug 2006 08:40:48 +0000 (+0000) Subject: Initial import of vapigen. X-Git-Tag: VALA_0_0_3~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19097d24fddabd15064abb2540bd999a085997ee;p=thirdparty%2Fvala.git Initial import of vapigen. * Initial import of vapigen. svn path=/trunk/; revision=101 --- diff --git a/vapigen/AUTHORS b/vapigen/AUTHORS new file mode 100644 index 000000000..7acb618c7 --- /dev/null +++ b/vapigen/AUTHORS @@ -0,0 +1 @@ +Jürg Billeter diff --git a/vapigen/COPYING b/vapigen/COPYING new file mode 100644 index 000000000..5ab7695ab --- /dev/null +++ b/vapigen/COPYING @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/vapigen/ChangeLog b/vapigen/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/vapigen/INSTALL b/vapigen/INSTALL new file mode 100644 index 000000000..23e5f25d0 --- /dev/null +++ b/vapigen/INSTALL @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/vapigen/Makefile.am b/vapigen/Makefile.am new file mode 100644 index 000000000..31f37cdde --- /dev/null +++ b/vapigen/Makefile.am @@ -0,0 +1,7 @@ +NULL = + +SUBDIRS = \ + gobject-introspection \ + gidlgen \ + vapigen \ + $(NULL) diff --git a/vapigen/NEWS b/vapigen/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/vapigen/README b/vapigen/README new file mode 100644 index 000000000..e69de29bb diff --git a/vapigen/configure.ac b/vapigen/configure.ac new file mode 100644 index 000000000..c434fc6a3 --- /dev/null +++ b/vapigen/configure.ac @@ -0,0 +1,38 @@ +AC_INIT([vapigen], [0.0.1], [j@bitron.ch], [vapigen]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS(config.h) +AM_INIT_AUTOMAKE([dist-bzip2]) + +AM_MAINTAINER_MODE + +# Checks for programs. +AC_PROG_CC +AC_PROG_LIBTOOL +AM_PROG_LEX +AC_PROG_YACC + +AC_PATH_PROG(VALAC, valac, valac) +AC_SUBST(VALAC) + +AC_SUBST(CFLAGS) +AC_SUBST(CPPFLAGS) +AC_SUBST(LDFLAGS) + +GLIB_REQUIRED=2.10.0 + +PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) + +VALA_REQUIRED=0.0.3 + +PKG_CHECK_MODULES(VALA, vala-1.0 >= $VALA_REQUIRED) +AC_SUBST(VALA_CFLAGS) +AC_SUBST(VALA_LIBS) + +AC_CONFIG_FILES([Makefile + gobject-introspection/Makefile + gidlgen/Makefile + vapigen/Makefile]) + +AC_OUTPUT diff --git a/vapigen/gidlgen/Makefile.am b/vapigen/gidlgen/Makefile.am new file mode 100644 index 000000000..73ed32eaa --- /dev/null +++ b/vapigen/gidlgen/Makefile.am @@ -0,0 +1,11 @@ +NULL = + +dist_bin_SCRIPTS = \ + gidlgen \ + $(NULL) + +pkglibexecdir = $(libdir)/vala +dist_pkglibexec_SCRIPTS = \ + gapi2xml.pl \ + gapi_pp.pl \ + $(NULL) diff --git a/vapigen/gidlgen/gapi2xml.pl b/vapigen/gidlgen/gapi2xml.pl new file mode 100755 index 000000000..49964aeab --- /dev/null +++ b/vapigen/gidlgen/gapi2xml.pl @@ -0,0 +1,1178 @@ +#!/usr/bin/perl +# +# gapi2xml.pl : Generates an XML representation of GObject based APIs. +# +# Author: Mike Kestner +# +# Copyright (c) 2001-2003 Mike Kestner +# 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. +############################################################## + +$debug=0; + +use XML::LibXML; + +if (!$ARGV[1]) { + die "Usage: gapi_pp.pl | gapi2xml.pl \n"; +} + +$ns = $ARGV[0]; + +############################################################## +# Check if the filename provided exists. We parse existing files into +# a tree and append the namespace to the root node. If the file doesn't +# exist, we create a doc tree and root node to work with. +############################################################## + +if (-e $ARGV[1]) { + #parse existing file and get root node. + $doc = XML::LibXML->new->parse_file($ARGV[1]); + $root = $doc->getDocumentElement(); +} else { + $doc = XML::LibXML::Document->new(); + $root = $doc->createElement('api'); + $root->setAttribute("version", "1.0"); + $doc->setDocumentElement($root); + $warning_node = XML::LibXML::Comment->new ("\n\n This file was automatically generated.\n Please DO NOT MODIFY THIS FILE, modify .metadata files instead.\n\n"); + $root->appendChild($warning_node); +} + +$ns_elem = $doc->createElement('namespace'); +$ns_elem->setAttribute('name', $ns); +$root->appendChild($ns_elem); + +############################################################## +# First we parse the input for typedefs, structs, enums, and class_init funcs +# and put them into temporary hashes. +############################################################## + +while ($line = ) { + if ($line =~ /typedef\s+(struct\s+\w+\s+)\*+(\w+);/) { + $ptrs{$2} = $1; + } elsif ($line =~ /typedef\s+(struct\s+\w+)\s+(\w+);/) { + next if ($2 =~ /Private$/); + # fixme: siiigh + $2 = "GdkDrawable" if ($1 eq "_GdkDrawable"); + $types{$2} = $1; + } elsif ($line =~ /typedef\s+struct/) { + $sdef = $line; + while ($line = ) { + $sdef .= $line; + last if ($line =~ /^(deprecated)?}/); + } + $sdef =~ s!/\*.*?(\*/|\n)!!g; + $sdef =~ s/\n\s*//g; + $types{$1} = $sdef if ($sdef =~ /.*\}\s*(\w+);/); + } elsif ($line =~ /typedef\s+(unsigned\s+\w+)\s+(\**)(\w+);/) { + $types{$3} = $1 . $2; + } elsif ($line =~ /typedef\s+(\w+)\s+(\**)(\w+);/) { + $types{$3} = $1 . $2; + } elsif ($line =~ /typedef\s+enum\s+(\w+)\s+(\w+);/) { + $etypes{$1} = $2; + } elsif ($line =~ /^((deprecated)?typedef\s+)?\benum\b/) { + $edef = $line; + while ($line = ) { + $edef .= $line; + last if ($line =~ /^(deprecated)?}\s*(\w+)?;/); + } + $edef =~ s/\n\s*//g; + $edef =~ s|/\*.*?\*/||g; + if ($edef =~ /typedef.*}\s*(\w+);/) { + $ename = $1; + } elsif ($edef =~ /^(deprecated)?enum\s+(\w+)\s*{/) { + $ename = $2; + } else { + print "Unexpected enum format\n$edef"; + next; + } + $edefs{$ename} = $edef; + } elsif ($line =~ /typedef\s+\w+\s*\**\s*\(\*\s*(\w+)\)\s*\(/) { + $fname = $1; + $fdef = ""; + while ($line !~ /;/) { + $fdef .= $line; + $line = ; + } + $fdef .= $line; + $fdef =~ s/\n\s+//g; + $fpdefs{$fname} = $fdef; + } elsif ($line =~ /^(private|deprecated)?struct\s+(\w+)/) { + next if ($line =~ /;/); + $sname = $2; + $sdef = $line; + while ($line = ) { + $sdef .= $line; + last if ($line =~ /^(deprecated)?}/); + } + $sdef =~ s!/\*[^<].*?(\*/|\n)!!g; + $sdef =~ s/\n\s*//g; + $sdefs{$sname} = $sdef if (!exists ($sdefs{$sname})); + } elsif ($line =~ /^(\w+)_(class|base)_init\b/) { + $class = StudlyCaps($1); + $pedef = $line; + while ($line = ) { + $pedef .= $line; + last if ($line =~ /^(deprecated)?}/); + } + $pedefs{lc($class)} = $pedef; + } elsif ($line =~ /^(\w+)_get_type\b/) { + $class = StudlyCaps($1); + $pedef = $line; + while ($line = ) { + $pedef .= $line; + if ($line =~ /g_boxed_type_register_static/) { + $boxdef = $line; + while ($line !~ /;/) { + $boxdef .= ($line = ); + } + $boxdef =~ s/\n\s*//g; + $boxdef =~ /\(\"(\w+)\"/; + my $boxtype = $1; + $boxtype =~ s/($ns)Type(\w+)/$ns$2/; + $boxdefs{$boxtype} = $boxdef; + } elsif ($line =~ /g_(enum|flags)_register_static/) { + $pedef =~ /^(\w+_get_type)/; + $enum_gtype{$class} = $1; + } + last if ($line =~ /^(deprecated)?}/); + } + $typefuncs{lc($class)} = $pedef; + } elsif ($line =~ /^G_DEFINE_TYPE_WITH_CODE\s*\(\s*(\w+)/) { + $typefuncs{lc($1)} = $line; + } elsif ($line =~ /^(deprecated)?(const|G_CONST_RETURN)?\s*(struct\s+)?\w+\s*\**(\s*(const|G_CONST_RETURN)\s*\**)?\s*(\w+)\s*\(/) { + $fname = $6; + $fdef = ""; + while ($line !~ /;/) { + $fdef .= $line; + $line = ; + } + $fdef .= $line; + $fdef =~ s/\n\s*//g; + if ($fdef !~ /^_/) { + $fdefs{$fname} = $fdef; + } + } elsif ($line =~ /CHECK_(\w*)CAST/) { + $cast_macro = $line; + while ($line =~ /\\$/) { + $line = ; + $cast_macro .= $line; + } + $cast_macro =~ s/\\\n\s*//g; + $cast_macro =~ s/\s+/ /g; + if ($cast_macro =~ /G_TYPE_CHECK_(\w+)_CAST.*,\s*(\w+),\s*(\w+)\)/) { + if ($1 eq "INSTANCE") { + $objects{$2} = $3 . $objects{$2}; + } else { + $objects{$2} .= ":$3"; + } + } elsif ($cast_macro =~ /G_TYPE_CHECK_(\w+)_CAST.*,\s*([a-zA-Z0-9]+)_(\w+)_get_type\s*\(\),\s*(\w+)\)/) { + $typename = uc ("$2_type_$3"); + if ($1 eq "INSTANCE") { + $objects{$typename} = $4 . $objects{$typename}; + } else { + $objects{$typename} .= ":$4"; + } + } elsif ($cast_macro =~ /GTK_CHECK_CAST.*,\s*(\w+),\s*(\w+)/) { + $objects{$1} = $2 . $objects{$1}; + } elsif ($cast_macro =~ /GTK_CHECK_CLASS_CAST.*,\s*(\w+),\s*(\w+)/) { + $objects{$1} .= ":$2"; + } elsif ($cast_macro =~ /GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_CAST.*,\s*(\w+),\s*(\w+)/) { + $objects{$1} = $2 . $objects{$1}; + } + } elsif ($line =~ /INSTANCE_GET_INTERFACE.*,\s*(\w+),\s*(\w+)/) { + $ifaces{$1} = $2; + } elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_BOXED/) { + $boxdefs{$1} = $line; + } elsif ($line =~ /^BUILTIN\s*\{\s*\"(\w+)\".*GTK_TYPE_(ENUM|FLAGS)/) { + # ignoring these for now. + } elsif ($line =~ /^(deprecated)?\#define/) { + my $test_ns = uc ($ns); + if ($line =~ /^deprecated\#define\s+(\w+)\s+\"(.*)\"/) { + $defines{"deprecated$1"} = $2; + } elsif ($line =~ /\#define\s+(\w+)\s+\"(.*)\"/) { + $defines{$1} = $2; + } + } elsif ($line !~ /\/\*/) { + print $line; + } +} + +############################################################## +# Produce the enum definitions. +############################################################## +%enums = (); + +foreach $cname (sort(keys(%edefs))) { + $ecnt++; + $def = $edefs{$cname}; + $cname = $etypes{$cname} if (exists($etypes{$cname})); + $enums{lc($cname)} = $cname; + $enum_elem = addNameElem($ns_elem, 'enum', $cname, $ns); + if ($def =~ /^deprecated/) { + $enum_elem->setAttribute("deprecated", "1"); + $def =~ s/deprecated//g; + } + if ($enum_gtype{$cname}) { + $enum_elem->setAttribute("get-type", $enum_gtype{$cname}); + } + if ($def =~ /<setAttribute('type', "flags"); + } else { + $enum_elem->setAttribute('type', "enum"); + } + $def =~ /\{(.*\S)\s*\}/; + @vals = split(/,\s*/, $1); + $vals[0] =~ s/^\s+//; + @v0 = split(/_/, $vals[0]); + if (@vals > 1) { + $done = 0; + for ($idx = 0, $regex = ""; $idx < @v0; $idx++) { + $regex .= ($v0[$idx] . "_"); + foreach $val (@vals) { + $done = 1 if ($val !~ /$regex/); + } + last if $done; + } + $common = join("_", @v0[0..$idx-1]); + } else { + $common = join("_", @v0[0..$#v0-1]); + } + + foreach $val (@vals) { + $val =~ s/=\s*\(\s*(.*\S)\s*\)\s*/= \1/; + if ($val =~ /$common\_?(\w+)\s*=\s*(.*)$/) { + $name = $1; + $enumval = $2; + if ($enumval =~ /^(\d+|0x[0-9A-Fa-f]+)u?\s*<<\s*(\d+)$/) { + $enumval = ""; + } elsif ($enumval =~ /^$common\_?(\w+)$/) { + $enumval = "" + } + } elsif ($val =~ /$common\_?(\w+)/) { + $name = $1; $enumval = ""; + } else { + die "Unexpected enum value: $val for common value $common\n"; + } + + $val_elem = addNameElem($enum_elem, 'member'); + $val_elem->setAttribute('name', "$common\_$name"); + $val_elem->setAttribute('value', $enumval); + } +} + +############################################################## +# Parse the callbacks. +############################################################## + +foreach $cbname (sort(keys(%fpdefs))) { + next if ($cbname =~ /^_/); + $cbcnt++; + $fdef = $cb = $fpdefs{$cbname}; + $cb_elem = addNameElem($ns_elem, 'callback', $cbname, $ns); + $cb =~ /typedef\s+(.*)\(.*\).*\((.*)\);/; + $ret = $1; $params = $2; + addReturnElem($cb_elem, $ret); + if ($params && ($params ne "void")) { + addParamsElem($cb_elem, split(/,/, $params)); + } +} + + +############################################################## +# Parse the interfaces list. +############################################################## + +foreach $type (sort(keys(%ifaces))) { + + $iface = $ifaces{$type}; + ($inst, $dontcare) = split(/:/, delete $objects{$type}); + $initfunc = $pedefs{lc($inst)}; + $ifacetype = delete $types{$iface}; + delete $types{$inst}; + + $ifacecnt++; + $iface_el = addNameElem($ns_elem, 'interface', $inst, $ns); + $iface_el->setAttribute("get-type", ""); + + $elem_table{lc($inst)} = $iface_el; + + $classdef = $sdefs{$1} if ($ifacetype =~ /struct\s+(\w+)/); + if ($initfunc) { + parseInitFunc($iface_el, $initfunc); + } else { + warn "Don't have an init func for $inst.\n" if $debug; + addVirtualMethods ($classdef, $iface_el); + } +} + + +############################################################## +# Parse the classes by walking the objects list. +############################################################## + +foreach $type (sort(keys(%objects))) { + ($inst, $class) = split(/:/, $objects{$type}); + $class = $inst . "Class" if (!$class); + $initfunc = $pedefs{lc($inst)}; + $typefunc = $typefuncs{lc($inst)}; + $insttype = delete $types{$inst}; + $classtype = delete $types{$class}; + + $instdef = $classdef = ""; + $instdef = $sdefs{$1} if ($insttype =~ /struct\s+(\w+)/); + $classdef = $sdefs{$1} if ($classtype =~ /struct\s+(\w+)/); + $classdef =~ s/deprecated//g; + $instdef =~ s/\s+(\*+)([^\/])/\1 \2/g; + warn "Strange Class $inst\n" if (!$instdef && $debug); + + $classcnt++; + $obj_el = addNameElem($ns_elem, 'object', $inst, $ns); + $obj_el->setAttribute("get-type", ""); + + + $elem_table{lc($inst)} = $obj_el; + + # Check if the object is deprecated + if ($instdef =~ /^deprecatedstruct/) { + $obj_el->setAttribute("deprecated", "1"); + $instdef =~ s/deprecated//g; + } + + # Extract parent and fields from the struct + if ($instdef =~ /^struct/) { + $instdef =~ /\{(.*)\}/; + $fieldstr = $1; + $fieldstr =~ s|/\*[^<].*?\*/||g; + @fields = split(/;/, $fieldstr); + addFieldElems($obj_el, 'private', @fields); + if ($inst =~ /GdkWindow/) { + $obj_el->setAttribute('parent', "GdkDrawable"); + } else { + $obj_el->setAttribute('parent', $obj_el->firstChild->getAttribute('type')); + } + $obj_el->removeChild($obj_el->firstChild); + } elsif ($instdef =~ /privatestruct/) { + # just get the parent for private structs + $instdef =~ /\{\s*(\w+)/; + $obj_el->setAttribute('parent', "$1"); + } + + # Get the props from the class_init func. + if ($initfunc) { + parseInitFunc($obj_el, $initfunc); + } else { + warn "Don't have an init func for $inst.\n" if $debug; + } + + # Get the interfaces from the class_init func. + if ($typefunc) { + if ($typefunc =~ /G_DEFINE_TYPE_WITH_CODE/) { + parseTypeFuncMacro($obj_el, $typefunc); + } else { + parseTypeFunc($obj_el, $typefunc); + } + } else { + warn "Don't have a GetType func for $inst.\n" if $debug; + } + +} + +############################################################## +# Parse the remaining types. +############################################################## + +foreach $key (sort (keys (%types))) { + + $lasttype = $type = $key; + while ($type && ($types{$type} !~ /struct/)) { + $lasttype = $type; + $type = $types{$type}; + } + + if ($types{$type} =~ /struct\s+(\w+)/) { + $type = $1; + if (exists($sdefs{$type})) { + $def = $sdefs{$type}; + } else { + $def = "privatestruct"; + } + } elsif ($types{$type} =~ /struct/ && $type =~ /^$ns/) { + $def = $types{$type}; + } else { + #how to represent aliases in gidl? + #$elem = addNameElem($ns_elem, 'alias', $key, $ns); + #$elem->setAttribute('type', $lasttype); + #warn "alias $key to $lasttype\n" if $debug; + next; + } + + # fixme: hack + if ($key eq "GdkBitmap") { + $struct_el = addNameElem($ns_elem, 'object', $key, $ns); + } elsif (exists($boxdefs{$key})) { + $struct_el = addNameElem($ns_elem, 'boxed', $key, $ns); + } else { + $struct_el = addNameElem($ns_elem, 'struct', $key, $ns); + } + + $struct_el->setAttribute("get-type", ""); + + if ($def =~ /^deprecated/) { + $struct_el->setAttribute("deprecated", "1"); + $def =~ s/deprecated//g; + } + + $elem_table{lc($key)} = $struct_el; + + $def =~ s/\s+/ /g; + if ($def =~ /privatestruct/) { + $struct_el->setAttribute('opaque', 'true'); + } else { + $def =~ /\{(.+)\}/; + addFieldElems($struct_el, 'public', split(/;/, $1)); + } +} + +# really, _really_ opaque structs that aren't even defined in sources. Lovely. +foreach $key (sort (keys (%ptrs))) { + next if $ptrs{$key} !~ /struct\s+(\w+)/; + $type = $1; + $struct_el = addNameElem ($ns_elem, 'struct', $key, $ns); + $struct_el->setAttribute('opaque', 'true'); + $elem_table{lc($key)} = $struct_el; +} + +addFuncElems(); +addStaticFuncElems(); + +# This should probably be done in a more generic way +foreach $define (sort (keys (%defines))) { + next if $define !~ /[A-Z]_STOCK_/; + $string_el = addNameElem ($ns_elem, "constant", $define); + $string_el->setAttribute('name', $define); + $string_el->setAttribute('type', "utf8"); + $string_el->setAttribute('value', $defines{$define}); +} + +############################################################## +# Output the tree +############################################################## + +if ($ARGV[1]) { + open(XMLFILE, ">$ARGV[1]") || + die "Couldn't open $ARGV[1] for writing.\n"; + print XMLFILE $doc->toString(); + close(XMLFILE); +} else { + print $doc->toString(); +} + +############################################################## +# Generate a few stats from the parsed source. +############################################################## + +$scnt = keys(%sdefs); $fcnt = keys(%fdefs); $tcnt = keys(%types); +print "structs: $scnt enums: $ecnt callbacks: $cbcnt\n"; +print "funcs: $fcnt types: $tcnt classes: $classcnt\n"; +print "props: $propcnt childprops: $childpropcnt signals: $sigcnt\n\n"; + +sub addFieldElems +{ + my ($parent, $defaultaccess, @fields) = @_; + my $access = $defaultaccess; + + foreach $field (@fields) { + if ($field =~ m!/\*< (public|private) >.*\*/(.*)$!) { + $access = $1; + $field = $2; + } + next if ($field !~ /\S/); + $field =~ s/\s+(\*+)/\1 /g; + $field =~ s/(const\s+)?(\w+)\*\s+const\*/const \2\*/g; + $field =~ s/(\w+)\s+const\s*\*/const \1\*/g; + $field =~ s/const /const\-/g; + $field =~ s/struct /struct\-/g; + $field =~ s/.*\*\///g; + next if ($field !~ /\S/); + + if ($field =~ /(\S+\s+\*?)\(\*\s*(.+)\)\s*\((.*)\)/) { + # FIXME: how to handle function pointer fields with + # anonymous type? + #$elem = addNameElem($parent, 'callback', $2); + #addReturnElem($elem, $1); + #addParamsElem($elem, $3); + } elsif ($field =~ /(unsigned )?(\S+)\s+(.+)/) { + my $type = $1 . $2; $symb = $3; + foreach $tok (split (/,\s*/, $symb)) { + if ($tok =~ /(\w+)\s*\[(.*)\]/) { + $elem = addFNameElem($parent, 'field', $1, ""); + #$elem->setAttribute('array_len', "$2"); + } elsif ($tok =~ /(\w+)\s*\:\s*(\d+)/) { + $elem = addFNameElem($parent, 'field', $1, ""); + #$elem->setAttribute('bits', "$2"); + } else { + $elem = addFNameElem($parent, 'field', $tok, ""); + } + $elem->setAttribute('type', "$type"); + + if ($access eq "public") { + $elem->setAttribute("readable", "1"); + $elem->setAttribute("writable", "1"); + } + } + } else { + die "$field\n"; + } + } +} + +sub addFuncElems +{ + my ($obj_el, $inst, $prefix); + + $fcnt = keys(%fdefs); + + foreach $mname (sort (keys (%fdefs))) { + next if ($mname =~ /^_/); + $obj_el = ""; + $prefix = $mname; + $prepend = undef; + while ($prefix =~ /(\w+)_/) { + $prefix = $key = $1; + $key =~ s/_//g; + # FIXME: lame Gdk API hack + if ($key eq "gdkdraw") { + $key = "gdkdrawable"; + $prepend = "draw_"; + } + if (exists ($elem_table{$key})) { + $prefix .= "_"; + $obj_el = $elem_table{$key}; + $inst = $key; + last; + } elsif (exists ($enums{$key}) && ($mname =~ /_get_type/)) { + delete $fdefs{$mname}; + last; + } + } + next if (!$obj_el); + + $mdef = delete $fdefs{$mname}; + + # FIXME: gidl doesn't support constructors in structs, a bug? + if ($mname =~ /$prefix(new)/ && $obj_el->nodeName eq "object") { + $el = addMNameElem($obj_el, 'constructor', $mname, $prefix); + if ($mdef =~ /^deprecated/) { + $el->setAttribute("deprecated", "1"); + $mdef =~ s/deprecated//g; + } + $drop_1st = 0; + } else { + $el = addMNameElem($obj_el, 'method', $mname, $prefix, $prepend); + if ($mdef =~ /^deprecated/) { + $el->setAttribute("deprecated", "1"); + $mdef =~ s/deprecated//g; + } + $mdef =~ /(.*?)\w+\s*\(/; + addReturnElem($el, $1); + $mdef =~ /\(\s*(const)?\s*(\w+)/; + # FIXME: gidl doesn't distinguish between static and instance methods + # if (lc($2) ne $inst) { + # $el->setAttribute("shared", "true"); + # $drop_1st = 0; + # } else { + # $drop_1st = 1; + # } + } + + parseParms ($el, $mdef, $drop_1st); + + # Don't add "free" to this regexp; that will wrongly catch all boxed types + if ($mname =~ /$prefix(new|destroy|ref|unref)/ && + ($obj_el->nodeName eq "boxed" || $obj_el->nodeName eq "struct") && + $obj_el->getAttribute("opaque") ne "true") { + $obj_el->setAttribute("opaque", "true"); + for my $field ($obj_el->getElementsByTagName("field")) { + if (!$field->getAttribute("access")) { + $field->setAttribute("access", "public"); + $field->setAttribute("writeable", "true"); + } + } + } + } +} + +sub parseParms +{ + my ($el, $mdef, $drop_1st) = @_; + + $fmt_args = 0; + + if ($mdef =~ /G_GNUC_PRINTF.*\((\d+,\s*\d+)\s*\)/) { + $fmt_args = $1; + $mdef =~ s/\s*G_GNUC_PRINTF.*\)//; + } + + if (($mdef =~ /\((.*)\)/) && ($1 ne "void")) { + @parms = (); + $parm = ""; + $pcnt = 0; + foreach $char (split(//, $1)) { + if ($char eq "(") { + $pcnt++; + } elsif ($char eq ")") { + $pcnt--; + } elsif (($pcnt == 0) && ($char eq ",")) { + @parms = (@parms, $parm); + $parm = ""; + next; + } + $parm .= $char; + } + + if ($parm) { + @parms = (@parms, $parm); + } + # @parms = split(/,/, $1); + ($dump, @parms) = @parms if $drop_1st; + if (@parms > 0) { + addParamsElem($el, @parms); + } + + if ($fmt_args != 0) { + $fmt_args =~ /(\d+),\s*(\d+)/; + $fmt = $1; $args = $2; + ($params_el, @junk) = $el->getElementsByTagName ("parameters"); + (@params) = $params_el->getElementsByTagName ("parameter"); + $offset = 1 + $drop_1st; + } + } +} + +sub addStaticFuncElems +{ + my ($global_el, $ns_prefix); + + @mnames = sort (keys (%fdefs)); + $mcount = @mnames; + + return if ($mcount == 0); + + $ns_prefix = ""; + $global_el = ""; + + for ($i = 0; $i < $mcount; $i++) { + $mname = $mnames[$i]; + $prefix = $mname; + next if ($prefix =~ /^_/); + + if ($ns_prefix eq "") { + my (@toks) = split(/_/, $prefix); + for ($j = 0; $j < @toks; $j++) { + if (join ("", @toks[0 .. $j]) eq lc($ns)) { + $ns_prefix = join ("_", @toks[0 .. $j]); + last; + } + } + next if ($ns_prefix eq ""); + } + next if ($mname !~ /^$ns_prefix/); + + if ($mname =~ /($ns_prefix)_([a-zA-Z]+)_\w+/) { + $classname = $2; + $key = $prefix = $1 . "_" . $2 . "_"; + $key =~ s/_//g; + $cnt = 1; + if (exists ($enums{$key})) { + $cnt = 1; + } elsif ($classname ne "set" && $classname ne "get" && + $classname ne "scan" && $classname ne "find" && + $classname ne "add" && $classname ne "remove" && + $classname ne "free" && $classname ne "register" && + $classname ne "execute" && $classname ne "show" && + $classname ne "parse" && $classname ne "paint" && + $classname ne "string") { + while ($mnames[$i+$cnt] =~ /$prefix/) { $cnt++; } + } + if ($cnt == 1) { + $mdef = delete $fdefs{$mname}; + + if (!$global_el) { + $global_el = $doc->createElement('struct'); + $global_el->setAttribute('name', "Global"); + $global_el->setAttribute('cname', $ns . "Global"); + $ns_elem->appendChild($global_el); + } + $el = addMNameElem($global_el, 'method', $mname, $ns_prefix); + if ($mdef =~ /^deprecated/) { + $el->setAttribute("deprecated", "1"); + $mdef =~ s/deprecated//g; + } + $mdef =~ /(.*?)\w+\s*\(/; + addReturnElem($el, $1); + #$el->setAttribute("shared", "true"); + parseParms ($el, $mdef, 0); + next; + } else { + my $stname = $prefix; + $stname =~ s/_$//; + + $class_el = $doc->createElement('struct'); + $class_el->setAttribute('name', StudlyCaps($stname)); + $ns_elem->appendChild($class_el); + + for ($j = 0; $j < $cnt; $j++) { + $mdef = delete $fdefs{$mnames[$i+$j]}; + + $el = addMNameElem($class_el, 'method', $mnames[$i+$j], $prefix); + if ($mdef =~ /^deprecated/) { + $el->setAttribute("deprecated", "1"); + $mdef =~ s/deprecated//g; + } + $mdef =~ /(.*?)\w+\s*\(/; + addReturnElem($el, $1); + #$el->setAttribute("shared", "true"); + parseParms ($el, $mdef, 0); + } + $i += ($cnt - 1); + next; + } + } + } +} + +sub addNameElem +{ + my ($node, $type, $cname, $prefix, $prepend) = @_; + + my $elem = $doc->createElement($type); + $node->appendChild($elem); + if ($cname) { + $elem->setAttribute('name', $cname); + $elem->setAttribute('type-name', $cname); + } + return $elem; +} + +sub addFNameElem +{ + my ($node, $type, $cname, $prefix, $prepend) = @_; + + my $elem = $doc->createElement($type); + $node->appendChild($elem); + if (defined $prefix) { + my $match; + if ($cname =~ /$prefix(\w+)/) { + $match = $1; + } else { + $match = $cname; + } + if ($prepend) { + $name = $prepend . $match; + } else { + $name = $match; + } + $elem->setAttribute('name', $name); + } + return $elem; +} + +sub addMNameElem +{ + my ($node, $type, $cname, $prefix, $prepend) = @_; + + my $elem = $doc->createElement($type); + $node->appendChild($elem); + if (defined $prefix) { + my $match; + if ($cname =~ /$prefix(\w+)/) { + $match = $1; + } else { + $match = $cname; + } + if ($prepend) { + $name = $prepend . $match; + } else { + $name = $match; + } + $elem->setAttribute('name', $name); + } + if ($cname) { + $elem->setAttribute('symbol', $cname); + } + return $elem; +} + +sub addParamsElem +{ + my ($parent, @params) = @_; + + my $parms_elem = $doc->createElement('parameters'); + $parent->appendChild($parms_elem); + my $parm_num = 0; + foreach $parm (@params) { + $parm_num++; + $parm =~ s/\s+(\*+)/\1 /g; + my $out = $parm =~ s/G_CONST_RETURN/const/g; + $parm =~ s/(const\s+)?(\w+)\*\s+const\*/const \2\*/g; + $parm =~ s/(\*+)\s*const\s+/\1 /g; + $parm =~ s/(\w+)\s+const\s*\*/const \1\*/g; + $parm =~ s/const\s+/const-/g; + $parm =~ s/unsigned\s+/unsigned-/g; + if ($parm =~ /(.*)\(\s*\**\s*(\w+)\)\s+\((.*)\)/) { + my $ret = $1; my $cbn = $2; my $params = $3; + my $type = $parent->getAttribute('name') . StudlyCaps($cbn); + $cb_elem = addNameElem($ns_elem, 'callback', $type, $ns); + addReturnElem($cb_elem, $ret); + if ($params && ($params ne "void")) { + addParamsElem($cb_elem, split(/,/, $params)); + my $data_parm = $cb_elem->lastChild()->lastChild(); + if ($data_parm && $data_parm->getAttribute('type') eq "gpointer") { + $data_parm->setAttribute('name', 'data'); + } + } + $parm_elem = $doc->createElement('parameter'); + $parm_elem->setAttribute('type', $type); + $parm_elem->setAttribute('name', $cbn); + $parms_elem->appendChild($parm_elem); + next; + } elsif ($parm =~ /\.\.\./) { + # FIXME: GIDL doesn't seem to support ellipsis parameters yet + # $parm_elem = $doc->createElement('parameter'); + # $parms_elem->appendChild($parm_elem); + # $parm_elem->setAttribute('ellipsis', 'true'); + next; + } + $parm_elem = $doc->createElement('parameter'); + $parms_elem->appendChild($parm_elem); + my $name = ""; + if ($parm =~ /struct\s+(\S+)\s+(\S+)/) { + $parm_elem->setAttribute('type', $1); + $name = $2; + }elsif ($parm =~ /(unsigned )?(\S+)\s+(\S+)/) { + $parm_elem->setAttribute('type', $1 . $2); + $name = $3; + } elsif ($parm =~ /(\S+)/) { + $parm_elem->setAttribute('type', $1); + $name = "arg" . $parm_num; + } + if ($name =~ /(\w+)\[.*\]/) { + $name = $1; + $parm_elem->setAttribute('type', $parm_elem->getAttribute('type') . '[]'); + } + if ($out) { + $parm_elem->setAttribute('direction', "out"); + } + $parm_elem->setAttribute('name', $name); + } +} + +sub addReturnElem +{ + my ($parent, $ret) = @_; + + $ret =~ s/(\w+)\s+const\s*\*/const \1\*/g; + $ret =~ s/const|G_CONST_RETURN/const-/g; + $ret =~ s/\s+//g; + $ret =~ s/(const-)?(\w+)\*(const-)\*/const-\2\*\*/g; + my $ret_elem = $doc->createElement('return-type'); + $parent->appendChild($ret_elem); + $ret_elem->setAttribute('type', $ret); + return $ret_elem; +} + +sub addPropElem +{ + my ($spec, $node, $is_child) = @_; + my ($name, $mode, $docs); + $spec =~ /g_param_spec_(\w+)\s*\((.*)\s*\)\s*\)/; + my $type = $1; + my @params = split(/,/, $2); + + $name = $params[0]; + if ($defines{$name}) { + $name = $defines{$name}; + } else { + $name =~ s/\s*\"//g; + } + + $mode = $params[$#params]; + + if ($type =~ /boolean|float|double|^u?int|pointer|unichar/) { + $type = "g$type"; + } elsif ($type =~ /string/) { + $type = "gchar*"; + } elsif ($type =~ /boxed|object/) { + $type = $params[$#params-1]; + $type =~ s/TYPE_//; + $type =~ s/\s+//g; + $type = StudlyCaps(lc($type)); + } elsif ($type =~ /enum|flags/) { + $type = $params[$#params-2]; + $type =~ s/TYPE_//; + $type =~ s/\s+//g; + $type = StudlyCaps(lc($type)); + } + + $prop_elem = $doc->createElement($is_child ? "childprop" : "property"); + $node->appendChild($prop_elem); + $prop_elem->setAttribute('name', $name); + + $prop_elem->setAttribute('readable', "1") if ($mode =~ /READ/); + $prop_elem->setAttribute('writable', "1") if ($mode =~ /WRIT/); + $prop_elem->setAttribute('construct', "1") if ($mode =~ /CONSTRUCT(?!_)/); + $prop_elem->setAttribute('construct-only', "1") if ($mode =~ /CONSTRUCT_ONLY/); + + $prop_elem->setAttribute('type', $type); +} + +sub parseTypeToken +{ + my ($tok) = @_; + + if ($tok =~ /G_TYPE_(\w+)/) { + my $type = $1; + if ($type eq "NONE") { + return "void"; + } elsif ($type eq "INT") { + return "gint32"; + } elsif ($type eq "UINT") { + return "guint32"; + } elsif ($type eq "ENUM" || $type eq "FLAGS") { + return "gint32"; + } elsif ($type eq "STRING") { + return "gchar*"; + } elsif ($type eq "OBJECT") { + return "GObject*"; + } else { + return "g" . lc ($type); + } + } else { + $tok =~ s/_TYPE//; + $tok =~ s/\|.*STATIC_SCOPE//; + $tok =~ s/\W+//g; + return StudlyCaps (lc($tok)); + } +} + +sub addSignalElem +{ + my ($spec, $class, $node) = @_; + $spec =~ s/\n\s*//g; $class =~ s/\n\s*//g; + + $sig_elem = $doc->createElement('signal'); + $node->appendChild($sig_elem); + + if ($spec =~ /\(\"([\w\-]+)\"/) { + my $cname = $1; + $cname =~ s/-/_/g; + $sig_elem->setAttribute('name', $cname); + } + if ($spec =~ /_RUN_(\w+)/) { + $sig_elem->setAttribute('when', $1); + } else { + $sig_elem->setAttribute('when', "LAST"); + } + + my $method = ""; + if ($spec =~ /_OFFSET\s*\(\w+,\s*(\w+)\)/) { + $method = $1; + } else { + @args = split(/,/, $spec); + my $rettype = parseTypeToken ($args[7]); + addReturnElem($sig_elem, $rettype); + $parmcnt = $args[8]; + $parmcnt =~ s/.*(\d+).*/\1/; + $parms_elem = $doc->createElement('parameters'); + $sig_elem->appendChild($parms_elem); + $parm_elem = $doc->createElement('parameter'); + $parms_elem->appendChild($parm_elem); + $parm_elem->setAttribute('name', "inst"); + $parm_elem->setAttribute('type', "$inst*"); + for (my $idx = 0; $idx < $parmcnt; $idx++) { + my $argtype = parseTypeToken ($args[9+$idx]); + $parm_elem = $doc->createElement('parameter'); + $parms_elem->appendChild($parm_elem); + $parm_elem->setAttribute('name', "p$idx"); + $parm_elem->setAttribute('type', $argtype); + } + return $class; + } + + if ($class =~ /;\s*(\/\*< public >\*\/)?(G_CONST_RETURN\s+)?(\w+\s*\**)\s*\(\s*\*\s*$method\)\s*\((.*?)\);/) { + $ret = $3; $parms = $4; + addReturnElem($sig_elem, $ret); + if ($parms && ($parms ne "void")) { + addParamsElem($sig_elem, split(/,/, $parms)); + } + $class =~ s/;\s*(\/\*< public >\*\/)?(G_CONST_RETURN\s+)?\w+\s*\**\s*\(\s*\*\s*$method\)\s*\(.*?\);/;/; + } else { + #die "$method $class"; + return $class; + } + + return $class; +} + +sub addVirtualMethods +{ + my ($class, $node) = @_; + $class =~ s/\n\s*//g; + $class =~ s/\/\*.*?\*\///g; + + while ($class =~ /;\s*(G_CONST_RETURN\s+)?(\S+\s*\**)\s*\(\s*\*\s*(\w+)\)\s*\((.*?)\);/) { + $ret = $1 . $2; $cname = $3; $parms = $4; + if ($cname !~ /reserved/) { + $vm_elem = $doc->createElement('vfunc'); + $node->appendChild($vm_elem); + $vm_elem->setAttribute('name', $cname); + addReturnElem($vm_elem, $ret); + if ($parms && ($parms ne "void")) { + addParamsElem($vm_elem, split(/,/, $parms)); + } + } + $class =~ s/;\s*(G_CONST_RETURN\s+)?\S+\s*\**\s*\(\s*\*\s*\w+\)\s*\(.*?\);/;/; + } +} + +sub addImplementsElem +{ + my ($spec, $node) = @_; + $spec =~ s/\n\s*//g; + if ($spec =~ /,\s*(\w+)_TYPE_(\w+),/) { + $impl_elem = $doc->createElement('interface'); + $name = StudlyCaps (lc ("$1_$2")); + $impl_elem->setAttribute ("name", "$name"); + $node->appendChild($impl_elem); + } +} + + +sub parseInitFunc +{ + my ($obj_el, $initfunc) = @_; + + my @init_lines = split (/\n/, $initfunc); + + my $linenum = 0; + while ($linenum < @init_lines) { + + my $line = $init_lines[$linenum]; + + if ($line =~ /#define/) { + # FIXME: This ignores the bool helper macro thingie. + } elsif ($line =~ /g_object_(class|interface)_install_prop/) { + my $prop = $line; + do { + $prop .= $init_lines[++$linenum]; + } until ($init_lines[$linenum] =~ /\)\s*;/); + addPropElem ($prop, $obj_el, 0); + $propcnt++; + # FIXME: how to handle childprops in GIDL? + #} elsif ($line =~ /gtk_container_class_install_child_property/) { + # my $prop = $line; + # do { + # $prop .= $init_lines[++$linenum]; + # } until ($init_lines[$linenum] =~ /\)\s*;/); + # addPropElem ($prop, $obj_el, 1); + # $childpropcnt++; + } elsif ($line =~ /\bg.*_signal_new/) { + my $sig = $line; + do { + $sig .= $init_lines[++$linenum]; + } until ($init_lines[$linenum] =~ /;/); + $classdef = addSignalElem ($sig, $classdef, $obj_el); + $sigcnt++; + } + $linenum++; + } + + addVirtualMethods ($classdef, $obj_el); +} + +sub parseTypeFuncMacro +{ + my ($obj_el, $typefunc) = @_; + + $impls_node = undef; + while ($typefunc =~ /G_IMPLEMENT_INTERFACE\s*\(\s*(\w+)/) { + $iface = $1; + if (not $impls_node) { + $impls_node = $doc->createElement ("implements"); + $obj_el->appendChild ($impls_node); + } + addImplementsElem ($prop, $impl_node); + if ($iface =~ /(\w+)_TYPE_(\w+)/) { + $impl_elem = $doc->createElement('interface'); + $name = StudlyCaps (lc ("$1_$2")); + $impl_elem->setAttribute ("name", "$name"); + if ($name !~ /GtkFileChooserEmbed/) { + $impls_node->appendChild($impl_elem); + } + } + $typefunc =~ s/G_IMPLEMENT_INTERFACE\s*\(.*?\)//; + } +} + +sub parseTypeFunc +{ + my ($obj_el, $typefunc) = @_; + + my @type_lines = split (/\n/, $typefunc); + + my $linenum = 0; + $impl_node = undef; + while ($linenum < @type_lines) { + + my $line = $type_lines[$linenum]; + + if ($line =~ /#define/) { + # FIXME: This ignores the bool helper macro thingie. + } elsif ($line =~ /g_type_add_interface_static/) { + my $prop = $line; + do { + $prop .= $type_lines[++$linenum]; + } until ($type_lines[$linenum] =~ /;/); + if (not $impl_node) { + $impl_node = $doc->createElement ("implements"); + $obj_el->appendChild ($impl_node); + } + addImplementsElem ($prop, $impl_node); + } + $linenum++; + } +} + +############################################################## +# Converts a dash or underscore separated name to StudlyCaps. +############################################################## + +%num2txt = ('1', "One", '2', "Two", '3', "Three", '4', "Four", '5', "Five", + '6', "Six", '7', "Seven", '8', "Eight", '9', "Nine", '0', "Zero"); + +sub StudlyCaps +{ + my ($symb) = @_; + $symb =~ s/^([a-z])/\u\1/; + $symb =~ s/^(\d)/\1_/; + $symb =~ s/[-_]([a-z])/\u\1/g; + $symb =~ s/[-_](\d)/\1/g; + $symb =~ s/^2/Two/; + $symb =~ s/^3/Three/; + return $symb; +} + diff --git a/vapigen/gidlgen/gapi_pp.pl b/vapigen/gidlgen/gapi_pp.pl new file mode 100755 index 000000000..fcfe0acf4 --- /dev/null +++ b/vapigen/gidlgen/gapi_pp.pl @@ -0,0 +1,257 @@ +#!/usr/bin/perl +# +# gapi_pp.pl : A source preprocessor for the extraction of API info from a +# C library source directory. +# +# Authors: Mike Kestner +# Martin Willemoes Hansen +# +# 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 = ) { + $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 = );} + print $def; + } elsif ($line =~ /#\s*define\s+\w+\s*\D+/) { + $def = $line; + while ($line =~ /\\\n/) {$def .= ($line = );} + if ($def =~ /_CHECK_\w*CAST|INSTANCE_GET_INTERFACE/) { + $def =~ s/\\\n//g; + print $def; + } + } elsif ($line =~ /^\s*\/\*[^<]/) { + while ($line !~ /\*\//) {$line = ;} + } elsif ($line =~ /^extern/) { + while ($line !~ /;/) {$line = ;} + } elsif ($line =~ /^#ifndef\s+\w+_H_*\b/) { + while ($line !~ /#define/) {$line = ;} + } elsif ($line =~ /$private_regex/) { + $nested = 0; + while ($line = ) { + last if (!$nested && ($line =~ /#else|#endif/)); + if ($line =~ /#if/) { + $nested++; + } elsif ($line =~ /#endif/) { + $nested-- + } + next if ($line !~ /^struct/); + + print "private$line"; + do { + $line = ; + print $line; + } until ($line =~ /^\}/); + } + } elsif ($line =~ /$eatit_regex/) { + $nested = 0; + while ($line = ) { + 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 = ; + while ($line !~ /^}\s*(\w+);/) { + push @lines, $line; + $line = ; + } + $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 = ;} + } elsif ($line =~ /^(typedef\s+)?union/) { + next if ($line =~ /^typedef\s+union\s+\w+\s+\w+;/); + while ($line !~ /^};/) {$line = ;} + } 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 = ; + 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 = ) { + next if ($line !~ /\{/); + + chomp($line); + $builtin = "BUILTIN" . $line; + $builtin .= ; + print $builtin; + } + next; + } + + while ($line = ) { + 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 = ; + } 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 = ) =~ /^}/); + print $line; + } +} + diff --git a/vapigen/gidlgen/gidlgen b/vapigen/gidlgen/gidlgen new file mode 100755 index 000000000..163b61a8b --- /dev/null +++ b/vapigen/gidlgen/gidlgen @@ -0,0 +1,35 @@ +#!/bin/sh + +pkglibdir=$(dirname $0) + +SOURCE=$1 +PKGBASE=$2 + +if [ $# -ne 2 ] +then + echo "Usage: $0 SOURCE PKGBASE" + 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 + +perl $pkglibdir/gapi_pp.pl $(cat $PKGBASE.files | sed -e "s@^@$PKGBASE-src/@") | perl $pkglibdir/gapi2xml.pl $(cat $PKGBASE.namespace) $PKGBASE.raw + +xml_pp $PKGBASE.raw > $PKGBASE.gidl + +rm -rf $PKGBASE-src diff --git a/vapigen/gobject-introspection/Makefile.am b/vapigen/gobject-introspection/Makefile.am new file mode 100644 index 000000000..7196fe6e3 --- /dev/null +++ b/vapigen/gobject-introspection/Makefile.am @@ -0,0 +1,25 @@ +NULL = + +INCLUDES = \ + $(GLIB_CFLAGS) \ + $(NULL) + +noinst_LTLIBRARIES = \ + libgidl.la \ + $(NULL) + +libgidl_la_SOURCES = \ + gidlmodule.c \ + gidlmodule.h \ + gidlnode.c \ + gidlnode.h \ + gidlparser.c \ + gidlparser.h \ + gmetadata.h \ + $(NULL) + +libgidl_la_LIBADD = \ + $(GLIB_LIBS) \ + $(NULL) + +EXTRA_DIST = gidl.vala diff --git a/vapigen/gobject-introspection/gidl.vala b/vapigen/gobject-introspection/gidl.vala new file mode 100644 index 000000000..2572b3212 --- /dev/null +++ b/vapigen/gobject-introspection/gidl.vala @@ -0,0 +1,260 @@ +/* gidl.vala + * + * Copyright (C) 2006 Jürg Billeter + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +[CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")] +namespace GLib { + [CCode (cheader_filename = "gidlparser.h")] + public struct Idl { + public static ref List parse_file (string! filename, out Error error); + } + + [CCode (cheader_filename = "gidlmodule.h")] + [ReferenceType (free_function = "g_idl_module_free")] + public struct IdlModule { + public string name; + public List entries; + } + + [CCode (cprefix = "G_IDL_NODE_", cheader_filename = "gidlnode.h")] + public enum IdlNodeTypeId { + INVALID, + FUNCTION, + CALLBACK, + STRUCT, + BOXED, + ENUM, + FLAGS, + OBJECT, + INTERFACE, + CONSTANT, + ERROR_DOMAIN, + UNION, + PARAM, + TYPE, + PROPERTY, + SIGNAL, + VALUE, + VFUNC, + FIELD, + XREF + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNode { + public IdlNodeTypeId type; + public string name; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeFunction { + public bool deprecated; + + public bool is_method; + public bool is_setter; + public bool is_getter; + public bool is_constructor; + public bool wraps_vfunc; + + public string symbol; + + public IdlNodeParam result; + public List parameters; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeSignal { + public bool deprecated; + + public bool run_first; + public bool run_last; + public bool run_cleanup; + public bool no_recurse; + public bool detailed; + public bool action; + public bool no_hooks; + + public bool has_class_closure; + public bool true_stops_emit; + + public int class_closure; + + public List parameters; + public IdlNodeParam result; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeBoxed { + public bool deprecated; + + public string gtype_name; + public string gtype_init; + + public List members; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeEnum { + public bool deprecated; + + public string gtype_name; + public string gtype_init; + + public List values; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeField { + public bool readable; + public bool writable; + public int bits; + public int offset; + + public IdlNodeType type; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeConstant { + public bool deprecated; + + public IdlNodeType type; + + public string value; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeInterface { + public bool deprecated; + + public string gtype_name; + public string gtype_init; + + public string parent; + + public List interfaces; + public List prerequisites; + + public List members; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeParam { + public bool @in; + public bool @out; + public bool dipper; + public bool optional; + public bool retval; + public bool null_ok; + public bool transfer; + public bool shallow_transfer; + + public IdlNodeType type; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeProperty { + public bool deprecated; + + public string name; + + public bool readable; + public bool writable; + public bool @construct; + public bool construct_only; + + public IdlNodeType type; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeStruct { + public bool deprecated; + + public List members; + } + + [CCode (cheader_filename = "gidlnode.h")] + [ReferenceType (free_function = "g_idl_node_free")] + public struct IdlNodeType { + public bool is_pointer; + public bool is_basic; + public bool is_array; + public bool is_glist; + public bool is_gslist; + public bool is_ghashtable; + public bool is_interface; + public bool is_error; + public TypeTag tag; + + public string unparsed; + + public bool zero_terminated; + public bool has_length; + public int length; + + public IdlNodeType parameter_type1; + public IdlNodeType parameter_type2; + + public string @interface; + public string[] errors; + } + + [CCode (cprefix = "TYPE_TAG_", cheader_filename = "gmetadata.h")] + public enum TypeTag + { + VOID, + BOOLEAN, + INT8, + UINT8, + INT16, + UINT16, + INT32, + UINT32, + INT64, + UINT64, + INT, + UINT, + LONG, + ULONG, + SSIZE, + SIZE, + FLOAT, + DOUBLE, + UTF8, + FILENAME, + ARRAY, + INTERFACE, + LIST, + SLIST, + HASH, + ERROR + } +} diff --git a/vapigen/gobject-introspection/gidlmodule.c b/vapigen/gobject-introspection/gidlmodule.c new file mode 100644 index 000000000..2d4929e0a --- /dev/null +++ b/vapigen/gobject-introspection/gidlmodule.c @@ -0,0 +1,208 @@ +/* GObject introspection: Metadata creation + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#include +#include + +#include "gidlmodule.h" +#include "gidlnode.h" +#include "gmetadata.h" + +#define ALIGN_VALUE(this, boundary) \ + (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1))) + + +GIdlModule * +g_idl_module_new (const gchar *name) +{ + GIdlModule *module; + + module = g_new (GIdlModule, 1); + + module->name = g_strdup (name); + module->entries = NULL; + + return module; +} + +void +g_idl_module_free (GIdlModule *module) +{ + GList *e; + + g_free (module->name); + + for (e = module->entries; e; e = e->next) + g_idl_node_free ((GIdlNode *)e->data); + + g_list_free (module->entries); + + g_free (module); +} + +void +g_idl_module_build_metadata (GIdlModule *module, + GList *modules, + guchar **metadata, + gsize *length) +{ + gint i; + GList *e; + Header *header; + DirEntry *entry; + guint32 header_size; + guint32 dir_size; + guint32 n_entries; + guint32 n_local_entries; + guint32 size, offset, offset2, old_offset; + GHashTable *strings; + GHashTable *types; + guchar *data; + + header_size = ALIGN_VALUE (sizeof (Header), 4); + n_local_entries = g_list_length (module->entries); + + restart: + init_stats (); + strings = g_hash_table_new (g_str_hash, g_str_equal); + types = g_hash_table_new (g_str_hash, g_str_equal); + n_entries = g_list_length (module->entries); + + g_message ("%d entries (%d local)\n", n_entries, n_local_entries); + + dir_size = n_entries * 12; + size = header_size + dir_size; + + size += ALIGN_VALUE (strlen (module->name) + 1, 4); + + for (e = module->entries; e; e = e->next) + { + GIdlNode *node = e->data; + + size += g_idl_node_get_full_size (node); + } + + g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n", + size, header_size, dir_size, size - header_size - dir_size); + + data = g_malloc0 (size); + + /* fill in header */ + header = (Header *)data; + memcpy (header, G_IDL_MAGIC, 16); + header->major_version = 1; + header->minor_version = 0; + header->reserved = 0; + header->n_entries = n_entries; + header->n_local_entries = n_local_entries; + header->n_annotations = 0; + header->annotations = 0; /* filled in later */ + header->size = 0; /* filled in later */ + header->namespace = write_string (module->name, strings, data, &header_size); + header->directory = ALIGN_VALUE (header_size, 4); + header->entry_blob_size = 12; + header->function_blob_size = 16; + header->callback_blob_size = 12; + header->signal_blob_size = 12; + header->vfunc_blob_size = 16; + header->arg_blob_size = 12; + header->property_blob_size = 12; + header->field_blob_size = 12; + header->value_blob_size = 12; + header->constant_blob_size = 20; + header->error_domain_blob_size = 16; + header->annotation_blob_size = 12; + header->signature_blob_size = 8; + header->enum_blob_size = 20; + header->struct_blob_size = 20; + header->object_blob_size = 32; + header->interface_blob_size = 28; + header->union_blob_size = 28; + + /* fill in directory and content */ + entry = (DirEntry *)&data[header->directory]; + + offset2 = header->directory + dir_size; + + for (e = module->entries, i = 0; e; e = e->next, i++) + { + GIdlNode *node = e->data; + + if (strchr (node->name, '.')) + { + g_error ("Names may not contain '.'"); + } + + /* we picked up implicit xref nodes, start over */ + if (i == n_entries) + { + g_message ("Found implicit cross references, starting over"); + + g_hash_table_destroy (strings); + g_hash_table_destroy (types); + strings = NULL; + + g_free (data); + data = NULL; + + goto restart; + } + + offset = offset2; + + if (node->type == G_IDL_NODE_XREF) + { + entry->blob_type = 0; + entry->local = FALSE; + entry->offset = write_string (((GIdlNodeXRef*)node)->namespace, strings, data, &offset2); + entry->name = write_string (node->name, strings, data, &offset2); + } + else + { + old_offset = offset; + offset2 = offset + g_idl_node_get_size (node); + + entry->blob_type = node->type; + entry->local = TRUE; + entry->offset = offset; + entry->name = write_string (node->name, strings, data, &offset2); + + g_idl_node_build_metadata (node, module, modules, + strings, types, data, &offset, &offset2); + + if (offset2 > old_offset + g_idl_node_get_full_size (node)) + g_error ("left a hole of %d bytes\n", offset2 - old_offset - g_idl_node_get_full_size (node)); + } + + entry++; + } + + dump_stats (); + g_hash_table_destroy (strings); + g_hash_table_destroy (types); + + header->annotations = offset2; + + g_message ("reallocating to %d bytes", offset2); + + *metadata = g_realloc (data, offset2); + *length = header->size = offset2; +} + diff --git a/vapigen/gobject-introspection/gidlmodule.h b/vapigen/gobject-introspection/gidlmodule.h new file mode 100644 index 000000000..17135764c --- /dev/null +++ b/vapigen/gobject-introspection/gidlmodule.h @@ -0,0 +1,47 @@ +/* GObject introspection: Parsed IDL + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#ifndef __G_IDL_MODULE_H__ +#define __G_IDL_MODULE_H__ + +#include + +G_BEGIN_DECLS + + +typedef struct _GIdlModule GIdlModule; + +struct _GIdlModule +{ + gchar *name; + GList *entries; +}; + +GIdlModule *g_idl_module_new (const gchar *name); +void g_idl_module_free (GIdlModule *module); + +void g_idl_module_build_metadata (GIdlModule *module, + GList *modules, + guchar **metadata, + gsize *length); + +G_END_DECLS + +#endif /* __G_IDL_MODULE_H__ */ diff --git a/vapigen/gobject-introspection/gidlnode.c b/vapigen/gobject-introspection/gidlnode.c new file mode 100644 index 000000000..bbde2a005 --- /dev/null +++ b/vapigen/gobject-introspection/gidlnode.c @@ -0,0 +1,1992 @@ +/* GObject introspection: Metadata creation + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#include +#include + +#include "gidlmodule.h" +#include "gidlnode.h" +#include "gmetadata.h" + +static gulong string_count = 0; +static gulong unique_string_count = 0; +static gulong string_size = 0; +static gulong unique_string_size = 0; +static gulong types_count = 0; +static gulong unique_types_count = 0; + +void +init_stats (void) +{ + string_count = 0; + unique_string_count = 0; + string_size = 0; + unique_string_size = 0; + types_count = 0; + unique_types_count = 0; +} + +void +dump_stats (void) +{ + g_message ("%d strings (%d before sharing), %d bytes (%d before sharing)", + unique_string_count, string_count, unique_string_size, string_size); + g_message ("%d types (%d before sharing)", unique_types_count, types_count); +} + +#define ALIGN_VALUE(this, boundary) \ + (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1))) + + +GIdlNode * +g_idl_node_new (GIdlNodeTypeId type) +{ + GIdlNode *node = NULL; + + switch (type) + { + case G_IDL_NODE_FUNCTION: + node = g_malloc0 (sizeof (GIdlNodeFunction)); + break; + + case G_IDL_NODE_PARAM: + node = g_malloc0 (sizeof (GIdlNodeParam)); + break; + + case G_IDL_NODE_TYPE: + node = g_malloc0 (sizeof (GIdlNodeType)); + break; + + case G_IDL_NODE_OBJECT: + case G_IDL_NODE_INTERFACE: + node = g_malloc0 (sizeof (GIdlNodeInterface)); + break; + + case G_IDL_NODE_SIGNAL: + node = g_malloc0 (sizeof (GIdlNodeSignal)); + break; + + case G_IDL_NODE_PROPERTY: + node = g_malloc0 (sizeof (GIdlNodeProperty)); + break; + + case G_IDL_NODE_VFUNC: + node = g_malloc0 (sizeof (GIdlNodeFunction)); + break; + + case G_IDL_NODE_FIELD: + node = g_malloc0 (sizeof (GIdlNodeField)); + break; + + case G_IDL_NODE_ENUM: + case G_IDL_NODE_FLAGS: + node = g_malloc0 (sizeof (GIdlNodeEnum)); + break; + + case G_IDL_NODE_BOXED: + node = g_malloc0 (sizeof (GIdlNodeBoxed)); + break; + + case G_IDL_NODE_STRUCT: + node = g_malloc0 (sizeof (GIdlNodeStruct)); + break; + + case G_IDL_NODE_VALUE: + node = g_malloc0 (sizeof (GIdlNodeValue)); + break; + + case G_IDL_NODE_CONSTANT: + node = g_malloc0 (sizeof (GIdlNodeConstant)); + break; + + case G_IDL_NODE_ERROR_DOMAIN: + node = g_malloc0 (sizeof (GIdlNodeErrorDomain)); + break; + + case G_IDL_NODE_XREF: + node = g_malloc0 (sizeof (GIdlNodeXRef)); + break; + + case G_IDL_NODE_UNION: + node = g_malloc0 (sizeof (GIdlNodeUnion)); + break; + + default: + g_error ("Unhandled node type %d\n", type); + break; + } + + node->type = type; + + return node; +} + +void +g_idl_node_free (GIdlNode *node) +{ + GList *l; + + if (node == NULL) + return; + + switch (node->type) + { + case G_IDL_NODE_FUNCTION: + case G_IDL_NODE_CALLBACK: + { + GIdlNodeFunction *function = (GIdlNodeFunction *)node; + + g_free (node->name); + g_free (function->symbol); + g_idl_node_free ((GIdlNode *)function->result); + for (l = function->parameters; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (function->parameters); + } + break; + + case G_IDL_NODE_TYPE: + { + GIdlNodeType *type = (GIdlNodeType *)node; + + g_free (node->name); + g_idl_node_free ((GIdlNode *)type->parameter_type1); + g_idl_node_free ((GIdlNode *)type->parameter_type2); + + g_free (type->interface); + g_strfreev (type->errors); + + } + break; + + case G_IDL_NODE_PARAM: + { + GIdlNodeParam *param = (GIdlNodeParam *)node; + + g_free (node->name); + g_idl_node_free ((GIdlNode *)param->type); + } + break; + + case G_IDL_NODE_PROPERTY: + { + GIdlNodeProperty *property = (GIdlNodeProperty *)node; + + g_free (node->name); + g_idl_node_free ((GIdlNode *)property->type); + } + break; + + case G_IDL_NODE_SIGNAL: + { + GIdlNodeSignal *signal = (GIdlNodeSignal *)node; + + g_free (node->name); + for (l = signal->parameters; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (signal->parameters); + g_idl_node_free ((GIdlNode *)signal->result); + } + break; + + case G_IDL_NODE_VFUNC: + { + GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node; + + g_free (node->name); + for (l = vfunc->parameters; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (vfunc->parameters); + g_idl_node_free ((GIdlNode *)vfunc->result); + } + break; + + case G_IDL_NODE_FIELD: + { + GIdlNodeField *field = (GIdlNodeField *)node; + + g_free (node->name); + g_idl_node_free ((GIdlNode *)field->type); + } + break; + + case G_IDL_NODE_OBJECT: + case G_IDL_NODE_INTERFACE: + { + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + g_free (node->name); + g_free (iface->gtype_name); + g_free (iface->gtype_init); + + g_free (iface->parent); + + for (l = iface->interfaces; l; l = l->next) + g_free ((GIdlNode *)l->data); + g_list_free (iface->interfaces); + + for (l = iface->members; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (iface->members); + + } + break; + + case G_IDL_NODE_VALUE: + { + GIdlNodeValue *value = (GIdlNodeValue *)node; + + g_free (node->name); + } + break; + + case G_IDL_NODE_ENUM: + case G_IDL_NODE_FLAGS: + { + GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node; + + g_free (node->name); + g_free (enum_->gtype_name); + g_free (enum_->gtype_init); + + for (l = enum_->values; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (enum_->values); + } + break; + + case G_IDL_NODE_BOXED: + { + GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node; + + g_free (node->name); + g_free (boxed->gtype_name); + g_free (boxed->gtype_init); + + for (l = boxed->members; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (boxed->members); + } + break; + + case G_IDL_NODE_STRUCT: + { + GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node; + + g_free (node->name); + for (l = struct_->members; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + g_list_free (struct_->members); + } + break; + + case G_IDL_NODE_CONSTANT: + { + GIdlNodeConstant *constant = (GIdlNodeConstant *)node; + + g_free (node->name); + g_free (constant->value); + g_idl_node_free ((GIdlNode *)constant->type); + } + break; + + case G_IDL_NODE_ERROR_DOMAIN: + { + GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node; + + g_free (node->name); + g_free (domain->getquark); + g_free (domain->codes); + } + break; + + case G_IDL_NODE_XREF: + { + GIdlNodeXRef *xref = (GIdlNodeXRef *)node; + + g_free (node->name); + g_free (xref->namespace); + } + break; + + case G_IDL_NODE_UNION: + { + GIdlNodeUnion *union_ = (GIdlNodeUnion *)node; + + g_free (node->name); + g_free (union_->gtype_name); + g_free (union_->gtype_init); + + g_idl_node_free ((GIdlNode *)union_->discriminator_type); + for (l = union_->members; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + g_idl_node_free ((GIdlNode *)l->data); + } + break; + + default: + g_error ("Unhandled node type %d\n", node->type); + break; + } + + g_free (node); +} + +/* returns the fixed size of the blob */ +guint32 +g_idl_node_get_size (GIdlNode *node) +{ + GList *l; + gint size, n; + + switch (node->type) + { + case G_IDL_NODE_CALLBACK: + size = 12; + break; + + case G_IDL_NODE_FUNCTION: + size = 16; + break; + + case G_IDL_NODE_PARAM: + size = 12; + break; + + case G_IDL_NODE_TYPE: + size = 4; + break; + + case G_IDL_NODE_OBJECT: + { + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + n = g_list_length (iface->interfaces); + size = 32 + 2 * (n + (n % 2)); + + for (l = iface->members; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_INTERFACE: + { + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + n = g_list_length (iface->prerequisites); + size = 28 + 2 * (n + (n % 2)); + + for (l = iface->members; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_ENUM: + case G_IDL_NODE_FLAGS: + { + GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node; + + size = 20; + for (l = enum_->values; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_VALUE: + size = 12; + break; + + case G_IDL_NODE_STRUCT: + { + GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node; + + size = 20; + for (l = struct_->members; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_BOXED: + { + GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node; + + size = 20; + for (l = boxed->members; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_PROPERTY: + size = 12; + break; + + case G_IDL_NODE_SIGNAL: + size = 12; + break; + + case G_IDL_NODE_VFUNC: + size = 16; + break; + + case G_IDL_NODE_FIELD: + size = 12; + break; + + case G_IDL_NODE_CONSTANT: + size = 20; + break; + + case G_IDL_NODE_ERROR_DOMAIN: + size = 16; + break; + + case G_IDL_NODE_XREF: + size = 0; + break; + + case G_IDL_NODE_UNION: + { + GIdlNodeUnion *union_ = (GIdlNodeUnion *)node; + + size = 28; + for (l = union_->members; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + size += g_idl_node_get_size ((GIdlNode *)l->data); + } + break; + + default: + g_error ("Unhandled node type %d\n", node->type); + size = 0; + } + + g_debug ("node %d type %d size %d", node, node->type, size); + + return size; +} + +/* returns the full size of the blob including variable-size parts */ +guint32 +g_idl_node_get_full_size (GIdlNode *node) +{ + GList *l; + gint size, n; + + g_assert (node != NULL); + + switch (node->type) + { + case G_IDL_NODE_CALLBACK: + { + GIdlNodeFunction *function = (GIdlNodeFunction *)node; + size = 12; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = function->parameters; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + size += g_idl_node_get_full_size ((GIdlNode *)function->result); + } + break; + + case G_IDL_NODE_FUNCTION: + { + GIdlNodeFunction *function = (GIdlNodeFunction *)node; + size = 24; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (function->symbol) + 1, 4); + for (l = function->parameters; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + size += g_idl_node_get_full_size ((GIdlNode *)function->result); + } + break; + + case G_IDL_NODE_PARAM: + { + GIdlNodeParam *param = (GIdlNodeParam *)node; + + size = 12; + if (node->name) + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += g_idl_node_get_full_size ((GIdlNode *)param->type); + } + break; + + case G_IDL_NODE_TYPE: + { + GIdlNodeType *type = (GIdlNodeType *)node; + if (type->tag < TYPE_TAG_ARRAY) + size = 4; + else + { + switch (type->tag) + { + case TYPE_TAG_ARRAY: + size = 4 + 4; + if (type->parameter_type1) + size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1); + break; + case TYPE_TAG_INTERFACE: + size = 4 + 4; + break; + case TYPE_TAG_LIST: + case TYPE_TAG_SLIST: + size = 4 + 4; + if (type->parameter_type1) + size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1); + break; + case TYPE_TAG_HASH: + size = 4 + 4 + 4; + if (type->parameter_type1) + size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1); + if (type->parameter_type2) + size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type2); + break; + case TYPE_TAG_ERROR: + { + gint n; + + if (type->errors) + n = g_strv_length (type->errors); + else + n = 0; + + size = 4 + 4 + 2 * (n + n % 2); + } + break; + default: + g_error ("Unknown type tag %d\n", type->tag); + break; + } + } + } + break; + + case G_IDL_NODE_OBJECT: + { + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + n = g_list_length (iface->interfaces); + size = 32; + if (iface->parent) + size += ALIGN_VALUE (strlen (iface->parent) + 1, 4); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); + size += 2 * (n + (n % 2)); + + for (l = iface->members; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_INTERFACE: + { + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + n = g_list_length (iface->prerequisites); + size = 28; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); + size += 2 * (n + (n % 2)); + + for (l = iface->members; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_ENUM: + case G_IDL_NODE_FLAGS: + { + GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node; + + size = 20; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (enum_->gtype_name) + { + size += ALIGN_VALUE (strlen (enum_->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (enum_->gtype_init) + 1, 4); + } + + for (l = enum_->values; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_VALUE: + { + GIdlNodeValue *value = (GIdlNodeValue *)node; + + size = 12; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + } + break; + + case G_IDL_NODE_STRUCT: + { + GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node; + + size = 20; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = struct_->members; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_BOXED: + { + GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node; + + size = 20; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (boxed->gtype_name) + { + size += ALIGN_VALUE (strlen (boxed->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (boxed->gtype_init) + 1, 4); + } + for (l = boxed->members; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + case G_IDL_NODE_PROPERTY: + { + GIdlNodeProperty *prop = (GIdlNodeProperty *)node; + + size = 12; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += g_idl_node_get_full_size ((GIdlNode *)prop->type); + } + break; + + case G_IDL_NODE_SIGNAL: + { + GIdlNodeSignal *signal = (GIdlNodeSignal *)node; + + size = 12; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = signal->parameters; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + size += g_idl_node_get_full_size ((GIdlNode *)signal->result); + } + break; + + case G_IDL_NODE_VFUNC: + { + GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node; + + size = 16; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = vfunc->parameters; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + size += g_idl_node_get_full_size ((GIdlNode *)vfunc->result); + } + break; + + case G_IDL_NODE_FIELD: + { + GIdlNodeField *field = (GIdlNodeField *)node; + + size = 12; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += g_idl_node_get_full_size ((GIdlNode *)field->type); + } + break; + + case G_IDL_NODE_CONSTANT: + { + GIdlNodeConstant *constant = (GIdlNodeConstant *)node; + + size = 20; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + /* FIXME non-string values */ + size += ALIGN_VALUE (strlen (constant->value) + 1, 4); + size += g_idl_node_get_full_size ((GIdlNode *)constant->type); + } + break; + + case G_IDL_NODE_ERROR_DOMAIN: + { + GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node; + + size = 16; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (domain->getquark) + 1, 4); + } + break; + + case G_IDL_NODE_XREF: + { + GIdlNodeXRef *xref = (GIdlNodeXRef *)node; + + size = 0; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4); + } + break; + + case G_IDL_NODE_UNION: + { + GIdlNodeUnion *union_ = (GIdlNodeUnion *)node; + + size = 28; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = union_->members; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + size += g_idl_node_get_full_size ((GIdlNode *)l->data); + } + break; + + default: + g_error ("Unknown type tag %d\n", node->type); + size = 0; + } + + g_debug ("node %d type %d full size %d", node, node->type, size); + + return size; +} + +static gint64 +parse_int_value (const gchar *str) +{ + return strtoll (str, NULL, 0); +} + +static guint64 +parse_uint_value (const gchar *str) +{ + return strtoull (str, NULL, 0); +} + +static gdouble +parse_float_value (const gchar *str) +{ + return strtod (str, NULL); +} + +static gboolean +parse_boolean_value (const gchar *str) +{ + if (strcmp (str, "TRUE") == 0) + return TRUE; + + if (strcmp (str, "FALSE") == 0) + return FALSE; + + return parse_int_value (str) ? TRUE : FALSE; +} + +static GIdlNode * +find_entry_node (GIdlModule *module, + GList *modules, + const gchar *name, + guint16 *idx) + +{ + GList *l; + gint i; + gchar **names; + gint n_names; + GIdlNode *result = NULL; + + names = g_strsplit (name, ".", 0); + n_names = g_strv_length (names); + if (n_names > 2) + g_error ("Too many name parts"); + + for (l = module->entries, i = 1; l; l = l->next, i++) + { + GIdlNode *node = (GIdlNode *)l->data; + + if (n_names > 1) + { + if (node->type != G_IDL_NODE_XREF) + continue; + + if (((GIdlNodeXRef *)node)->namespace == NULL || + strcmp (((GIdlNodeXRef *)node)->namespace, names[0]) != 0) + continue; + } + + if (strcmp (node->name, names[n_names - 1]) == 0) + { + if (idx) + *idx = i; + + result = node; + goto out; + } + } + + if (n_names > 1) + { + GIdlNode *node = g_idl_node_new (G_IDL_NODE_XREF); + + ((GIdlNodeXRef *)node)->namespace = g_strdup (names[0]); + node->name = g_strdup (names[1]); + + module->entries = g_list_append (module->entries, node); + + if (idx) + *idx = g_list_length (module->entries); + + result = node; + + goto out; + } + + g_warning ("Entry %s not found", name); + + out: + + g_strfreev (names); + + return result; +} + +static guint16 +find_entry (GIdlModule *module, + GList *modules, + const gchar *name) +{ + guint16 idx = 0; + + find_entry_node (module, modules, name, &idx); + + return idx; +} + +static void +serialize_type (GIdlModule *module, + GList *modules, + GIdlNodeType *node, + GString *str) +{ + gint i; + const gchar* basic[] = { + "void", + "gboolean", + "gint8", + "guint8", + "gint16", + "guint16", + "gint32", + "guint32", + "gint64", + "guint64", + "gint", + "guint", + "glong", + "gulong", + "gssize", + "gsize", + "gfloat", + "gdouble", + "utf8", + "filename" + }; + + if (node->tag < 20) + { + g_string_append_printf (str, "%s%s", + basic[node->tag], node->is_pointer ? "*" : ""); + } + else if (node->tag == 20) + { + serialize_type (module, modules, node->parameter_type1, str); + g_string_append (str, "["); + + if (node->has_length) + g_string_append_printf (str, "length=%d", node->length); + + if (node->zero_terminated) + g_string_append_printf (str, "%szero-terminated=1", + node->has_length ? "," : ""); + + g_string_append (str, "]"); + } + else if (node->tag == 21) + { + GIdlNode *iface; + gchar *name; + + iface = find_entry_node (module, modules, node->interface, NULL); + if (iface) + name = iface->name; + else + { + g_warning ("Interface for type reference %s not found", node->interface); + name = node->interface; + } + + g_string_append_printf (str, "%s%s", name, node->is_pointer ? "*" : ""); + } + else if (node->tag == 22) + { + g_string_append (str, "GList"); + if (node->parameter_type1) + { + g_string_append (str, "<"); + serialize_type (module, modules, node->parameter_type1, str); + g_string_append (str, ">"); + } + } + else if (node->tag == 23) + { + g_string_append (str, "GSList"); + if (node->parameter_type1) + { + g_string_append (str, "<"); + serialize_type (module, modules, node->parameter_type1, str); + g_string_append (str, ">"); + } + } + else if (node->tag == 24) + { + g_string_append (str, "GHashTable<"); + if (node->parameter_type1) + { + g_string_append (str, "<"); + serialize_type (module, modules, node->parameter_type1, str); + g_string_append (str, ","); + serialize_type (module, modules, node->parameter_type2, str); + g_string_append (str, ">"); + } + } + else if (node->tag == 25) + { + g_string_append (str, "GError"); + if (node->errors) + { + g_string_append (str, "<"); + for (i = 0; node->errors[i]; i++) + { + if (i > 0) + g_string_append (str, ","); + g_string_append (str, node->errors[i]); + } + g_string_append (str, ">"); + } + } +} + +void +g_idl_node_build_metadata (GIdlNode *node, + GIdlModule *module, + GList *modules, + GHashTable *strings, + GHashTable *types, + guchar *data, + guint32 *offset, + guint32 *offset2) +{ + GList *l; + guint32 old_offset = *offset; + guint32 old_offset2 = *offset2; + + switch (node->type) + { + case G_IDL_NODE_TYPE: + { + GIdlNodeType *type = (GIdlNodeType *)node; + SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset]; + + *offset += 4; + + if (type->tag < TYPE_TAG_ARRAY) + { + blob->reserved = 0; + blob->reserved2 = 0; + blob->pointer = type->is_pointer; + blob->reserved3 = 0; + blob->tag = type->tag; + } + else + { + GString *str; + gchar *s; + gpointer value; + + str = g_string_new (0); + serialize_type (module, modules, type, str); + s = g_string_free (str, FALSE); + + types_count += 1; + value = g_hash_table_lookup (types, s); + if (value) + { + blob->offset = GPOINTER_TO_INT (value); + g_free (s); + } + else + { + unique_types_count += 1; + g_hash_table_insert (types, s, GINT_TO_POINTER(*offset2)); + + blob->offset = *offset2; + switch (type->tag) + { + case TYPE_TAG_ARRAY: + { + ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2]; + guint32 pos; + + array->pointer = 1; + array->reserved = 0; + array->tag = type->tag; + array->zero_terminated = type->zero_terminated; + array->has_length = type->has_length; + array->reserved2 = 0; + array->length = type->length; + + pos = *offset2 + 4; + *offset2 += 8; + + g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1, + module, modules, strings, types, + data, &pos, offset2); + } + break; + + case TYPE_TAG_INTERFACE: + { + InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2]; + *offset2 += 4; + + iface->pointer = type->is_pointer; + iface->reserved = 0; + iface->tag = type->tag; + iface->reserved2 = 0; + iface->interface = find_entry (module, modules, type->interface); + + } + break; + + case TYPE_TAG_LIST: + case TYPE_TAG_SLIST: + { + ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; + guint32 pos; + + param->pointer = 1; + param->reserved = 0; + param->tag = type->tag; + param->reserved2 = 0; + param->n_types = 1; + + pos = *offset2 + 4; + *offset2 += 8; + + g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1, + module, modules, strings, types, + data, &pos, offset2); + } + break; + + case TYPE_TAG_HASH: + { + ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; + guint32 pos; + + param->pointer = 1; + param->reserved = 0; + param->tag = type->tag; + param->reserved2 = 0; + param->n_types = 2; + + pos = *offset2 + 4; + *offset2 += 12; + + g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1, + module, modules, strings, types, + data, &pos, offset2); + g_idl_node_build_metadata ((GIdlNode *)type->parameter_type2, + module, modules, strings, types, + data, &pos, offset2); + } + break; + + case TYPE_TAG_ERROR: + { + ErrorTypeBlob *blob = (ErrorTypeBlob *)&data[*offset2]; + gint i, domain; + + blob->pointer = 1; + blob->reserved = 0; + blob->tag = type->tag; + blob->reserved2 = 0; + if (type->errors) + blob->n_domains = g_strv_length (type->errors); + else + blob->n_domains = 0; + + *offset2 = ALIGN_VALUE (*offset2 + 4 + 2 * blob->n_domains, 4); + for (i = 0; i < blob->n_domains; i++) + blob->domains[i] = find_entry (module, modules, type->errors[i]); + } + break; + + default: + g_error ("Unknown type tag %d\n", type->tag); + break; + } + } + } + } + break; + + case G_IDL_NODE_FIELD: + { + GIdlNodeField *field = (GIdlNodeField *)node; + FieldBlob *blob; + + blob = (FieldBlob *)&data[*offset]; + *offset += 8; + + blob->name = write_string (node->name, strings, data, offset2); + blob->readable = field->readable; + blob->writable = field->writable; + blob->reserved = 0; + blob->bits = 0; + blob->struct_offset = field->offset; + + g_idl_node_build_metadata ((GIdlNode *)field->type, + module, modules, strings, types, + data, offset, offset2); + } + break; + + case G_IDL_NODE_PROPERTY: + { + GIdlNodeProperty *prop = (GIdlNodeProperty *)node; + PropertyBlob *blob = (PropertyBlob *)&data[*offset]; + *offset += 8; + + blob->name = write_string (node->name, strings, data, offset2); + blob->deprecated = prop->deprecated; + blob->readable = prop->readable; + blob->writable = prop->writable; + blob->construct = prop->construct; + blob->construct_only = prop->construct_only; + blob->reserved = 0; + + g_idl_node_build_metadata ((GIdlNode *)prop->type, + module, modules, strings, types, + data, offset, offset2); + } + break; + + case G_IDL_NODE_FUNCTION: + { + FunctionBlob *blob = (FunctionBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIdlNodeFunction *function = (GIdlNodeFunction *)node; + guint32 signature, res; + gint n; + + signature = *offset2; + n = g_list_length (function->parameters); + + *offset += 16; + *offset2 += 8 + n * 12; + + blob->blob_type = BLOB_TYPE_FUNCTION; + blob->deprecated = function->deprecated; + blob->setter = function->is_setter; + blob->getter = function->is_getter; + blob->constructor = function->is_constructor; + blob->wraps_vfunc = function->wraps_vfunc; + blob->reserved = 0; + blob->index = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->symbol = write_string (function->symbol, strings, data, offset2); + blob->signature = signature; + + g_idl_node_build_metadata ((GIdlNode *)function->result->type, + module, modules, strings, types, + data, &signature, offset2); + + blob2->may_return_null = function->result->null_ok; + blob2->caller_owns_return_value = function->result->transfer; + blob2->caller_owns_return_container = function->result->shallow_transfer; + blob2->reserved = 0; + blob2->n_arguments = n; + + signature += 4; + + for (l = function->parameters; l; l = l->next) + { + GIdlNode *param = (GIdlNode *)l->data; + + g_idl_node_build_metadata (param, + module, modules, strings, types, + data, &signature, offset2); + } + } + break; + + case G_IDL_NODE_CALLBACK: + { + CallbackBlob *blob = (CallbackBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIdlNodeFunction *function = (GIdlNodeFunction *)node; + guint32 signature, res; + gint n; + + signature = *offset2; + n = g_list_length (function->parameters); + + *offset += 12; + *offset2 += 8 + n * 12; + + blob->blob_type = BLOB_TYPE_CALLBACK; + blob->deprecated = function->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->signature = signature; + + g_idl_node_build_metadata ((GIdlNode *)function->result->type, + module, modules, strings, types, + data, &signature, offset2); + + blob2->may_return_null = function->result->null_ok; + blob2->caller_owns_return_value = function->result->transfer; + blob2->caller_owns_return_container = function->result->shallow_transfer; + blob2->reserved = 0; + blob2->n_arguments = n; + + signature += 4; + + for (l = function->parameters; l; l = l->next) + { + GIdlNode *param = (GIdlNode *)l->data; + + g_idl_node_build_metadata (param, + module, modules, strings, types, + data, &signature, offset2); + } + } + break; + + case G_IDL_NODE_SIGNAL: + { + SignalBlob *blob = (SignalBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIdlNodeSignal *signal = (GIdlNodeSignal *)node; + guint32 signature, res; + gint n; + + signature = *offset2; + n = g_list_length (signal->parameters); + + *offset += 12; + *offset2 += 8 + n * 12; + + blob->deprecated = signal->deprecated; + blob->run_first = signal->run_first; + blob->run_last = signal->run_last; + blob->run_cleanup = signal->run_cleanup; + blob->no_recurse = signal->no_recurse; + blob->detailed = signal->detailed; + blob->action = signal->action; + blob->no_hooks = signal->no_hooks; + blob->has_class_closure = 0; /* FIXME */ + blob->true_stops_emit = 0; /* FIXME */ + blob->reserved = 0; + blob->class_closure = 0; /* FIXME */ + blob->name = write_string (node->name, strings, data, offset2); + blob->signature = signature; + + g_idl_node_build_metadata ((GIdlNode *)signal->result->type, + module, modules, strings, types, + data, &signature, offset2); + + blob2->may_return_null = signal->result->null_ok; + blob2->caller_owns_return_value = signal->result->transfer; + blob2->caller_owns_return_container = signal->result->shallow_transfer; + blob2->reserved = 0; + blob2->n_arguments = n; + + signature += 4; + + for (l = signal->parameters; l; l = l->next) + { + GIdlNode *param = (GIdlNode *)l->data; + + g_idl_node_build_metadata (param, module, modules, strings, types, + data, &signature, offset2); + } + } + break; + + case G_IDL_NODE_VFUNC: + { + VFuncBlob *blob = (VFuncBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node; + guint32 signature, res; + gint n; + + signature = *offset2; + n = g_list_length (vfunc->parameters); + + *offset += 16; + *offset2 += 8 + n * 12; + + blob->name = write_string (node->name, strings, data, offset2); + blob->must_chain_up = 0; /* FIXME */ + blob->must_be_implemented = 0; /* FIXME */ + blob->must_not_be_implemented = 0; /* FIXME */ + blob->class_closure = 0; /* FIXME */ + blob->reserved = 0; + + blob->struct_offset = vfunc->offset; + blob->reserved2 = 0; + blob->signature = signature; + + g_idl_node_build_metadata ((GIdlNode *)vfunc->result->type, + module, modules, strings, types, + data, &signature, offset2); + + blob2->may_return_null = vfunc->result->null_ok; + blob2->caller_owns_return_value = vfunc->result->transfer; + blob2->caller_owns_return_container = vfunc->result->shallow_transfer; + blob2->reserved = 0; + blob2->n_arguments = n; + + signature += 4; + + for (l = vfunc->parameters; l; l = l->next) + { + GIdlNode *param = (GIdlNode *)l->data; + + g_idl_node_build_metadata (param, module, modules, strings, + types, data, &signature, offset2); + } + } + break; + + case G_IDL_NODE_PARAM: + { + ArgBlob *blob = (ArgBlob *)&data[*offset]; + GIdlNodeParam *param = (GIdlNodeParam *)node; + guint32 res; + + *offset += 8; + + blob->name = write_string (node->name, strings, data, offset2); + blob->in = param->in; + blob->out = param->out; + blob->dipper = param->dipper; + blob->null_ok = param->null_ok; + blob->optional = param->optional; + blob->transfer_ownership = param->transfer; + blob->transfer_container_ownership = param->shallow_transfer; + blob->return_value = param->retval; + blob->reserved = 0; + + g_idl_node_build_metadata ((GIdlNode *)param->type, module, modules, + strings, types, data, offset, offset2); + } + break; + + case G_IDL_NODE_STRUCT: + { + StructBlob *blob = (StructBlob *)&data[*offset]; + GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node; + guint32 pos; + + blob->blob_type = BLOB_TYPE_STRUCT; + blob->deprecated = struct_->deprecated; + blob->unregistered = TRUE; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->gtype_name = 0; + blob->gtype_init = 0; + + blob->n_fields = 0; + blob->n_methods = 0; + + *offset += 20; + for (l = struct_->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FIELD) + { + blob->n_fields++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + for (l = struct_->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FUNCTION) + { + blob->n_methods++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + } + break; + + case G_IDL_NODE_BOXED: + { + StructBlob *blob = (StructBlob *)&data[*offset]; + GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node; + + blob->blob_type = BLOB_TYPE_BOXED; + blob->deprecated = boxed->deprecated; + blob->unregistered = FALSE; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->gtype_name = write_string (boxed->gtype_name, strings, data, offset2); + blob->gtype_init = write_string (boxed->gtype_init, strings, data, offset2); + + blob->n_fields = 0; + blob->n_methods = 0; + + *offset += 20; + for (l = boxed->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FIELD) + { + blob->n_fields++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + for (l = boxed->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FUNCTION) + { + blob->n_methods++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + } + break; + + case G_IDL_NODE_UNION: + { + UnionBlob *blob = (UnionBlob *)&data[*offset]; + GIdlNodeUnion *union_ = (GIdlNodeUnion *)node; + + blob->blob_type = BLOB_TYPE_UNION; + blob->deprecated = union_->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + if (union_->gtype_name) + { + blob->unregistered = FALSE; + blob->gtype_name = write_string (union_->gtype_name, strings, data, offset2); + blob->gtype_init = write_string (union_->gtype_init, strings, data, offset2); + } + else + { + blob->unregistered = TRUE; + blob->gtype_name = 0; + blob->gtype_init = 0; + } + + blob->n_fields = 0; + blob->n_functions = 0; + + blob->discriminator_offset = union_->discriminator_offset; + + if (union_->discriminator_type) + { + *offset += 24; + blob->discriminated = TRUE; + g_idl_node_build_metadata ((GIdlNode *)union_->discriminator_type, + module, modules, strings, types, + data, offset, offset2); + } + else + { + *offset += 28; + blob->discriminated = FALSE; + blob->discriminator_type.offset = 0; + } + + + for (l = union_->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FIELD) + { + blob->n_fields++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + for (l = union_->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FUNCTION) + { + blob->n_functions++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + if (union_->discriminator_type) + { + for (l = union_->discriminators; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + } + break; + + case G_IDL_NODE_ENUM: + case G_IDL_NODE_FLAGS: + { + EnumBlob *blob = (EnumBlob *)&data[*offset]; + GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node; + + *offset += 20; + + if (node->type == G_IDL_NODE_ENUM) + blob->blob_type = BLOB_TYPE_ENUM; + else + blob->blob_type = BLOB_TYPE_FLAGS; + + blob->deprecated = enum_->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + if (enum_->gtype_name) + { + blob->unregistered = FALSE; + blob->gtype_name = write_string (enum_->gtype_name, strings, data, offset2); + blob->gtype_init = write_string (enum_->gtype_init, strings, data, offset2); + } + else + { + blob->unregistered = TRUE; + blob->gtype_name = 0; + blob->gtype_init = 0; + } + + blob->n_values = 0; + blob->reserved2 = 0; + + for (l = enum_->values; l; l = l->next) + { + GIdlNode *value = (GIdlNode *)l->data; + + blob->n_values++; + g_idl_node_build_metadata (value, module, modules, strings, types, + data, offset, offset2); + } + } + break; + + case G_IDL_NODE_OBJECT: + { + ObjectBlob *blob = (ObjectBlob *)&data[*offset]; + GIdlNodeInterface *object = (GIdlNodeInterface *)node; + gint parent; + + blob->blob_type = BLOB_TYPE_OBJECT; + blob->deprecated = object->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->gtype_name = write_string (object->gtype_name, strings, data, offset2); + blob->gtype_init = write_string (object->gtype_init, strings, data, offset2); + if (object->parent) + blob->parent = find_entry (module, modules, object->parent); + else + blob->parent = 0; + + blob->n_interfaces = 0; + blob->n_fields = 0; + blob->n_properties = 0; + blob->n_methods = 0; + blob->n_signals = 0; + blob->n_vfuncs = 0; + blob->n_constants = 0; + + *offset += 32; + for (l = object->interfaces; l; l = l->next) + { + blob->n_interfaces++; + *(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data); + *offset += 2; + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FIELD) + { + blob->n_fields++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_PROPERTY) + { + blob->n_properties++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FUNCTION) + { + blob->n_methods++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_SIGNAL) + { + blob->n_signals++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_VFUNC) + { + blob->n_vfuncs++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = object->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_CONSTANT) + { + blob->n_constants++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + } + break; + + case G_IDL_NODE_INTERFACE: + { + InterfaceBlob *blob = (InterfaceBlob *)&data[*offset]; + GIdlNodeInterface *iface = (GIdlNodeInterface *)node; + + blob->blob_type = BLOB_TYPE_INTERFACE; + blob->deprecated = iface->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->gtype_name = write_string (iface->gtype_name, strings, data, offset2); + blob->gtype_init = write_string (iface->gtype_init, strings, data, offset2); + blob->n_prerequisites = 0; + blob->n_properties = 0; + blob->n_methods = 0; + blob->n_signals = 0; + blob->n_vfuncs = 0; + blob->n_constants = 0; + + *offset += 28; + for (l = iface->prerequisites; l; l = l->next) + { + blob->n_prerequisites++; + *(guint16*)&data[*offset] = find_entry (module, modules, (gchar *)l->data); + *offset += 2; + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = iface->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_PROPERTY) + { + blob->n_properties++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = iface->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_FUNCTION) + { + blob->n_methods++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = iface->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_SIGNAL) + { + blob->n_signals++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = iface->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_VFUNC) + { + blob->n_vfuncs++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + + *offset = ALIGN_VALUE (*offset, 4); + for (l = iface->members; l; l = l->next) + { + GIdlNode *member = (GIdlNode *)l->data; + + if (member->type == G_IDL_NODE_CONSTANT) + { + blob->n_constants++; + g_idl_node_build_metadata (member, module, modules, strings, + types, data, offset, offset2); + } + } + } + break; + + + case G_IDL_NODE_VALUE: + { + GIdlNodeValue *value = (GIdlNodeValue *)node; + ValueBlob *blob = (ValueBlob *)&data[*offset]; + *offset += 12; + + blob->deprecated = value->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->value = value->value; + } + break; + + case G_IDL_NODE_ERROR_DOMAIN: + { + GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node; + ErrorDomainBlob *blob = (ErrorDomainBlob *)&data[*offset]; + *offset += 16; + + blob->blob_type = BLOB_TYPE_ERROR_DOMAIN; + blob->deprecated = domain->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + blob->get_quark = write_string (domain->getquark, strings, data, offset2); + blob->error_codes = find_entry (module, modules, domain->codes); + blob->reserved2 = 0; + } + break; + + case G_IDL_NODE_CONSTANT: + { + GIdlNodeConstant *constant = (GIdlNodeConstant *)node; + ConstantBlob *blob = (ConstantBlob *)&data[*offset]; + guint32 pos; + + pos = *offset + 8; + *offset += 20; + + blob->blob_type = BLOB_TYPE_CONSTANT; + blob->deprecated = constant->deprecated; + blob->reserved = 0; + blob->name = write_string (node->name, strings, data, offset2); + + blob->offset = *offset2; + switch (constant->type->tag) + { + case TYPE_TAG_BOOLEAN: + blob->size = 4; + *(gboolean*)&data[blob->offset] = parse_boolean_value (constant->value); + break; + case TYPE_TAG_INT8: + blob->size = 1; + *(gint8*)&data[blob->offset] = (gint8) parse_int_value (constant->value); + break; + case TYPE_TAG_UINT8: + blob->size = 1; + *(guint8*)&data[blob->offset] = (guint8) parse_uint_value (constant->value); + break; + case TYPE_TAG_INT16: + blob->size = 2; + *(gint16*)&data[blob->offset] = (gint16) parse_int_value (constant->value); + break; + case TYPE_TAG_UINT16: + blob->size = 2; + *(guint16*)&data[blob->offset] = (guint16) parse_uint_value (constant->value); + break; + case TYPE_TAG_INT32: + blob->size = 4; + *(gint32*)&data[blob->offset] = (gint32) parse_int_value (constant->value); + break; + case TYPE_TAG_UINT32: + blob->size = 4; + *(guint32*)&data[blob->offset] = (guint32) parse_uint_value (constant->value); + break; + case TYPE_TAG_INT64: + blob->size = 8; + *(gint64*)&data[blob->offset] = (gint64) parse_int_value (constant->value); + break; + case TYPE_TAG_UINT64: + blob->size = 8; + *(guint64*)&data[blob->offset] = (guint64) parse_uint_value (constant->value); + break; + case TYPE_TAG_INT: + blob->size = sizeof (gint); + *(gint*)&data[blob->offset] = (gint) parse_int_value (constant->value); + break; + case TYPE_TAG_UINT: + blob->size = sizeof (guint); + *(gint*)&data[blob->offset] = (guint) parse_uint_value (constant->value); + break; + case TYPE_TAG_SSIZE: /* FIXME */ + case TYPE_TAG_LONG: + blob->size = sizeof (glong); + *(glong*)&data[blob->offset] = (glong) parse_int_value (constant->value); + break; + case TYPE_TAG_SIZE: /* FIXME */ + case TYPE_TAG_ULONG: + blob->size = sizeof (gulong); + *(gulong*)&data[blob->offset] = (gulong) parse_uint_value (constant->value); + break; + case TYPE_TAG_FLOAT: + blob->size = sizeof (gfloat); + *(gfloat*)&data[blob->offset] = (gfloat) parse_float_value (constant->value); + break; + case TYPE_TAG_DOUBLE: + blob->size = sizeof (gdouble); + *(gdouble*)&data[blob->offset] = (gdouble) parse_float_value (constant->value); + break; + case TYPE_TAG_UTF8: + case TYPE_TAG_FILENAME: + blob->size = strlen (constant->value) + 1; + memcpy (&data[blob->offset], constant->value, blob->size); + break; + } + *offset2 += ALIGN_VALUE (blob->size, 4); + + g_idl_node_build_metadata ((GIdlNode *)constant->type, module, modules, + strings, types, data, &pos, offset2); + } + break; + } + + g_debug ("node %p type %d, offset %d -> %d, offset2 %d -> %d", + node, node->type, old_offset, *offset, old_offset2, *offset2); + + if (*offset2 - old_offset2 + *offset - old_offset > g_idl_node_get_full_size (node)) + g_error ("exceeding space reservation !!"); +} + +/* if str is already in the pool, return previous location, otherwise write str + * to the metadata at offset, put it in the pool and update offset. If the + * metadata is not large enough to hold the string, reallocate it. + */ +guint32 +write_string (const gchar *str, + GHashTable *strings, + guchar *data, + guint32 *offset) +{ + gpointer value; + guint32 start; + + string_count += 1; + string_size += strlen (str); + + value = g_hash_table_lookup (strings, str); + + if (value) + return GPOINTER_TO_INT (value); + + unique_string_count += 1; + unique_string_size += strlen (str); + + g_hash_table_insert (strings, (gpointer)str, GINT_TO_POINTER (*offset)); + + start = *offset; + *offset = ALIGN_VALUE (start + strlen (str) + 1, 4); + + strcpy ((gchar*)&data[start], str); + + return start; +} + diff --git a/vapigen/gobject-introspection/gidlnode.h b/vapigen/gobject-introspection/gidlnode.h new file mode 100644 index 000000000..7b6f1568c --- /dev/null +++ b/vapigen/gobject-introspection/gidlnode.h @@ -0,0 +1,331 @@ +/* GObject introspection: Parsed IDL + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#ifndef __G_IDL_NODE_H__ +#define __G_IDL_NODE_H__ + +#include + +G_BEGIN_DECLS + +typedef struct _GIdlNode GIdlNode; +typedef struct _GIdlNodeFunction GIdlNodeFunction; +typedef struct _GIdlNodeParam GIdlNodeParam; +typedef struct _GIdlNodeType GIdlNodeType; +typedef struct _GIdlNodeInterface GIdlNodeInterface; +typedef struct _GIdlNodeSignal GIdlNodeSignal; +typedef struct _GIdlNodeProperty GIdlNodeProperty; +typedef struct _GIdlNodeVFunc GIdlNodeVFunc; +typedef struct _GIdlNodeField GIdlNodeField; +typedef struct _GIdlNodeValue GIdlNodeValue; +typedef struct _GIdlNodeEnum GIdlNodeEnum; +typedef struct _GIdlNodeBoxed GIdlNodeBoxed; +typedef struct _GIdlNodeStruct GIdlNodeStruct; +typedef struct _GIdlNodeConstant GIdlNodeConstant; +typedef struct _GIdlNodeErrorDomain GIdlNodeErrorDomain; +typedef struct _GIdlNodeXRef GIdlNodeXRef; +typedef struct _GIdlNodeUnion GIdlNodeUnion; + +typedef enum +{ + G_IDL_NODE_INVALID, + G_IDL_NODE_FUNCTION, + G_IDL_NODE_CALLBACK, + G_IDL_NODE_STRUCT, + G_IDL_NODE_BOXED, + G_IDL_NODE_ENUM, + G_IDL_NODE_FLAGS, + G_IDL_NODE_OBJECT, + G_IDL_NODE_INTERFACE, + G_IDL_NODE_CONSTANT, + G_IDL_NODE_ERROR_DOMAIN, + G_IDL_NODE_UNION, + G_IDL_NODE_PARAM, + G_IDL_NODE_TYPE, + G_IDL_NODE_PROPERTY, + G_IDL_NODE_SIGNAL, + G_IDL_NODE_VALUE, + G_IDL_NODE_VFUNC, + G_IDL_NODE_FIELD, + G_IDL_NODE_XREF +} GIdlNodeTypeId; + +struct _GIdlNode +{ + GIdlNodeTypeId type; + gchar *name; +}; + +struct _GIdlNodeXRef +{ + GIdlNode node; + + gchar *namespace; +}; + +struct _GIdlNodeFunction +{ + GIdlNode node; + + gboolean deprecated; + + gboolean is_method; + gboolean is_setter; + gboolean is_getter; + gboolean is_constructor; + gboolean wraps_vfunc; + + gchar *symbol; + + GIdlNodeParam *result; + GList *parameters; +}; + +struct _GIdlNodeType +{ + GIdlNode node; + + gboolean is_pointer; + gboolean is_basic; + gboolean is_array; + gboolean is_glist; + gboolean is_gslist; + gboolean is_ghashtable; + gboolean is_interface; + gboolean is_error; + gint tag; + + gchar *unparsed; + + gboolean zero_terminated; + gboolean has_length; + gint length; + + GIdlNodeType *parameter_type1; + GIdlNodeType *parameter_type2; + + gchar *interface; + gchar **errors; +}; + +struct _GIdlNodeParam +{ + GIdlNode node; + + gboolean in; + gboolean out; + gboolean dipper; + gboolean optional; + gboolean retval; + gboolean null_ok; + gboolean transfer; + gboolean shallow_transfer; + + GIdlNodeType *type; +}; + +struct _GIdlNodeProperty +{ + GIdlNode node; + + gboolean deprecated; + + gchar *name; + gboolean readable; + gboolean writable; + gboolean construct; + gboolean construct_only; + + GIdlNodeType *type; +}; + +struct _GIdlNodeSignal +{ + GIdlNode node; + + gboolean deprecated; + + gboolean run_first; + gboolean run_last; + gboolean run_cleanup; + gboolean no_recurse; + gboolean detailed; + gboolean action; + gboolean no_hooks; + + gboolean has_class_closure; + gboolean true_stops_emit; + + gint class_closure; + + GList *parameters; + GIdlNodeParam *result; +}; + +struct _GIdlNodeVFunc +{ + GIdlNode node; + + gboolean must_chain_up; + gboolean must_be_implemented; + gboolean must_not_be_implemented; + gboolean is_class_closure; + + GList *parameters; + GIdlNodeParam *result; + + gint offset; +}; + +struct _GIdlNodeField +{ + GIdlNode node; + + gboolean readable; + gboolean writable; + gint bits; + gint offset; + + GIdlNodeType *type; +}; + +struct _GIdlNodeInterface +{ + GIdlNode node; + + gboolean deprecated; + + gchar *gtype_name; + gchar *gtype_init; + + gchar *parent; + + GList *interfaces; + GList *prerequisites; + + GList *members; +}; + +struct _GIdlNodeValue +{ + GIdlNode node; + + gboolean deprecated; + + guint32 value; +}; + +struct _GIdlNodeConstant +{ + GIdlNode node; + + gboolean deprecated; + + GIdlNodeType *type; + + gchar *value; +}; + +struct _GIdlNodeEnum +{ + GIdlNode node; + + gboolean deprecated; + + gchar *gtype_name; + gchar *gtype_init; + + GList *values; +}; + +struct _GIdlNodeBoxed +{ + GIdlNode node; + + gboolean deprecated; + + gchar *gtype_name; + gchar *gtype_init; + + GList *members; +}; + +struct _GIdlNodeStruct +{ + GIdlNode node; + + gboolean deprecated; + + GList *members; +}; + +struct _GIdlNodeUnion +{ + GIdlNode node; + + gboolean deprecated; + + GList *members; + GList *discriminators; + + gchar *gtype_name; + gchar *gtype_init; + + gint discriminator_offset; + GIdlNodeType *discriminator_type; +}; + + +struct _GIdlNodeErrorDomain +{ + GIdlNode node; + + gboolean deprecated; + + gchar *name; + gchar *getquark; + gchar *codes; +}; + + +GIdlNode *g_idl_node_new (GIdlNodeTypeId type); +void g_idl_node_free (GIdlNode *node); +guint32 g_idl_node_get_size (GIdlNode *node); +guint32 g_idl_node_get_full_size (GIdlNode *node); +void g_idl_node_build_metadata (GIdlNode *node, + GIdlModule *module, + GList *modules, + GHashTable *strings, + GHashTable *types, + guchar *data, + guint32 *offset, + guint32 *offset2); + +guint32 write_string (const gchar *str, + GHashTable *strings, + guchar *data, + guint32 *offset); + +void init_stats (void); +void dump_stats (void); + +G_END_DECLS + +#endif /* __G_IDL_NODE_H__ */ diff --git a/vapigen/gobject-introspection/gidlparser.c b/vapigen/gobject-introspection/gidlparser.c new file mode 100644 index 000000000..b774bb984 --- /dev/null +++ b/vapigen/gobject-introspection/gidlparser.c @@ -0,0 +1,2036 @@ +/* GObject introspection: A parser for the XML IDL format + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ +#include + +#include +#include "gidlmodule.h" +#include "gidlnode.h" +#include "gmetadata.h" + +typedef enum +{ + STATE_START, + STATE_END, + STATE_ROOT, + STATE_NAMESPACE, + STATE_FUNCTION, + STATE_PARAMETERS, + STATE_OBJECT, + STATE_INTERFACE, + STATE_IMPLEMENTS, + STATE_REQUIRES, + STATE_ENUM, + STATE_BOXED, + STATE_STRUCT, + STATE_SIGNAL, + STATE_ERRORDOMAIN, + STATE_UNION +} ParseState; + +typedef struct _ParseContext ParseContext; +struct _ParseContext +{ + ParseState state; + ParseState prev_state; + + GList *modules; + + GIdlModule *current_module; + GIdlNode *current_node; +}; + +#define MISSING_ATTRIBUTE(error,element,attribute) \ + g_set_error (error, \ + G_MARKUP_ERROR, \ + G_MARKUP_ERROR_INVALID_CONTENT, \ + "The attribute '%s' on the element '%s' must be specified", \ + attribute, element) + +static const gchar * +find_attribute (const gchar *name, + const gchar **attribute_names, + const gchar **attribute_values) +{ + gint i; + + for (i = 0; attribute_names[i] != NULL; i++) + if (strcmp (attribute_names[i], name) == 0) + return attribute_values[i]; + + return 0; +} + +static GIdlNodeType * +parse_type_internal (gchar *str, gchar **rest) +{ + gint i; + + static struct { + const gchar *str; + gint tag; + gboolean pointer; + } basic[] = { + { "void", TYPE_TAG_VOID, 0 }, + { "gpointer", TYPE_TAG_VOID, 1 }, + { "gboolean", TYPE_TAG_BOOLEAN, 0 }, + { "int8_t", TYPE_TAG_INT8, 0 }, + { "int8", TYPE_TAG_INT8, 0 }, + { "gint8", TYPE_TAG_INT8, 0 }, + { "uint8_t", TYPE_TAG_UINT8, 0 }, + { "uint8", TYPE_TAG_UINT8, 0 }, + { "guint8", TYPE_TAG_UINT8, 0 }, + { "int16_t", TYPE_TAG_INT16, 0 }, + { "int16", TYPE_TAG_INT16, 0 }, + { "gint16", TYPE_TAG_INT16, 0 }, + { "uint16_t", TYPE_TAG_UINT16, 0 }, + { "uint16", TYPE_TAG_UINT16, 0 }, + { "guint16", TYPE_TAG_UINT16, 0 }, + { "int32_t", TYPE_TAG_INT32, 0 }, + { "int32", TYPE_TAG_INT32, 0 }, + { "gint32", TYPE_TAG_INT32, 0 }, + { "uint32_t", TYPE_TAG_UINT32, 0 }, + { "uint32", TYPE_TAG_UINT32, 0 }, + { "guint32", TYPE_TAG_UINT32, 0 }, + { "int64_t", TYPE_TAG_INT64, 0 }, + { "int64", TYPE_TAG_INT64, 0 }, + { "gint64", TYPE_TAG_INT64, 0 }, + { "uint64_t", TYPE_TAG_UINT64, 0 }, + { "uint64", TYPE_TAG_UINT64, 0 }, + { "guint64", TYPE_TAG_UINT64, 0 }, + { "int", TYPE_TAG_INT, 0 }, + { "gint", TYPE_TAG_INT, 0 }, + { "uint", TYPE_TAG_UINT, 0 }, + { "guint", TYPE_TAG_UINT, 0 }, + { "long", TYPE_TAG_LONG, 0 }, + { "glong", TYPE_TAG_LONG, 0 }, + { "ulong", TYPE_TAG_ULONG, 0 }, + { "gulong", TYPE_TAG_ULONG, 0 }, + { "ssize_t", TYPE_TAG_SSIZE, 0 }, + { "gssize", TYPE_TAG_SSIZE, 0 }, + { "size_t", TYPE_TAG_SIZE, 0 }, + { "gsize", TYPE_TAG_SIZE, 0 }, + { "float", TYPE_TAG_FLOAT, 0 }, + { "gfloat", TYPE_TAG_FLOAT, 0 }, + { "double", TYPE_TAG_DOUBLE, 0 }, + { "gdouble", TYPE_TAG_DOUBLE, 0 }, + { "utf8", TYPE_TAG_UTF8, 1 }, + { "gchar*", TYPE_TAG_UTF8, 1 }, + { "filename", TYPE_TAG_FILENAME,1 } + }; + + gint n_basic = G_N_ELEMENTS (basic); + gchar *start, *end; + + GIdlNodeType *type; + + type = (GIdlNodeType *)g_idl_node_new (G_IDL_NODE_TYPE); + + str = g_strstrip (str); + + type->unparsed = g_strdup (str); + + *rest = str; + for (i = 0; i < n_basic; i++) + { + if (g_str_has_prefix (*rest, basic[i].str)) + { + type->is_basic = TRUE; + type->tag = basic[i].tag; + type->is_pointer = basic[i].pointer; + + *rest += strlen(basic[i].str); + *rest = g_strchug (*rest); + if (**rest == '*' && !type->is_pointer) + { + type->is_pointer = TRUE; + (*rest)++; + } + + break; + } + } + + if (i < n_basic) + /* found a basic type */; + else if (g_str_has_prefix (*rest, "GList") || + g_str_has_prefix (*rest, "GSList")) + { + if (g_str_has_prefix (*rest, "GList")) + { + type->tag = TYPE_TAG_LIST; + type->is_glist = TRUE; + type->is_pointer = TRUE; + *rest += strlen ("GList"); + } + else + { + type->tag = TYPE_TAG_SLIST; + type->is_gslist = TRUE; + type->is_pointer = TRUE; + *rest += strlen ("GSList"); + } + + *rest = g_strchug (*rest); + + if (**rest == '<') + { + (*rest)++; + + type->parameter_type1 = parse_type_internal (*rest, rest); + if (type->parameter_type1 == NULL) + goto error; + + *rest = g_strchug (*rest); + + if ((*rest)[0] != '>') + goto error; + (*rest)++; + } + } + else if (g_str_has_prefix (*rest, "GHashTable")) + { + type->tag = TYPE_TAG_HASH; + type->is_ghashtable = TRUE; + type->is_pointer = TRUE; + *rest += strlen ("GHashTable"); + + *rest = g_strchug (*rest); + + if (**rest == '<') + { + (*rest)++; + + type->parameter_type1 = parse_type_internal (*rest, rest); + if (type->parameter_type1 == NULL) + goto error; + + *rest = g_strchug (*rest); + + if ((*rest)[0] != ',') + goto error; + (*rest)++; + + type->parameter_type2 = parse_type_internal (*rest, rest); + if (type->parameter_type2 == NULL) + goto error; + + if ((*rest)[0] != '>') + goto error; + (*rest)++; + } + } + else if (g_str_has_prefix (*rest, "GError")) + { + type->tag = TYPE_TAG_ERROR; + type->is_error = TRUE; + type->is_pointer = TRUE; + *rest += strlen ("GError"); + + *rest = g_strchug (*rest); + + if (**rest == '<') + { + (*rest)++; + + end = strchr (*rest, '>'); + str = g_strndup (*rest, end - *rest); + type->errors = g_strsplit (str, ",", 0); + g_free (str); + + *rest = end + 1; + } + } + else + { + type->tag = TYPE_TAG_INTERFACE; + type->is_interface = TRUE; + start = *rest; + + /* must be an interface type */ + while (g_ascii_isalnum (**rest) || + **rest == '.' || + **rest == '-' || + **rest == '_' || + **rest == ':') + (*rest)++; + + type->interface = g_strndup (start, *rest - start); + + *rest = g_strchug (*rest); + if (**rest == '*') + { + type->is_pointer = TRUE; + (*rest)++; + } + } + + *rest = g_strchug (*rest); + if (g_str_has_prefix (*rest, "[")) + { + GIdlNodeType *array; + + array = (GIdlNodeType *)g_idl_node_new (G_IDL_NODE_TYPE); + + array->tag = TYPE_TAG_ARRAY; + array->is_pointer = TRUE; + array->is_array = TRUE; + + array->parameter_type1 = type; + + array->zero_terminated = FALSE; + array->has_length = FALSE; + array->length = 0; + + if (!g_str_has_prefix (*rest, "[]")) + { + gchar *end, *str, **opts; + + end = strchr (*rest, ']'); + str = g_strndup (*rest + 1, (end - *rest) - 1); + opts = g_strsplit (str, ",", 0); + + *rest = end + 1; + + for (i = 0; opts[i]; i++) + { + gchar **vals; + + vals = g_strsplit (opts[i], "=", 0); + + if (strcmp (vals[0], "zero-terminated") == 0) + array->zero_terminated = (strcmp (vals[1], "1") == 0); + else if (strcmp (vals[0], "length") == 0) + { + array->has_length = TRUE; + array->length = atoi (vals[1]); + } + + g_strfreev (vals); + } + + g_free (str); + g_strfreev (opts); + } + + type = array; + } + + return type; + + error: + g_idl_node_free ((GIdlNode *)type); + + return NULL; +} + +static GIdlNodeType * +parse_type (const gchar *type) +{ + gchar *str; + gchar *rest; + GIdlNodeType *node; + + str = g_strdup (type); + node = parse_type_internal (str, &rest); + g_free (str); + + return node; +} + +static gboolean +start_boxed (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "boxed") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *typename; + const gchar *typeinit; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + typename = find_attribute ("type-name", attribute_names, attribute_values); + typeinit = find_attribute ("get-type", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (typename == NULL) + MISSING_ATTRIBUTE (error, element_name, "type-name"); + else if (typeinit == NULL) + MISSING_ATTRIBUTE (error, element_name, "get-type"); + else + { + GIdlNodeBoxed *boxed; + + boxed = (GIdlNodeBoxed *) g_idl_node_new (G_IDL_NODE_BOXED); + + ((GIdlNode *)boxed)->name = g_strdup (name); + boxed->gtype_name = g_strdup (typename); + boxed->gtype_init = g_strdup (typeinit); + if (deprecated && strcmp (deprecated, "1") == 0) + boxed->deprecated = TRUE; + else + boxed->deprecated = FALSE; + + ctx->current_node = (GIdlNode *)boxed; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, boxed); + + ctx->state = STATE_BOXED; + } + + return TRUE; + } + + return FALSE; +} + +static gboolean +start_function (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if ((ctx->state == STATE_NAMESPACE && + (strcmp (element_name, "function") == 0 || + strcmp (element_name, "callback") == 0)) || + ((ctx->state == STATE_OBJECT || + ctx->state == STATE_INTERFACE || + ctx->state == STATE_BOXED || + ctx->state == STATE_STRUCT || + ctx->state == STATE_UNION) && + strcmp (element_name, "method") == 0) || + ((ctx->state == STATE_OBJECT || + ctx->state == STATE_BOXED) && + strcmp (element_name, "constructor") == 0)) + { + const gchar *name; + const gchar *symbol; + const gchar *deprecated; + const gchar *type; + + name = find_attribute ("name", attribute_names, attribute_values); + symbol = find_attribute ("symbol", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + type = find_attribute ("type", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (strcmp (element_name, "callback") != 0 && symbol == NULL) + MISSING_ATTRIBUTE (error, element_name, "symbol"); + else + { + GIdlNodeFunction *function; + + function = (GIdlNodeFunction *) g_idl_node_new (G_IDL_NODE_FUNCTION); + + ((GIdlNode *)function)->name = g_strdup (name); + function->symbol = g_strdup (symbol); + function->parameters = NULL; + if (deprecated && strcmp (deprecated, "1") == 0) + function->deprecated = TRUE; + else + function->deprecated = FALSE; + + if (strcmp (element_name, "method") == 0 || + strcmp (element_name, "constructor") == 0) + { + function->is_method = TRUE; + + if (type && strcmp (type, "setter") == 0) + function->is_setter = TRUE; + else if (type && strcmp (type, "getter") == 0) + function->is_getter = TRUE; + + if (strcmp (element_name, "constructor") == 0) + function->is_constructor = TRUE; + else + function->is_constructor = FALSE; + } + else + { + function->is_method = FALSE; + function->is_setter = FALSE; + function->is_getter = FALSE; + function->is_constructor = FALSE; + if (strcmp (element_name, "callback") == 0) + ((GIdlNode *)function)->type = G_IDL_NODE_CALLBACK; + } + + if (ctx->current_node == NULL) + { + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, function); + } + else + switch (ctx->current_node->type) + { + case G_IDL_NODE_INTERFACE: + case G_IDL_NODE_OBJECT: + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, function); + } + break; + case G_IDL_NODE_BOXED: + { + GIdlNodeBoxed *boxed; + + boxed = (GIdlNodeBoxed *)ctx->current_node; + boxed->members = g_list_append (boxed->members, function); + } + break; + case G_IDL_NODE_STRUCT: + { + GIdlNodeStruct *struct_; + + struct_ = (GIdlNodeStruct *)ctx->current_node; + struct_->members = g_list_append (struct_->members, function); } + break; + case G_IDL_NODE_UNION: + { + GIdlNodeUnion *union_; + + union_ = (GIdlNodeUnion *)ctx->current_node; + union_->members = g_list_append (union_->members, function); + } + break; + } + + ctx->current_node = (GIdlNode *)function; + ctx->state = STATE_FUNCTION; + + return TRUE; + } + } + + return FALSE; +} + +static gboolean +start_parameter (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "parameter") == 0 && + ctx->state == STATE_PARAMETERS) + { + const gchar *type; + const gchar *name; + const gchar *direction; + const gchar *retval; + const gchar *dipper; + const gchar *optional; + const gchar *nullok; + const gchar *transfer; + + type = find_attribute ("type", attribute_names, attribute_values); + name = find_attribute ("name", attribute_names, attribute_values); + direction = find_attribute ("direction", attribute_names, attribute_values); + retval = find_attribute ("retval", attribute_names, attribute_values); + dipper = find_attribute ("dipper", attribute_names, attribute_values); + optional = find_attribute ("optional", attribute_names, attribute_values); + nullok = find_attribute ("null-ok", attribute_names, attribute_values); + transfer = find_attribute ("transfer", attribute_names, attribute_values); + + if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeParam *param; + + param = (GIdlNodeParam *)g_idl_node_new (G_IDL_NODE_PARAM); + + if (direction && strcmp (direction, "out") == 0) + { + param->in = FALSE; + param->out = TRUE; + } + else if (direction && strcmp (direction, "inout") == 0) + { + param->in = TRUE; + param->out = TRUE; + } + else + { + param->in = TRUE; + param->out = FALSE; + } + + if (retval && strcmp (retval, "1") == 0) + param->retval = TRUE; + else + param->retval = FALSE; + + if (dipper && strcmp (dipper, "1") == 0) + param->dipper = TRUE; + else + param->dipper = FALSE; + + if (optional && strcmp (optional, "1") == 0) + param->optional = TRUE; + else + param->optional = FALSE; + + if (nullok && strcmp (nullok, "1") == 0) + param->null_ok = TRUE; + else + param->null_ok = FALSE; + + if (transfer && strcmp (transfer, "none") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = FALSE; + } + else if (transfer && strcmp (transfer, "shallow") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = TRUE; + } + else + { + param->transfer = TRUE; + param->shallow_transfer = FALSE; + } + + ((GIdlNode *)param)->name = g_strdup (name); + param->type = parse_type (type); + + switch (ctx->current_node->type) + { + case G_IDL_NODE_FUNCTION: + case G_IDL_NODE_CALLBACK: + { + GIdlNodeFunction *func; + + func = (GIdlNodeFunction *)ctx->current_node; + func->parameters = g_list_append (func->parameters, param); + } + break; + case G_IDL_NODE_SIGNAL: + { + GIdlNodeSignal *signal; + + signal = (GIdlNodeSignal *)ctx->current_node; + signal->parameters = g_list_append (signal->parameters, param); + } + break; + case G_IDL_NODE_VFUNC: + { + GIdlNodeVFunc *vfunc; + + vfunc = (GIdlNodeVFunc *)ctx->current_node; + vfunc->parameters = g_list_append (vfunc->parameters, param); + } + break; + } + } + + return TRUE; + } + + return FALSE; +} + +static gboolean +start_field (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "field") == 0 && + (ctx->state == STATE_OBJECT || + ctx->state == STATE_BOXED || + ctx->state == STATE_STRUCT || + ctx->state == STATE_UNION)) + { + const gchar *name; + const gchar *type; + const gchar *readable; + const gchar *writable; + const gchar *bits; + const gchar *branch; + const gchar *offset; + + name = find_attribute ("name", attribute_names, attribute_values); + type = find_attribute ("type", attribute_names, attribute_values); + readable = find_attribute ("readable", attribute_names, attribute_values); + writable = find_attribute ("writable", attribute_names, attribute_values); + bits = find_attribute ("bits", attribute_names, attribute_values); + branch = find_attribute ("branch", attribute_names, attribute_values); + offset = find_attribute ("offset", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else + { + GIdlNodeField *field; + + field = (GIdlNodeField *)g_idl_node_new (G_IDL_NODE_FIELD); + ((GIdlNode *)field)->name = g_strdup (name); + if (readable && strcmp (readable, "1") == 0) + field->readable = TRUE; + else + field->readable = FALSE; + + if (writable && strcmp (writable, "1") == 0) + field->writable = TRUE; + else + field->writable = FALSE; + + if (bits) + field->bits = atoi (bits); + else + field->bits = 0; + + if (offset) + field->offset = atoi (offset); + else + field->offset = 0; + + field->type = parse_type (type); + + switch (ctx->current_node->type) + { + case G_IDL_NODE_OBJECT: + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, field); + } + break; + case G_IDL_NODE_BOXED: + { + GIdlNodeBoxed *boxed; + + boxed = (GIdlNodeBoxed *)ctx->current_node; + boxed->members = g_list_append (boxed->members, field); + } + break; + case G_IDL_NODE_STRUCT: + { + GIdlNodeStruct *struct_; + + struct_ = (GIdlNodeStruct *)ctx->current_node; + struct_->members = g_list_append (struct_->members, field); + } + break; + case G_IDL_NODE_UNION: + { + GIdlNodeUnion *union_; + + union_ = (GIdlNodeUnion *)ctx->current_node; + union_->members = g_list_append (union_->members, field); + if (branch) + { + GIdlNodeConstant *constant; + + constant = (GIdlNodeConstant *) g_idl_node_new (G_IDL_NODE_CONSTANT); + ((GIdlNode *)constant)->name = g_strdup (name); + constant->value = g_strdup (branch); + constant->type = union_->discriminator_type; + constant->deprecated = FALSE; + + union_->discriminators = g_list_append (union_->discriminators, constant); + } + } + break; + } + } + return TRUE; + } + + return FALSE; +} + +static gboolean +start_enum (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if ((strcmp (element_name, "enum") == 0 && ctx->state == STATE_NAMESPACE) || + (strcmp (element_name, "flags") == 0 && ctx->state == STATE_NAMESPACE)) + { + const gchar *name; + const gchar *typename; + const gchar *typeinit; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + typename = find_attribute ("type-name", attribute_names, attribute_values); + typeinit = find_attribute ("get-type", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeEnum *enum_; + + if (strcmp (element_name, "enum") == 0) + enum_ = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_ENUM); + else + enum_ = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_FLAGS); + ((GIdlNode *)enum_)->name = g_strdup (name); + enum_->gtype_name = g_strdup (typename); + enum_->gtype_init = g_strdup (typeinit); + if (deprecated && strcmp (deprecated, "1") == 0) + enum_->deprecated = TRUE; + else + enum_->deprecated = FALSE; + + ctx->current_node = (GIdlNode *) enum_; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, enum_); + + ctx->state = STATE_ENUM; + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_property (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "property") == 0 && + (ctx->state == STATE_OBJECT || + ctx->state == STATE_INTERFACE)) + { + const gchar *name; + const gchar *type; + const gchar *readable; + const gchar *writable; + const gchar *construct; + const gchar *construct_only; + + name = find_attribute ("name", attribute_names, attribute_values); + type = find_attribute ("type", attribute_names, attribute_values); + readable = find_attribute ("readable", attribute_names, attribute_values); + writable = find_attribute ("writable", attribute_names, attribute_values); + construct = find_attribute ("construct", attribute_names, attribute_values); + construct_only = find_attribute ("construct-only", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else + { + GIdlNodeProperty *property; + GIdlNodeInterface *iface; + + property = (GIdlNodeProperty *) g_idl_node_new (G_IDL_NODE_PROPERTY); + + ((GIdlNode *)property)->name = g_strdup (name); + + if (readable && strcmp (readable, "1") == 0) + property->readable = TRUE; + else + property->readable = FALSE; + if (writable && strcmp (writable, "1") == 0) + property->writable = TRUE; + else + property->writable = FALSE; + if (construct && strcmp (construct, "1") == 0) + property->construct = TRUE; + else + property->construct = FALSE; + if (construct_only && strcmp (construct_only, "1") == 0) + property->construct_only = TRUE; + else + property->construct_only = FALSE; + + property->type = parse_type (type); + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, property); + } + + return TRUE; + } + return FALSE; +} + +static gint +parse_value (const gchar *str) +{ + gchar *shift_op; + + /* FIXME just a quick hack */ + shift_op = strstr (str, "<<"); + + if (shift_op) + { + gint base, shift; + + base = strtol (str, NULL, 10); + shift = strtol (shift_op + 3, NULL, 10); + + return base << shift; + } + else + return strtol (str, NULL, 10); + + return 0; +} + +static gboolean +start_member (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "member") == 0 && + ctx->state == STATE_ENUM) + { + const gchar *name; + const gchar *value; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + value = find_attribute ("value", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeEnum *enum_; + GIdlNodeValue *value_; + + value_ = (GIdlNodeValue *) g_idl_node_new (G_IDL_NODE_VALUE); + + ((GIdlNode *)value_)->name = g_strdup (name); + + value_->value = parse_value (value); + + if (deprecated && strcmp (deprecated, "1") == 0) + value_->deprecated = TRUE; + else + value_->deprecated = FALSE; + + enum_ = (GIdlNodeEnum *)ctx->current_node; + enum_->values = g_list_append (enum_->values, value_); + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_constant (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "constant") == 0 && + (ctx->state == STATE_NAMESPACE || + ctx->state == STATE_OBJECT || + ctx->state == STATE_INTERFACE)) + { + const gchar *name; + const gchar *type; + const gchar *value; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + type = find_attribute ("type", attribute_names, attribute_values); + value = find_attribute ("value", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else if (value == NULL) + MISSING_ATTRIBUTE (error, element_name, "value"); + else + { + GIdlNodeConstant *constant; + + constant = (GIdlNodeConstant *) g_idl_node_new (G_IDL_NODE_CONSTANT); + + ((GIdlNode *)constant)->name = g_strdup (name); + constant->value = g_strdup (value); + + constant->type = parse_type (type); + + if (deprecated && strcmp (deprecated, "1") == 0) + constant->deprecated = TRUE; + else + constant->deprecated = FALSE; + + if (ctx->state == STATE_NAMESPACE) + { + ctx->current_node = (GIdlNode *) constant; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, constant); + } + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, constant); + } + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_errordomain (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "errordomain") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *getquark; + const gchar *codes; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + getquark = find_attribute ("get-quark", attribute_names, attribute_values); + codes = find_attribute ("codes", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (getquark == NULL) + MISSING_ATTRIBUTE (error, element_name, "getquark"); + else if (codes == NULL) + MISSING_ATTRIBUTE (error, element_name, "codes"); + else + { + GIdlNodeErrorDomain *domain; + + domain = (GIdlNodeErrorDomain *) g_idl_node_new (G_IDL_NODE_ERROR_DOMAIN); + + ((GIdlNode *)domain)->name = g_strdup (name); + domain->getquark = g_strdup (getquark); + domain->codes = g_strdup (codes); + + if (deprecated && strcmp (deprecated, "1") == 0) + domain->deprecated = TRUE; + else + domain->deprecated = FALSE; + + ctx->current_node = (GIdlNode *) domain; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, domain); + + ctx->state = STATE_ERRORDOMAIN; + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_interface (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "interface") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *typename; + const gchar *typeinit; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + typename = find_attribute ("type-name", attribute_names, attribute_values); + typeinit = find_attribute ("get-type", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (typename == NULL) + MISSING_ATTRIBUTE (error, element_name, "type-name"); + else if (typeinit == NULL) + MISSING_ATTRIBUTE (error, element_name, "get-type"); + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_INTERFACE); + ((GIdlNode *)iface)->name = g_strdup (name); + iface->gtype_name = g_strdup (typename); + iface->gtype_init = g_strdup (typeinit); + if (deprecated && strcmp (deprecated, "1") == 0) + iface->deprecated = TRUE; + else + iface->deprecated = FALSE; + + ctx->current_node = (GIdlNode *) iface; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, iface); + + ctx->state = STATE_INTERFACE; + + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_object (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "object") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *parent; + const gchar *typename; + const gchar *typeinit; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + parent = find_attribute ("parent", attribute_names, attribute_values); + typename = find_attribute ("type-name", attribute_names, attribute_values); + typeinit = find_attribute ("get-type", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (typename == NULL) + MISSING_ATTRIBUTE (error, element_name, "type-name"); + else if (typeinit == NULL) + MISSING_ATTRIBUTE (error, element_name, "get-type"); + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_OBJECT); + ((GIdlNode *)iface)->name = g_strdup (name); + iface->gtype_name = g_strdup (typename); + iface->gtype_init = g_strdup (typeinit); + iface->parent = g_strdup (parent); + if (deprecated && strcmp (deprecated, "1") == 0) + iface->deprecated = TRUE; + else + iface->deprecated = FALSE; + + ctx->current_node = (GIdlNode *) iface; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, iface); + + ctx->state = STATE_OBJECT; + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_return_type (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "return-type") == 0 && + ctx->state == STATE_FUNCTION) + { + const gchar *type; + const gchar *nullok; + const gchar *transfer; + + type = find_attribute ("type", attribute_names, attribute_values); + nullok = find_attribute ("null-ok", attribute_names, attribute_values); + transfer = find_attribute ("transfer", attribute_names, attribute_values); + if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else + { + GIdlNodeParam *param; + + param = (GIdlNodeParam *)g_idl_node_new (G_IDL_NODE_PARAM); + param->in = FALSE; + param->out = FALSE; + param->retval = TRUE; + if (nullok && strcmp (nullok, "1") == 0) + param->null_ok = TRUE; + else + param->null_ok = FALSE; + if (transfer && strcmp (transfer, "none") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = FALSE; + } + else if (transfer && strcmp (transfer, "shallow") == 0) + { + param->transfer = FALSE; + param->shallow_transfer = TRUE; + } + else + { + param->transfer = TRUE; + param->shallow_transfer = FALSE; + } + + param->type = parse_type (type); + + switch (ctx->current_node->type) + { + case G_IDL_NODE_FUNCTION: + case G_IDL_NODE_CALLBACK: + { + GIdlNodeFunction *func = (GIdlNodeFunction *)ctx->current_node; + func->result = param; + } + break; + case G_IDL_NODE_SIGNAL: + { + GIdlNodeSignal *signal = (GIdlNodeSignal *)ctx->current_node; + signal->result = param; + } + break; + case G_IDL_NODE_VFUNC: + { + GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)ctx->current_node; + vfunc->result = param; + } + break; + } + } + + return TRUE; + } + + return FALSE; +} + +static gboolean +start_signal (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "signal") == 0 && + (ctx->state == STATE_OBJECT || + ctx->state == STATE_INTERFACE)) + { + const gchar *name; + const gchar *when; + const gchar *no_recurse; + const gchar *detailed; + const gchar *action; + const gchar *no_hooks; + const gchar *has_class_closure; + + name = find_attribute ("name", attribute_names, attribute_values); + when = find_attribute ("when", attribute_names, attribute_values); + no_recurse = find_attribute ("no-recurse", attribute_names, attribute_values); + detailed = find_attribute ("detailed", attribute_names, attribute_values); + action = find_attribute ("action", attribute_names, attribute_values); + no_hooks = find_attribute ("no-hooks", attribute_names, attribute_values); + has_class_closure = find_attribute ("has-class-closure", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else if (when == NULL) + MISSING_ATTRIBUTE (error, element_name, "when"); + else + { + GIdlNodeInterface *iface; + GIdlNodeSignal *signal; + + signal = (GIdlNodeSignal *)g_idl_node_new (G_IDL_NODE_SIGNAL); + + ((GIdlNode *)signal)->name = g_strdup (name); + + signal->run_first = FALSE; + signal->run_last = FALSE; + signal->run_cleanup = FALSE; + if (strcmp (when, "FIRST") == 0) + signal->run_first = TRUE; + else if (strcmp (when, "LAST") == 0) + signal->run_last = TRUE; + else + signal->run_cleanup = TRUE; + + if (no_recurse && strcmp (no_recurse, "1") == 0) + signal->no_recurse = TRUE; + else + signal->no_recurse = FALSE; + if (detailed && strcmp (detailed, "1") == 0) + signal->detailed = TRUE; + else + signal->detailed = FALSE; + if (action && strcmp (action, "1") == 0) + signal->action = TRUE; + else + signal->action = FALSE; + if (no_hooks && strcmp (no_hooks, "1") == 0) + signal->no_hooks = TRUE; + else + signal->no_hooks = FALSE; + if (has_class_closure && strcmp (has_class_closure, "1") == 0) + signal->has_class_closure = TRUE; + else + signal->has_class_closure = FALSE; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, signal); + + ctx->current_node = (GIdlNode *)signal; + ctx->state = STATE_FUNCTION; + } + + return TRUE; + } + return FALSE; +} + +static gboolean +start_vfunc (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "vfunc") == 0 && + (ctx->state == STATE_OBJECT || + ctx->state == STATE_INTERFACE)) + { + const gchar *name; + const gchar *must_chain_up; + const gchar *override; + const gchar *is_class_closure; + const gchar *offset; + + name = find_attribute ("name", attribute_names, attribute_values); + must_chain_up = find_attribute ("must-chain-up", attribute_names, attribute_values); + override = find_attribute ("override", attribute_names, attribute_values); + is_class_closure = find_attribute ("is-class-closure", attribute_names, attribute_values); + offset = find_attribute ("offset", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeInterface *iface; + GIdlNodeVFunc *vfunc; + + vfunc = (GIdlNodeVFunc *)g_idl_node_new (G_IDL_NODE_VFUNC); + + ((GIdlNode *)vfunc)->name = g_strdup (name); + + if (must_chain_up && strcmp (must_chain_up, "1") == 0) + vfunc->must_chain_up = TRUE; + else + vfunc->must_chain_up = FALSE; + + if (override && strcmp (override, "always") == 0) + { + vfunc->must_be_implemented = TRUE; + vfunc->must_not_be_implemented = FALSE; + } + else if (override && strcmp (override, "never") == 0) + { + vfunc->must_be_implemented = FALSE; + vfunc->must_not_be_implemented = TRUE; + } + else + { + vfunc->must_be_implemented = FALSE; + vfunc->must_not_be_implemented = FALSE; + } + + if (is_class_closure && strcmp (is_class_closure, "1") == 0) + vfunc->is_class_closure = TRUE; + else + vfunc->is_class_closure = FALSE; + + if (offset) + vfunc->offset = atoi (offset); + else + vfunc->offset = 0; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface->members = g_list_append (iface->members, vfunc); + + ctx->current_node = (GIdlNode *)vfunc; + ctx->state = STATE_FUNCTION; + } + + return TRUE; + } + return FALSE; +} + + +static gboolean +start_struct (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "struct") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *deprecated; + + name = find_attribute ("name", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeStruct *struct_; + + struct_ = (GIdlNodeStruct *) g_idl_node_new (G_IDL_NODE_STRUCT); + + ((GIdlNode *)struct_)->name = g_strdup (name); + if (deprecated && strcmp (deprecated, "1") == 0) + struct_->deprecated = TRUE; + else + struct_->deprecated = FALSE; + + ctx->current_node = (GIdlNode *)struct_; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, struct_); + + ctx->state = STATE_STRUCT; + } + return TRUE; + } + return FALSE; +} + + +static gboolean +start_union (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "union") == 0 && + ctx->state == STATE_NAMESPACE) + { + const gchar *name; + const gchar *deprecated; + const gchar *typename; + const gchar *typeinit; + + name = find_attribute ("name", attribute_names, attribute_values); + deprecated = find_attribute ("deprecated", attribute_names, attribute_values); + typename = find_attribute ("type-name", attribute_names, attribute_values); + typeinit = find_attribute ("get-type", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeUnion *union_; + + union_ = (GIdlNodeUnion *) g_idl_node_new (G_IDL_NODE_UNION); + + ((GIdlNode *)union_)->name = g_strdup (name); + union_->gtype_name = g_strdup (typename); + union_->gtype_init = g_strdup (typeinit); + if (deprecated && strcmp (deprecated, "1") == 0) + union_->deprecated = TRUE; + else + union_->deprecated = FALSE; + + ctx->current_node = (GIdlNode *)union_; + ctx->current_module->entries = + g_list_append (ctx->current_module->entries, union_); + + ctx->state = STATE_UNION; + } + return TRUE; + } + return FALSE; +} + +static gboolean +start_discriminator (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) +{ + if (strcmp (element_name, "discriminator") == 0 && + ctx->state == STATE_UNION) + { + const gchar *type; + const gchar *offset; + + type = find_attribute ("type", attribute_names, attribute_values); + offset = find_attribute ("offset", attribute_names, attribute_values); + if (type == NULL) + MISSING_ATTRIBUTE (error, element_name, "type"); + else if (offset == NULL) + MISSING_ATTRIBUTE (error, element_name, "offset"); + { + ((GIdlNodeUnion *)ctx->current_node)->discriminator_type + = parse_type (type); + ((GIdlNodeUnion *)ctx->current_node)->discriminator_offset + = atoi (offset); + } + + return TRUE; + } + + return FALSE; +} + +static void +start_element_handler (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error) +{ + ParseContext *ctx = user_data; + gint i, line_number, char_number; + + switch (element_name[0]) + { + case 'a': + if (strcmp (element_name, "api") == 0 && ctx->state == STATE_START) + { + const gchar *version; + + version = find_attribute ("version", attribute_names, attribute_values); + + if (version == NULL) + MISSING_ATTRIBUTE (error, element_name, "version"); + else if (strcmp (version, "1.0") != 0) + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Unsupported version '%s'", + version); + else + ctx->state = STATE_ROOT; + + goto out; + } + break; + + case 'b': + if (start_boxed (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'c': + if (start_function (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_constant (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'd': + if (start_discriminator (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'e': + if (start_enum (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_errordomain (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'f': + if (start_function (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_field (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_enum (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + + break; + + case 'i': + if (start_interface (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + if (strcmp (element_name, "implements") == 0 && + ctx->state == STATE_OBJECT) + { + ctx->state = STATE_IMPLEMENTS; + + goto out; + } + else if (strcmp (element_name, "interface") == 0 && + ctx->state == STATE_IMPLEMENTS) + { + const gchar *name; + + name = find_attribute ("name", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface ->interfaces = g_list_append (iface->interfaces, g_strdup (name)); + } + + goto out; + } + else if (strcmp (element_name, "interface") == 0 && + ctx->state == STATE_REQUIRES) + { + const gchar *name; + + name = find_attribute ("name", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); + } + + goto out; + } + break; + + case 'm': + if (start_function (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_member (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'n': + if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_ROOT) + { + const gchar *name; + + name = find_attribute ("name", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + ctx->current_module = g_idl_module_new (name); + ctx->modules = g_list_append (ctx->modules, ctx->current_module); + + ctx->state = STATE_NAMESPACE; + } + + goto out; + } + break; + + case 'o': + if (start_object (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (strcmp (element_name, "object") == 0 && + ctx->state == STATE_REQUIRES) + { + const gchar *name; + + name = find_attribute ("name", attribute_names, attribute_values); + + if (name == NULL) + MISSING_ATTRIBUTE (error, element_name, "name"); + else + { + GIdlNodeInterface *iface; + + iface = (GIdlNodeInterface *)ctx->current_node; + iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); + } + + goto out; + } + break; + + case 'p': + if (start_property (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (strcmp (element_name, "parameters") == 0 && + ctx->state == STATE_FUNCTION) + { + ctx->state = STATE_PARAMETERS; + + goto out; + } + else if (start_parameter (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + + break; + + case 'r': + if (start_return_type (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (strcmp (element_name, "requires") == 0 && + ctx->state == STATE_INTERFACE) + { + ctx->state = STATE_REQUIRES; + + goto out; + } + + break; + + case 's': + if (start_signal (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + else if (start_struct (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + + break; + + case 'u': + if (start_union (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + + case 'v': + if (start_vfunc (context, element_name, + attribute_names, attribute_values, + ctx, error)) + goto out; + break; + } + + g_markup_parse_context_get_position (context, &line_number, &char_number); + + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_UNKNOWN_ELEMENT, + "Unexpected start tag '%s' on line %d char %d", + element_name, + line_number, char_number); + + out: ; + +} + +static void +end_element_handler (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error) +{ + ParseContext *ctx = user_data; + + switch (ctx->state) + { + case STATE_START: + case STATE_END: + /* no need to GError here, GMarkup already catches this */ + break; + + case STATE_ROOT: + ctx->state = STATE_END; + break; + + case STATE_NAMESPACE: + if (strcmp (element_name, "namespace") == 0) + { + ctx->current_module = NULL; + ctx->state = STATE_ROOT; + } + break; + + case STATE_FUNCTION: + if (strcmp (element_name, "return-type") == 0) + /* do nothing */ ; + + else if (ctx->current_node == g_list_last (ctx->current_module->entries)->data) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + else + { + ctx->current_node = g_list_last (ctx->current_module->entries)->data; + if (ctx->current_node->type == G_IDL_NODE_INTERFACE) + ctx->state = STATE_INTERFACE; + else if (ctx->current_node->type == G_IDL_NODE_OBJECT) + ctx->state = STATE_OBJECT; + else if (ctx->current_node->type == G_IDL_NODE_BOXED) + ctx->state = STATE_BOXED; + else if (ctx->current_node->type == G_IDL_NODE_STRUCT) + ctx->state = STATE_STRUCT; + else if (ctx->current_node->type == G_IDL_NODE_UNION) + ctx->state = STATE_UNION; + } + break; + + case STATE_OBJECT: + if (strcmp (element_name, "object") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_ERRORDOMAIN: + if (strcmp (element_name, "errordomain") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_INTERFACE: + if (strcmp (element_name, "interface") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_ENUM: + if (strcmp (element_name, "enum") == 0 || + strcmp (element_name, "flags") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_BOXED: + if (strcmp (element_name, "boxed") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_STRUCT: + if (strcmp (element_name, "struct") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + case STATE_UNION: + if (strcmp (element_name, "union") == 0) + { + ctx->current_node = NULL; + ctx->state = STATE_NAMESPACE; + } + break; + + case STATE_IMPLEMENTS: + if (strcmp (element_name, "implements") == 0) + ctx->state = STATE_OBJECT; + break; + case STATE_REQUIRES: + ctx->state = STATE_INTERFACE; + break; + case STATE_PARAMETERS: + if (strcmp (element_name, "parameters") == 0) + ctx->state = STATE_FUNCTION; + break; + default: + g_error ("Unhandled state %d in end_element_handler\n", ctx->state); + } +} + +static void +text_handler (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error) +{ + /* FIXME warn about non-whitespace text */ +} + +static void +cleanup (GMarkupParseContext *context, + GError *error, + gpointer user_data) +{ + ParseContext *ctx = user_data; + GList *m; + + for (m = ctx->modules; m; m = m->next) + g_idl_module_free (m->data); + g_list_free (ctx->modules); + ctx->modules = NULL; + + ctx->current_module = NULL; +} + +static GMarkupParser parser = +{ + start_element_handler, + end_element_handler, + text_handler, + NULL, + cleanup +}; + +GList * +g_idl_parse_string (const gchar *buffer, + gssize length, + GError **error) +{ + ParseContext ctx = { 0 }; + GMarkupParseContext *context; + + ctx.state = STATE_START; + + context = g_markup_parse_context_new (&parser, 0, &ctx, NULL); + if (!g_markup_parse_context_parse (context, buffer, length, error)) + goto out; + + if (!g_markup_parse_context_end_parse (context, error)) + goto out; + + out: + + g_markup_parse_context_free (context); + + return ctx.modules; +} + +GList * +g_idl_parse_file (const gchar *filename, + GError **error) +{ + gchar *buffer; + gsize length; + GList *modules; + + if (!g_file_get_contents (filename, &buffer, &length, error)) + return NULL; + + modules = g_idl_parse_string (buffer, length, error); + + g_free (buffer); + + return modules; +} + + diff --git a/vapigen/gobject-introspection/gidlparser.h b/vapigen/gobject-introspection/gidlparser.h new file mode 100644 index 000000000..2d71aaa0d --- /dev/null +++ b/vapigen/gobject-introspection/gidlparser.h @@ -0,0 +1,38 @@ +/* GObject introspection: A parser for the XML IDL format + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#ifndef __G_IDL_PARSER_H__ +#define __G_IDL_PARSER_H__ + +#include + +G_BEGIN_DECLS + + +GList *g_idl_parse_string (const gchar *buffer, + gssize length, + GError **error); +GList *g_idl_parse_file (const gchar *filename, + GError **error); + + +G_END_DECLS + +#endif /* __G_IDL_PARSER_H__ */ diff --git a/vapigen/gobject-introspection/gmetadata.h b/vapigen/gobject-introspection/gmetadata.h new file mode 100644 index 000000000..7ca390c0d --- /dev/null +++ b/vapigen/gobject-introspection/gmetadata.h @@ -0,0 +1,539 @@ +/* GObject introspection: struct definitions for the binary + * metadata format, validation + * + * Copyright (C) 2005 Matthias Clasen + * + * 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 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. + */ + +#ifndef __G_METADATA_H__ +#define __G_METADATA_H__ + +G_BEGIN_DECLS + +#define G_IDL_MAGIC "GOBJ\nMETADATA\r\n\032" + +enum +{ + BLOB_TYPE_INVALID, + BLOB_TYPE_FUNCTION, + BLOB_TYPE_CALLBACK, + BLOB_TYPE_STRUCT, + BLOB_TYPE_BOXED, + BLOB_TYPE_ENUM, + BLOB_TYPE_FLAGS, + BLOB_TYPE_OBJECT, + BLOB_TYPE_INTERFACE, + BLOB_TYPE_CONSTANT, + BLOB_TYPE_ERROR_DOMAIN, + BLOB_TYPE_UNION +}; + +typedef struct +{ + gchar magic[16]; + guint8 major_version; + guint8 minor_version; + guint16 reserved; + guint16 n_entries; + guint16 n_local_entries; + guint32 directory; + guint32 n_annotations; + guint32 annotations; + + guint32 size; + guint32 namespace; + + guint16 entry_blob_size; + guint16 function_blob_size; + guint16 callback_blob_size; + guint16 signal_blob_size; + guint16 vfunc_blob_size; + guint16 arg_blob_size; + guint16 property_blob_size; + guint16 field_blob_size; + guint16 value_blob_size; + guint16 annotation_blob_size; + guint16 constant_blob_size; + guint16 error_domain_blob_size; + + guint16 signature_blob_size; + guint16 enum_blob_size; + guint16 struct_blob_size; + guint16 object_blob_size; + guint16 interface_blob_size; + guint16 union_blob_size; + + guint16 padding; +} Header; + +typedef struct +{ + guint16 blob_type; + + guint local : 1; + guint reserved :15; + + guint32 name; + guint32 offset; +} DirEntry; + + +#define TYPE_POINTER_MASK 1 << 7 +#define TYPE_TAG_MASK 63 + +typedef enum +{ + TYPE_TAG_VOID = 0, + TYPE_TAG_BOOLEAN = 1, + TYPE_TAG_INT8 = 2, + TYPE_TAG_UINT8 = 3, + TYPE_TAG_INT16 = 4, + TYPE_TAG_UINT16 = 5, + TYPE_TAG_INT32 = 6, + TYPE_TAG_UINT32 = 7, + TYPE_TAG_INT64 = 8, + TYPE_TAG_UINT64 = 9, + TYPE_TAG_INT = 10, + TYPE_TAG_UINT = 11, + TYPE_TAG_LONG = 12, + TYPE_TAG_ULONG = 13, + TYPE_TAG_SSIZE = 14, + TYPE_TAG_SIZE = 15, + TYPE_TAG_FLOAT = 16, + TYPE_TAG_DOUBLE = 17, + TYPE_TAG_UTF8 = 18, + TYPE_TAG_FILENAME = 19, + TYPE_TAG_ARRAY = 20, + TYPE_TAG_INTERFACE = 21, + TYPE_TAG_LIST = 22, + TYPE_TAG_SLIST = 23, + TYPE_TAG_HASH = 24, + TYPE_TAG_ERROR = 25 +} TypeTag; + +typedef union +{ + struct + { + guint reserved : 8; + guint reserved2 :16; + guint pointer : 1; + guint reserved3 : 2; + guint tag : 5; + }; + guint32 offset; +} SimpleTypeBlob; + + +typedef struct +{ + guint32 name; + + guint in : 1; + guint out : 1; + guint dipper : 1; + guint null_ok : 1; + guint optional : 1; + guint transfer_ownership : 1; + guint transfer_container_ownership : 1; + guint return_value : 1; + guint reserved :24; + + SimpleTypeBlob arg_type; +} ArgBlob; + +typedef struct +{ + SimpleTypeBlob return_type; + + guint may_return_null : 1; + guint caller_owns_return_value : 1; + guint caller_owns_return_container : 1; + guint reserved :13; + + guint16 n_arguments; + + ArgBlob arguments[]; +} SignatureBlob; + +typedef struct +{ + guint16 blob_type; /* 1 */ + + guint deprecated : 1; + guint reserved :15; + + guint32 name; +} CommonBlob; + +typedef struct +{ + guint16 blob_type; /* 1 */ + + guint deprecated : 1; + guint setter : 1; + guint getter : 1; + guint constructor : 1; + guint wraps_vfunc : 1; + guint reserved : 1; + guint index :10; + + guint32 name; + guint32 symbol; + guint32 signature; +} FunctionBlob; + +typedef struct +{ + guint16 blob_type; /* 2 */ + + guint deprecated : 1; + guint reserved :15; + + guint32 name; + guint32 signature; +} CallbackBlob; + +typedef struct +{ + guint pointer :1; + guint reserved :2; + guint tag :5; + guint8 reserved2; + guint16 interface; +} InterfaceTypeBlob; + +typedef struct +{ + guint pointer :1; + guint reserved :2; + guint tag :5; + + guint zero_terminated :1; + guint has_length :1; + guint reserved2 :6; + + guint16 length; + + SimpleTypeBlob type; +} ArrayTypeBlob; + +typedef struct +{ + guint pointer :1; + guint reserved :2; + guint tag :5; + + guint8 reserved2; + guint16 n_types; + + SimpleTypeBlob type[]; +} ParamTypeBlob; + +typedef struct +{ + guint pointer :1; + guint reserved :2; + guint tag :5; + + guint8 reserved2; + guint16 n_domains; + + guint16 domains[]; +} ErrorTypeBlob; + +typedef struct +{ + guint16 blob_type; /* 10 */ + + guint deprecated : 1; + guint reserved :15; + + guint32 name; + + guint32 get_quark; + guint16 error_codes; + guint16 reserved2; +} ErrorDomainBlob; + +typedef struct +{ + guint deprecated : 1; + guint reserved :31; + guint32 name; + guint32 value; +} ValueBlob; + +typedef struct +{ + guint32 name; + + guint readable : 1; + guint writable : 1; + guint reserved : 6; + guint8 bits; + + guint16 struct_offset; + + SimpleTypeBlob type; +} FieldBlob; + +typedef struct +{ + guint16 blob_type; + guint deprecated : 1; + guint unregistered :15; + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; +} RegisteredTypeBlob; + +typedef struct +{ + guint16 blob_type; + + guint deprecated : 1; + guint unregistered : 1; + guint reserved :14; + + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; + + guint16 n_fields; + guint16 n_methods; + +#if 0 + /* variable-length parts of the blob */ + FieldBlob fields[]; + FunctionBlob methods[]; +#endif +} StructBlob; + +typedef struct +{ + guint16 blob_type; + guint deprecated : 1; + guint unregistered : 1; + guint discriminated : 1; + guint reserved :13; + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; + + guint16 n_fields; + guint16 n_functions; + + gint32 discriminator_offset; + SimpleTypeBlob discriminator_type; + +#if 0 + FieldBlob fields[]; + FunctionBlob functions[]; + ConstantBlob discriminator_values[] +#endif +} UnionBlob; + +typedef struct +{ + guint16 blob_type; + + guint deprecated : 1; + guint unregistered : 1; + guint reserved :14; + + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; + + guint16 n_values; + guint16 reserved2; + + ValueBlob values[]; +} EnumBlob; + +typedef struct +{ + guint32 name; + + guint deprecated : 1; + guint readable : 1; + guint writable : 1; + guint construct : 1; + guint construct_only : 1; + guint reserved :27; + + SimpleTypeBlob type; + +} PropertyBlob; + +typedef struct +{ + guint deprecated : 1; + guint run_first : 1; + guint run_last : 1; + guint run_cleanup : 1; + guint no_recurse : 1; + guint detailed : 1; + guint action : 1; + guint no_hooks : 1; + guint has_class_closure : 1; + guint true_stops_emit : 1; + guint reserved : 6; + + guint16 class_closure; + + guint32 name; + + guint32 signature; +} SignalBlob; + +typedef struct +{ + guint32 name; + + guint must_chain_up : 1; + guint must_be_implemented : 1; + guint must_not_be_implemented : 1; + guint class_closure : 1; + guint reserved :12; + guint16 signal; + + guint16 struct_offset; + guint16 reserved2; + guint32 signature; +} VFuncBlob; + +typedef struct +{ + guint16 blob_type; /* 7 */ + guint deprecated : 1; + guint reserved :15; + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; + + guint16 parent; + + guint16 n_interfaces; + guint16 n_fields; + guint16 n_properties; + guint16 n_methods; + guint16 n_signals; + guint16 n_vfuncs; + guint16 n_constants; + + guint16 interfaces[]; + +#if 0 + /* variable-length parts of the blob */ + FieldBlob fields[]; + PropertyBlob properties[]; + FunctionBlob methods[]; + SignalBlob signals[]; + VFuncBlob vfuncs[]; + ConstantBlob constants[]; +#endif +} ObjectBlob; + +typedef struct +{ + guint16 blob_type; + guint deprecated : 1; + guint reserved :15; + guint32 name; + + guint32 gtype_name; + guint32 gtype_init; + + guint16 n_prerequisites; + guint16 n_properties; + guint16 n_methods; + guint16 n_signals; + guint16 n_vfuncs; + guint16 n_constants; + + guint16 prerequisites[]; + +#if 0 + /* variable-length parts of the blob */ + PropertyBlob properties[]; + FunctionBlob methods[]; + SignalBlob signals[]; + VFuncBlob vfuncs[]; + ConstantBlob constants[]; +#endif +} InterfaceBlob; + + +typedef struct +{ + guint16 blob_type; + guint deprecated : 1; + guint reserved :15; + guint32 name; + + SimpleTypeBlob type; + + guint32 size; + guint32 offset; +} ConstantBlob; + +typedef struct +{ + guint32 offset; + guint32 name; + guint32 value; +} AnnotationBlob; + + + +DirEntry *g_metadata_get_dir_entry (const guchar *metadata, + guint16 index); + +void g_metadata_check_sanity (void); + +#define g_metadata_get_string(metadata,offset) ((const gchar*)&(metadata)[(offset)]) + + +typedef enum +{ + G_METADATA_ERROR_INVALID, + G_METADATA_ERROR_INVALID_HEADER, + G_METADATA_ERROR_INVALID_DIRECTORY, + G_METADATA_ERROR_INVALID_ENTRY, + G_METADATA_ERROR_INVALID_BLOB +} GMetadataError; + +#define G_METADATA_ERROR (g_metadata_error_quark ()) + +GQuark g_metadata_error_quark (void); + +gboolean g_metadata_validate (const guchar *data, + guint len, + GError **error); + + +G_END_DECLS + +#endif /* __G_METADATA_H__ */ + diff --git a/vapigen/packages/atk/atk.files b/vapigen/packages/atk/atk.files new file mode 100644 index 000000000..f72e4d974 --- /dev/null +++ b/vapigen/packages/atk/atk.files @@ -0,0 +1 @@ +atk diff --git a/vapigen/packages/atk/atk.gidl b/vapigen/packages/atk/atk.gidl new file mode 100644 index 000000000..69463b8c1 --- /dev/null +++ b/vapigen/packages/atk/atk.gidl @@ -0,0 +1,3006 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vapigen/packages/atk/atk.namespace b/vapigen/packages/atk/atk.namespace new file mode 100644 index 000000000..83fd424e1 --- /dev/null +++ b/vapigen/packages/atk/atk.namespace @@ -0,0 +1 @@ +Atk diff --git a/vapigen/packages/gdk-2.0/gdk-2.0.excludes b/vapigen/packages/gdk-2.0/gdk-2.0.excludes new file mode 100644 index 000000000..89f974ece --- /dev/null +++ b/vapigen/packages/gdk-2.0/gdk-2.0.excludes @@ -0,0 +1,4 @@ +gdkalias.h +keyname-table.h +gdk-pixbuf-alias.h +xpm-color-table.h diff --git a/vapigen/packages/gdk-2.0/gdk-2.0.files b/vapigen/packages/gdk-2.0/gdk-2.0.files new file mode 100644 index 000000000..0180eb1f8 --- /dev/null +++ b/vapigen/packages/gdk-2.0/gdk-2.0.files @@ -0,0 +1,2 @@ +gdk +gdk-pixbuf diff --git a/vapigen/packages/gdk-2.0/gdk-2.0.gidl b/vapigen/packages/gdk-2.0/gdk-2.0.gidl new file mode 100644 index 000000000..aa6faba89 --- /dev/null +++ b/vapigen/packages/gdk-2.0/gdk-2.0.gidl @@ -0,0 +1,6098 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vapigen/packages/gdk-2.0/gdk-2.0.metadata b/vapigen/packages/gdk-2.0/gdk-2.0.metadata new file mode 100644 index 000000000..39e9f61e3 --- /dev/null +++ b/vapigen/packages/gdk-2.0/gdk-2.0.metadata @@ -0,0 +1,3 @@ +Gdk cheader_filename="gdk/gdk.h" +GdkAtom is_value_type="1" +GdkColor is_value_type="1" diff --git a/vapigen/packages/gdk-2.0/gdk-2.0.namespace b/vapigen/packages/gdk-2.0/gdk-2.0.namespace new file mode 100644 index 000000000..2617db96f --- /dev/null +++ b/vapigen/packages/gdk-2.0/gdk-2.0.namespace @@ -0,0 +1 @@ +Gdk diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0-custom.vala b/vapigen/packages/gtk+-2.0/gtk+-2.0-custom.vala new file mode 100644 index 000000000..823b8a198 --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0-custom.vala @@ -0,0 +1,28 @@ +/* gtk+-2.0.vala + * + * Copyright (C) 2006 Jürg Billeter + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +[CCode (cheader_filename = "gtk/gtk.h")] +namespace Gtk { + public void init (ref int argc, out string[] argv); + public void main (); + public void main_quit (); +} diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.excludes b/vapigen/packages/gtk+-2.0/gtk+-2.0.excludes new file mode 100644 index 000000000..e4d977cd2 --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.excludes @@ -0,0 +1,68 @@ +gtkalias.h +gtkbuiltincache.h +gtkdndcursors.h +gtkfilechooserdefault.c +gtkfilechooserdefault.h +gtkfilechooserembed.c +gtkfilechooserembed.h +gtkfilechooserentry.c +gtkfilechooserentry.h +gtkfilechoosersettings.c +gtkfilechoosersettings.h +gtkfilechooserutils.c +gtkfilechooserutils.h +gtkfilesystem.c +gtkfilesystem.h +gtkfilesystemmodel.c +gtkfilesystemmodel.h +gtkfilesystemunix.c +gtkfilesystemunix.h +gtkfilesystemwin32.c +gtkfilesystemwin32.h +gtkiconcache.c +gtkiconcache.h +gtkiconthemeparser.h +gtkpathbar.c +gtkpathbar.h +gtkrbtree.c +gtkrbtree.h +gtksequence.c +gtksequence.h +gtktextbtree.c +gtktextbtree.h +gtktextsegment.c +gtktextsegment.h +gtktexttypes.c +gtktexttypes.h +gtktextutil.c +gtktextutil.h +gtkthemes.c +gtkthemes.h +gtktreedatalist.c +gtktreedatalist.h +gtkwindow-decorate.c +gtkwindow-decorate.h +gtkxembed.h +xembed.h +gtkclist.c +gtkclist.h +gtkctree.c +gtkctree.h +gtklist.c +gtklist.h +gtklistitem.c +gtklistitem.h +gtkoldeditable.c +gtkoldeditable.h +gtkpixmap.c +gtkpixmap.h +gtkpreview.c +gtkpreview.h +gtktext.c +gtktext.h +gtktipsquery.c +gtktipsquery.h +gtktree.c +gtktree.h +gtktreeitem.c +gtktreeitem.h diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.files b/vapigen/packages/gtk+-2.0/gtk+-2.0.files new file mode 100644 index 000000000..a5699d82a --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.files @@ -0,0 +1 @@ +gtk diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.gidl b/vapigen/packages/gtk+-2.0/gtk+-2.0.gidl new file mode 100644 index 000000000..4b8443f47 --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.gidl @@ -0,0 +1,26480 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.metadata b/vapigen/packages/gtk+-2.0/gtk+-2.0.metadata new file mode 100644 index 000000000..be96f0a97 --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.metadata @@ -0,0 +1,68 @@ +Gtk cheader_filename="gtk/gtk.h" +GtkAction::activate has_emitter="1" +GtkAdjustment::changed has_emitter="1" +GtkAdjustment::value_changed has_emitter="1" +GtkButton::clicked has_emitter="1" +GtkButton::enter has_emitter="1" +GtkButton::leave has_emitter="1" +GtkButton::pressed has_emitter="1" +GtkButton::released has_emitter="1" +GtkCallbackMarshal hidden="1" +GtkCheckMenuItem::toggled has_emitter="1" +GtkContainer::add has_emitter="1" +GtkContainer::check_resize has_emitter="1" +GtkContainer::remove has_emitter="1" +GtkContainer::set_focus_child has_emitter="1" +GtkDialog::response has_emitter="1" +GtkEntryCompletion::insert_prefix has_emitter="1" +GtkIconView::item_activated has_emitter="1" +gtk_icon_view_select_all hidden="1" experimental="1" +gtk_icon_view_unselect_all hidden="1" experimental="1" +GtkIMContext::delete_surrounding has_emitter="1" +GtkItem::deselect has_emitter="1" +GtkItem::select has_emitter="1" +GtkItem::toggle has_emitter="1" +GtkMenuItem::activate has_emitter="1" +GtkMenuItem::toggle_size_allocate has_emitter="1" +GtkMenuItem::toggle_size_request has_emitter="1" +GtkMenuShell::cancel has_emitter="1" +GtkMenuShell::deactivate has_emitter="1" +gtk_object_destroy hidden="1" experimental="1" +gtk_printer_accepts_pdf hidden="1" experimental="1" +gtk_printer_accepts_ps hidden="1" experimental="1" +gtk_printer_is_virtual hidden="1" experimental="1" +gtk_quit_add_full hidden="1" +GtkTextBuffer::apply_tag has_emitter="1" +GtkTextBuffer::begin_user_action has_emitter="1" +GtkTextBuffer::end_user_action has_emitter="1" +GtkTextBuffer::insert_child_anchor has_emitter="1" +GtkTextBuffer::insert_pixbuf has_emitter="1" +GtkTextBuffer::remove_tag has_emitter="1" +GtkTextTag::event has_emitter="1" +GtkToggleAction::toggled has_emitter="1" +GtkToggleButton::toggled has_emitter="1" +GtkToolItem::set_tooltip has_emitter="1" +GtkTreeView::row_activated has_emitter="1" +GtkTreeView::row_expanded has_emitter="1" +GtkTreeViewColumn::clicked has_emitter="1" +gtk_tree_view_column_new_with_attributes ellipsis="1" +GtkWidget::can_activate_accel has_emitter="1" +gtk_widget_destroy hidden="1" +GtkWidget::event has_emitter="1" +gtk_widget_is_focus hidden="1" experimental="1" +GtkWidget::child_notify has_emitter="1" +GtkWidget::grab_focus has_emitter="1" +GtkWidget::hide has_emitter="1" +GtkWidget::map has_emitter="1" +GtkWidget::mnemonic_activate has_emitter="1" +GtkWidget::realize has_emitter="1" +GtkWidget::size_allocate has_emitter="1" +GtkWidget::size_request has_emitter="1" +GtkWidget::show has_emitter="1" +GtkWidget::unmap has_emitter="1" +GtkWidget::unrealize has_emitter="1" +gtk_window_has_toplevel_focus hidden="1" experimental="1" +gtk_window_is_active hidden="1" experimental="1" +GtkWindow::activate_default name="default_activated" experimental="1" +GtkWindow::activate_focus name="focus_activated" experimental="1" +GtkWindow::set_focus has_emitter="1" diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.namespace b/vapigen/packages/gtk+-2.0/gtk+-2.0.namespace new file mode 100644 index 000000000..0be6e7e3d --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.namespace @@ -0,0 +1 @@ +Gtk diff --git a/vapigen/packages/gtk+-2.0/gtk+-2.0.patch b/vapigen/packages/gtk+-2.0/gtk+-2.0.patch new file mode 100644 index 000000000..454418c91 --- /dev/null +++ b/vapigen/packages/gtk+-2.0/gtk+-2.0.patch @@ -0,0 +1,24 @@ +diff -puNr gtk+-2.10.1.orig/gtk/gtkclipboard.h gtk+-2.10.1/gtk/gtkclipboard.h +--- gtk+-2.10.1.orig/gtk/gtkclipboard.h 2006-04-24 07:42:12.000000000 +0200 ++++ gtk+-2.10.1/gtk/gtkclipboard.h 2006-08-07 16:32:29.000000000 +0200 +@@ -30,6 +30,9 @@ G_BEGIN_DECLS + #define GTK_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CLIPBOARD, GtkClipboard)) + #define GTK_IS_CLIPBOARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CLIPBOARD)) + ++typedef struct _GtkClipboard GtkClipboard; ++typedef struct _GtkClipboardClass GtkClipboardClass; ++ + typedef void (* GtkClipboardReceivedFunc) (GtkClipboard *clipboard, + GtkSelectionData *selection_data, + gpointer data); +diff -puNr gtk+-2.10.1.orig/gtk/gtkfilechooser.h gtk+-2.10.1/gtk/gtkfilechooser.h +--- gtk+-2.10.1.orig/gtk/gtkfilechooser.h 2005-10-10 16:29:03.000000000 +0200 ++++ gtk+-2.10.1/gtk/gtkfilechooser.h 2006-08-07 16:34:13.000000000 +0200 +@@ -29,6 +29,7 @@ G_BEGIN_DECLS + #define GTK_TYPE_FILE_CHOOSER (gtk_file_chooser_get_type ()) + #define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser)) + #define GTK_IS_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER)) ++#define GTK_FILE_CHOOSER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface)) + + typedef struct _GtkFileChooser GtkFileChooser; + diff --git a/vapigen/packages/pango/pango.excludes b/vapigen/packages/pango/pango.excludes new file mode 100644 index 000000000..c7636e170 --- /dev/null +++ b/vapigen/packages/pango/pango.excludes @@ -0,0 +1,35 @@ +pangocairo.h +pangocairo-atsui.h +pangocairo-atsuifont.h +pangocairo-fc.h +pangocairo-win32.h +pangocairo-private.h +pangofc-decoder.c +pangofc-decoder.h +pangofc-font.c +pangofc-font.h +pangofc-fontmap.c +pangofc-fontmap.h +pangofc-private.h +pangoft2.c +pangoft2.h +pangoft2-fontmap.c +pangoft2-private.h +pangoft2-render.c +pangox-fontcache.c +pangox-fontmap.c +pangox-private.h +pangox.h +pangox.c +pangoxft.h +pangoxft-font.c +pangoxft-font.h +pangoxft-fontmap.c +pangoxft-fontmap.h +pangoxft-private.h +pangoxft-render.c +pangoxft-render.h +pango-color-table.h +pango-impl-utils.h +pango-script-lang-table.h +pango-script-table.h diff --git a/vapigen/packages/pango/pango.files b/vapigen/packages/pango/pango.files new file mode 100644 index 000000000..98ccac5bc --- /dev/null +++ b/vapigen/packages/pango/pango.files @@ -0,0 +1 @@ +pango diff --git a/vapigen/packages/pango/pango.gidl b/vapigen/packages/pango/pango.gidl new file mode 100644 index 000000000..8c84c8e64 --- /dev/null +++ b/vapigen/packages/pango/pango.gidl @@ -0,0 +1,2474 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vapigen/packages/pango/pango.metadata b/vapigen/packages/pango/pango.metadata new file mode 100644 index 000000000..1d1800df1 --- /dev/null +++ b/vapigen/packages/pango/pango.metadata @@ -0,0 +1,2 @@ +Pango cheader_filename="pango/pango.h" +pango_attr_size_new_absolute hidden="1" diff --git a/vapigen/packages/pango/pango.namespace b/vapigen/packages/pango/pango.namespace new file mode 100644 index 000000000..1e0fa507d --- /dev/null +++ b/vapigen/packages/pango/pango.namespace @@ -0,0 +1 @@ +Pango diff --git a/vapigen/vapigen/Makefile.am b/vapigen/vapigen/Makefile.am new file mode 100644 index 000000000..9842b4bcf --- /dev/null +++ b/vapigen/vapigen/Makefile.am @@ -0,0 +1,35 @@ +NULL = + +INCLUDES = \ + $(GLIB_CFLAGS) \ + $(VALA_CFLAGS) \ + -I ../gobject-introspection \ + $(NULL) + +bin_PROGRAMS = \ + vapigen \ + $(NULL) + +BUILT_SOURCES = vapigen.vala.stamp + +vapigen_SOURCES = \ + vapigen.vala.stamp \ + valagidlparser.c \ + valagidlparser.h \ + valagidlparser.vala \ + valavapigen.c \ + valavapigen.h \ + valavapigen.vala \ + $(NULL) + +vapigen.vala.stamp: $(filter %.vala,$(vapigen_SOURCES)) + $(VALAC) --vapidir ../gobject-introspection --pkg gidl --pkg vala-1.0 $^ + touch $@ + +vapigen_LDADD = \ + $(GLIB_LIBS) \ + $(VALA_LIBS) \ + ../gobject-introspection/libgidl.la \ + $(NULL) + +EXTRA_DIST = vapigen.vala.stamp diff --git a/vapigen/vapigen/valagidlparser.vala b/vapigen/vapigen/valagidlparser.vala new file mode 100644 index 000000000..149a18358 --- /dev/null +++ b/vapigen/vapigen/valagidlparser.vala @@ -0,0 +1,788 @@ +/* valagidlparser.vala + * + * Copyright (C) 2006 Jürg Billeter + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +using GLib; + +/** + * Code visitor parsing all GIDL files. + */ +public class Vala.GIdlParser : CodeVisitor { + private SourceReference current_source_reference; + + private DataType current_data_type; + private HashTable codenode_attributes_map; + private HashTable current_type_symbol_map; + + /** + * Parse all source files in the specified code context and build a + * code tree. + * + * @param context a code context + */ + public void parse (CodeContext! context) { + context.accept (this); + } + + public override void visit_begin_source_file (SourceFile! source_file) { + if (source_file.filename.has_suffix (".gidl")) { + parse_file (source_file); + } + } + + private void parse_file (SourceFile! source_file) { + Error error = null; + + string metadata_filename = "%s.metadata".printf (source_file.filename.ndup (source_file.filename.size () - ".gidl".size ())); + + codenode_attributes_map = new HashTable.full (str_hash, str_equal, g_free, g_free); + + if (File.test (metadata_filename, FileTest.EXISTS)) { + string metadata; + File.get_contents (metadata_filename, out metadata, null, out error); + + foreach (string line in metadata.split ("\n")) { + var line_parts = line.split (" ", 2); + if (line_parts[0] == null) { + continue; + } + + codenode_attributes_map.insert (line_parts[0], line_parts[1]); + } + } + + var modules = Idl.parse_file (source_file.filename, out error); + + if (error != null) { + stdout.printf ("error parsing GIDL file: %s\n", error.message); + } + + current_source_reference = new SourceReference (source_file); + + foreach (IdlModule module in modules) { + var ns = parse_module (module); + source_file.add_namespace (ns); + } + } + + private ref Namespace parse_module (IdlModule! module) { + var ns = new Namespace (module.name, current_source_reference); + + var attributes = get_attributes (ns.name); + if (attributes != null) { + foreach (string attr in attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "cheader_filename") { + ns.set_cheader_filename (eval (nv[1])); + } + } + } + + foreach (IdlNode node in module.entries) { + if (node.type == IdlNodeTypeId.CALLBACK) { + var cb = parse_callback ((IdlNodeFunction) node); + if (cb == null) { + continue; + } + if (cb.name.has_prefix (module.name)) { + cb.name = cb.name.offset (module.name.len ()); + } + ns.add_callback (cb); + } else if (node.type == IdlNodeTypeId.STRUCT) { + var st = parse_struct ((IdlNodeStruct) node); + if (st == null) { + continue; + } + if (st.name.has_prefix (module.name)) { + st.name = st.name.offset (module.name.len ()); + } + ns.add_struct (st); + } else if (node.type == IdlNodeTypeId.BOXED) { + var st = parse_boxed ((IdlNodeBoxed) node); + if (st.name.has_prefix (module.name)) { + st.name = st.name.offset (module.name.len ()); + } + ns.add_struct (st); + } else if (node.type == IdlNodeTypeId.ENUM) { + var en = parse_enum ((IdlNodeEnum) node); + if (en.name.has_prefix (module.name)) { + en.name = en.name.offset (module.name.len ()); + } + ns.add_enum (en); + } else if (node.type == IdlNodeTypeId.OBJECT) { + var cl = parse_object ((IdlNodeInterface) node); + if (cl.name.has_prefix (module.name)) { + cl.name = cl.name.offset (module.name.len ()); + } + ns.add_class (cl); + } else if (node.type == IdlNodeTypeId.INTERFACE) { + var iface = parse_interface ((IdlNodeInterface) node); + if (iface.name.has_prefix (module.name)) { + iface.name = iface.name.offset (module.name.len ()); + } + ns.add_interface (iface); + } else if (node.type == IdlNodeTypeId.CONSTANT) { + var c = parse_constant ((IdlNodeConstant) node); + if (c.name.has_prefix (module.name.up ())) { + c.name = c.name.offset (module.name.len () + 1); + } + ns.add_constant (c); + } + } + + return ns; + } + + private ref Callback parse_callback (IdlNodeFunction! f_node) { + var node = (IdlNode) f_node; + + var attributes = get_attributes (node.name); + if (attributes != null) { + foreach (string attr in attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "hidden") { + if (eval (nv[1]) == "1") { + return null; + } + } + } + } + + var cb = new Callback (node.name, parse_param (f_node.result), current_source_reference); + cb.access = MemberAccessibility.PUBLIC; + + foreach (IdlNodeParam param in f_node.parameters) { + var param_node = (IdlNode) param; + + var p = new FormalParameter (param_node.name, parse_param (param)); + cb.add_parameter (p); + } + + return cb; + } + + private ref Struct parse_struct (IdlNodeStruct! st_node) { + var node = (IdlNode) st_node; + + if (st_node.deprecated) { + return null; + } + + var st = new Struct (node.name, current_source_reference); + st.access = MemberAccessibility.PUBLIC; + + st.set_is_reference_type (true); + + var st_attributes = get_attributes (node.name); + if (st_attributes != null) { + foreach (string attr in st_attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "is_value_type" && eval (nv[1]) == "1") { + st.set_is_reference_type (false); + } + } + } + + current_data_type = st; + + foreach (IdlNode member in st_node.members) { + if (member.type == IdlNodeTypeId.FUNCTION) { + var m = parse_function ((IdlNodeFunction) member); + if (m != null) { + st.add_method (m); + } + } else if (member.type == IdlNodeTypeId.FIELD) { + var f = parse_field ((IdlNodeField) member); + if (f != null) { + st.add_field (f); + } + } + } + + current_data_type = null; + + return st; + } + + private ref Struct parse_boxed (IdlNodeBoxed! boxed_node) { + var node = (IdlNode) boxed_node; + + var st = new Struct (node.name, current_source_reference); + st.access = MemberAccessibility.PUBLIC; + + current_data_type = st; + + foreach (IdlNode member in boxed_node.members) { + if (member.type == IdlNodeTypeId.FUNCTION) { + var m = parse_function ((IdlNodeFunction) member); + if (m != null) { + st.add_method (m); + } + } + } + + current_data_type = null; + + return st; + } + + private ref Enum parse_enum (IdlNodeEnum! en_node) { + var node = (IdlNode) en_node; + + var en = new Enum (node.name, current_source_reference); + en.access = MemberAccessibility.PUBLIC; + + string common_prefix = null; + + foreach (IdlNode value in en_node.values) { + if (common_prefix == null) { + common_prefix = value.name; + while (common_prefix.len () > 0 && !common_prefix.has_suffix ("_")) { + // FIXME: could easily be made faster + common_prefix = common_prefix.ndup (common_prefix.size () - 1); + } + } else { + while (!value.name.has_prefix (common_prefix)) { + common_prefix = common_prefix.ndup (common_prefix.size () - 1); + } + } + } + + en.set_cprefix (common_prefix); + + foreach (IdlNode value2 in en_node.values) { + var ev = new EnumValue (value2.name.offset (common_prefix.len ())); + en.add_value (ev); + } + + return en; + } + + private ref Class parse_object (IdlNodeInterface! node) { + + var cl = new Class (node.gtype_name, current_source_reference); + cl.access = MemberAccessibility.PUBLIC; + + if (node.parent != null) { + var parent = new TypeReference (); + parse_type_string (parent, node.parent); + cl.add_base_type (parent); + } + + foreach (string iface_name in node.interfaces) { + var iface = new TypeReference (); + parse_type_string (iface, iface_name); + cl.add_base_type (iface); + } + + current_data_type = cl; + + current_type_symbol_map = new HashTable.full (str_hash, str_equal, g_free, g_free); + + foreach (IdlNode member in node.members) { + if (member.type == IdlNodeTypeId.FUNCTION) { + var m = parse_function ((IdlNodeFunction) member); + if (m != null) { + cl.add_method (m); + } + } else if (member.type == IdlNodeTypeId.PROPERTY) { + var prop = parse_property ((IdlNodeProperty) member); + if (prop != null) { + cl.add_property (prop); + } + } else if (member.type == IdlNodeTypeId.SIGNAL) { + var sig = parse_signal ((IdlNodeSignal) member); + if (sig != null) { + cl.add_signal (sig); + } + } + } + + foreach (IdlNode member in node.members) { + if (member.type == IdlNodeTypeId.FIELD) { + if (current_type_symbol_map.lookup (member.name) == null) { + var f = parse_field ((IdlNodeField) member); + if (f != null) { + cl.add_field (f); + } + } + } + } + + foreach (Property prop in cl.get_properties ()) { + var getter = "get_%s".printf (prop.name); + + if (prop.get_accessor != null && current_type_symbol_map.lookup (getter) == null) { + prop.no_accessor_method = true; + } + + var setter = "set_%s".printf (prop.name); + + if (prop.set_accessor != null && current_type_symbol_map.lookup (setter) == null) { + prop.no_accessor_method = true; + } + } + + current_data_type = null; + current_type_symbol_map = null; + + return cl; + } + + private ref Interface parse_interface (IdlNodeInterface! node) { + var iface = new Interface (node.gtype_name, current_source_reference); + iface.access = MemberAccessibility.PUBLIC; + + foreach (string prereq_name in node.prerequisites) { + var prereq = new TypeReference (); + parse_type_string (prereq, prereq_name); + iface.add_base_type (prereq); + } + + current_data_type = iface; + + foreach (IdlNode member in node.members) { + if (member.type == IdlNodeTypeId.FUNCTION) { + var m = parse_function ((IdlNodeFunction) member); + if (m != null) { + iface.add_method (m); + } + } + } + + current_data_type = null; + + return iface; + } + + private ref TypeReference parse_type (IdlNodeType! type_node) { + var type = new TypeReference (); + if (type_node.tag == TypeTag.VOID) { + if (type_node.is_pointer) { + type.type_name = "pointer"; + } else { + type.type_name = "void"; + } + } else if (type_node.tag == TypeTag.BOOLEAN) { + type.type_name = "bool"; + } else if (type_node.tag == TypeTag.INT8) { + type.type_name = "char"; + } else if (type_node.tag == TypeTag.UINT8) { + type.type_name = "uchar"; + } else if (type_node.tag == TypeTag.INT16) { + type.type_name = "short"; + } else if (type_node.tag == TypeTag.UINT16) { + type.type_name = "ushort"; + } else if (type_node.tag == TypeTag.INT32) { + type.type_name = "int"; + } else if (type_node.tag == TypeTag.UINT32) { + type.type_name = "uint"; + } else if (type_node.tag == TypeTag.INT64) { + type.type_name = "int64"; + } else if (type_node.tag == TypeTag.UINT64) { + type.type_name = "uint64"; + } else if (type_node.tag == TypeTag.INT) { + type.type_name = "int"; + } else if (type_node.tag == TypeTag.UINT) { + type.type_name = "uint"; + } else if (type_node.tag == TypeTag.LONG) { + type.type_name = "long"; + } else if (type_node.tag == TypeTag.ULONG) { + type.type_name = "ulong"; + } else if (type_node.tag == TypeTag.SSIZE) { + type.type_name = "long"; + } else if (type_node.tag == TypeTag.SIZE) { + type.type_name = "ulong"; + } else if (type_node.tag == TypeTag.FLOAT) { + type.type_name = "float"; + } else if (type_node.tag == TypeTag.DOUBLE) { + type.type_name = "double"; + } else if (type_node.tag == TypeTag.UTF8) { + type.type_name = "string"; + } else if (type_node.tag == TypeTag.FILENAME) { + type.type_name = "string"; + } else if (type_node.tag == TypeTag.ARRAY) { + type = parse_type (type_node.parameter_type1); + type.array_rank = 1; + } else if (type_node.tag == TypeTag.LIST) { + type.namespace_name = "GLib"; + type.type_name = "List"; + } else if (type_node.tag == TypeTag.SLIST) { + type.namespace_name = "GLib"; + type.type_name = "SList"; + } else if (type_node.tag == TypeTag.HASH) { + type.namespace_name = "GLib"; + type.type_name = "HashTable"; + } else if (type_node.tag == TypeTag.ERROR) { + type.namespace_name = "GLib"; + type.type_name = "Error"; + } else if (type_node.is_interface) { + var n = type_node.@interface; + + if (n == "") { + return null; + } + + if (n.has_prefix ("const-")) { + n = n.offset ("const-".len ()); + } + + if (type_node.is_pointer && + (n == "gchar" || n == "char")) { + type.type_name = "string"; + } else if (n == "gunichar") { + type.type_name = "unichar"; + } else if (n == "gchar") { + type.type_name = "char"; + } else if (n == "guchar" || n == "guint8") { + type.type_name = "uchar"; + } else if (n == "gushort") { + type.type_name = "ushort"; + } else if (n == "gshort") { + type.type_name = "short"; + } else if (n == "gconstpointer") { + type.type_name = "pointer"; + } else if (n == "value_array") { + type.namespace_name = "GLib"; + type.type_name = "ValueArray"; + } else if (n == "time_t") { + type.type_name = "ulong"; + } else if (n == "FILE") { + type.namespace_name = "GLib"; + type.type_name = "File"; + } else { + parse_type_string (type, n); + } + } else { + stdout.printf ("%d\n", type_node.tag); + } + return type; + } + + private void parse_type_string (TypeReference! type, string! n) { + // Generated GIDL misses explicit namespace specifier, + // so try to guess namespace + if (n.has_prefix ("H") || n.has_suffix ("Class") || n == "va_list" || n == "LOGFONT") { + // unsupported + type.type_name = "pointer"; + } else if (n.has_prefix ("cairo")) { + type.namespace_name = "Cairo"; + if (n == "cairo_t") { + type.type_name = "Context"; + } else if (n == "cairo_surface_t") { + type.type_name = "Surface"; + } else { + type.namespace_name = null; + type.type_name = "pointer"; + } + } else if (n.has_prefix ("Atk")) { + type.namespace_name = "Atk"; + type.type_name = n.offset ("Atk".len ()); + if (type.type_name == "AttributeSet") { + type.namespace_name = "GLib"; + type.type_name = "SList"; + } + } else if (n.has_prefix ("Gtk")) { + type.namespace_name = "Gtk"; + type.type_name = n.offset ("Gtk".len ()); + if (type.type_name == "Allocation" || type.type_name == "TextLayout") { + type.namespace_name = null; + type.type_name = "pointer"; + } + } else if (n.has_prefix ("Gdk")) { + type.namespace_name = "Gdk"; + type.type_name = n.offset ("Gdk".len ()); + if (type.type_name == "NativeWindow" || type.type_name == "XEvent") { + type.namespace_name = null; + type.type_name = "pointer"; + } + } else if (n.has_prefix ("Pango")) { + type.namespace_name = "Pango"; + type.type_name = n.offset ("Pango".len ()); + if (type.type_name == "Glyph") { + type.namespace_name = null; + type.type_name = "uint"; + } else if (type.type_name == "GlyphUnit") { + type.namespace_name = null; + type.type_name = "int"; + } + } else if (n.has_prefix ("G")) { + type.namespace_name = "GLib"; + type.type_name = n.offset ("G".len ()); + if (type.type_name == "Strv") { + type.namespace_name = null; + type.type_name = "string"; + type.array_rank = 1; + } + } else { + var name_parts = n.split (".", 2); + if (name_parts[1] == null) { + type.type_name = name_parts[0]; + } else { + type.namespace_name = name_parts[0]; + type.type_name = name_parts[1]; + } + } + } + + private ref TypeReference parse_param (IdlNodeParam! param) { + var type = parse_type (param.type); + + // disable for now as null_ok not yet correctly set + // type.non_null = !param.null_ok; + + return type; + } + + private ref Method parse_function (IdlNodeFunction! f) { + var node = (IdlNode) f; + + if (f.deprecated) { + return null; + } + + TypeReference return_type = null; + if (f.result != null) { + return_type = parse_param (f.result); + } + + var m = new Method (node.name, return_type, current_source_reference); + m.access = MemberAccessibility.PUBLIC; + + if (current_type_symbol_map != null) { + current_type_symbol_map.insert (node.name, "1"); + } + + if (current_data_type != null) { + var sig_attributes = get_attributes ("%s::%s".printf (current_data_type.name, node.name)); + if (sig_attributes != null) { + foreach (string attr in sig_attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "has_emitter" && eval (nv[1]) == "1") { + return null; + } + } + } + } + + bool add_ellipsis = false; + + var attributes = get_attributes (f.symbol); + if (attributes != null) { + foreach (string attr in attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "hidden") { + if (eval (nv[1]) == "1") { + return null; + } + } else if (nv[0] == "ellipsis") { + if (eval (nv[1]) == "1") { + add_ellipsis = true; + } + } + } + } + + if (f.is_constructor || m.name.has_prefix ("new")) { + m.construction = true; + if (m.name == "new") { + m.name = null; + } else if (m.name.has_prefix ("new_")) { + m.name = m.name.offset ("new_".len ()); + } + } + + bool first = true; + foreach (IdlNodeParam param in f.parameters) { + var param_node = (IdlNode) param; + + if (first) { + first = false; + if (current_data_type != null && + param.type.is_interface && + (param_node.name == "self" || + param.type.@interface.has_suffix (current_data_type.name))) { + // instance method + continue; + } else { + // static method + m.instance = false; + } + } + + var p = new FormalParameter (param_node.name, parse_param (param)); + m.add_parameter (p); + } + + if (add_ellipsis) { + m.add_parameter (new FormalParameter.with_ellipsis ()); + } + + return m; + } + + private ref string! fix_prop_name (string name) { + var str = new String (); + + string i = name; + + while (i.len () > 0) { + unichar c = i.get_char (); + if (c == '-') { + str.append_c ('_'); + } else { + str.append_unichar (c); + } + + i = i.next_char (); + } + + return str.str; + } + + private ref Property parse_property (IdlNodeProperty! prop_node) { + var node = (IdlNode) prop_node; + + if (prop_node.deprecated) { + return null; + } + + if (!prop_node.readable && !prop_node.writable) { + // buggy GIDL definition + prop_node.readable = true; + prop_node.writable = true; + } + + PropertyAccessor get_acc = null; + PropertyAccessor set_acc = null; + if (prop_node.readable) { + get_acc = new PropertyAccessor (true, false, false, null, null); + } + if (prop_node.writable) { + set_acc = new PropertyAccessor (false, false, false, null, null); + if (prop_node.construct_only) { + set_acc.construction = true; + } else { + set_acc.writable = true; + set_acc.construction = prop_node.@construct; + } + } + + var prop = new Property (fix_prop_name (node.name), parse_type (prop_node.type), get_acc, set_acc, current_source_reference); + prop.access = MemberAccessibility.PUBLIC; + prop.interface_only = true; + + if (current_type_symbol_map != null) { + current_type_symbol_map.insert (prop.name, "1"); + } + + return prop; + } + + private ref Constant parse_constant (IdlNodeConstant! const_node) { + var node = (IdlNode) const_node; + + var type = parse_type (const_node.type); + if (type == null) { + return null; + } + + var c = new Constant (node.name, type, null, current_source_reference); + + return c; + } + + private ref Field parse_field (IdlNodeField! field_node) { + var node = (IdlNode) field_node; + + var type = parse_type (field_node.type); + if (type == null) { + return null; + } + + if (!field_node.readable) { + return null; + } + + if (current_type_symbol_map != null) { + current_type_symbol_map.insert (node.name, "1"); + } + + var field = new Field (node.name, type, null, current_source_reference); + field.access = MemberAccessibility.PUBLIC; + + return field; + } + + private ref string[] get_attributes (string! codenode) { + string attributes = codenode_attributes_map.lookup (codenode); + if (attributes == null) { + return null; + } + + return attributes.split (" "); + } + + private ref string eval (string! s) { + return s.offset (1).ndup (s.size () - 2); + } + + private ref Signal parse_signal (IdlNodeSignal! sig_node) { + var node = (IdlNode) sig_node; + + if (sig_node.deprecated || sig_node.result == null) { + return null; + } + + var sig = new Signal (fix_prop_name (node.name), parse_param (sig_node.result), current_source_reference); + sig.access = MemberAccessibility.PUBLIC; + + var attributes = get_attributes ("%s::%s".printf (current_data_type.name, sig.name)); + if (attributes != null) { + foreach (string attr in attributes) { + var nv = attr.split ("=", 2); + if (nv[0] == "name") { + sig.set_cname (sig.name); + sig.name = eval (nv[1]); + } else if (nv[0] == "has_emitter" && eval (nv[1]) == "1") { + sig.has_emitter = true; + } + } + } + + bool first = true; + + foreach (IdlNodeParam param in sig_node.parameters) { + if (first) { + // ignore implicit first signal parameter (sender) + first = false; + continue; + } + + var param_node = (IdlNode) param; + + var p = new FormalParameter (param_node.name, parse_param (param)); + sig.add_parameter (p); + } + + return sig; + } +} diff --git a/vapigen/vapigen/valavapigen.vala b/vapigen/vapigen/valavapigen.vala new file mode 100644 index 000000000..8d29805e4 --- /dev/null +++ b/vapigen/vapigen/valavapigen.vala @@ -0,0 +1,191 @@ +/* valavapigen.vala + * + * Copyright (C) 2006 Jürg Billeter + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +using GLib; + +class Vala.VAPIGen { + static string directory; + static bool version; + static string[] sources; + static string[] vapi_directories; + static string library; + static string[] packages; + static bool disable_memory_management; + CodeContext context; + + const OptionEntry[] options = { + { "vapidir", 0, 0, OptionArg.FILENAME_ARRAY, out vapi_directories, "Look for package bindings in DIRECTORY", "DIRECTORY..." }, + { "pkg", 0, 0, OptionArg.STRING_ARRAY, out packages, "Include binding for PACKAGE", "PACKAGE..." }, + { "library", 0, 0, OptionArg.STRING, out library, "Library name", "NAME" }, + { "directory", 'd', 0, OptionArg.FILENAME, out directory, "Output directory", "DIRECTORY" }, + { "version", 0, 0, OptionArg.NONE, ref version, "Display version number", null }, + { "", 0, 0, OptionArg.FILENAME_ARRAY, out sources, null, "FILE..." }, + { null } + }; + + private int quit () { + if (Report.get_errors () == 0) { + stdout.printf ("Generation succeeded - %d warning(s)\n", Report.get_warnings ()); + return 0; + } else { + stdout.printf ("Generation failed: %d error(s), %d warning(s)\n", Report.get_errors (), Report.get_warnings ()); + return 1; + } + } + + private ref string get_package_path (string! pkg) { + var basename = "%s.vala".printf (pkg); + + if (vapi_directories != null) { + foreach (string vapidir in vapi_directories) { + var filename = Path.build_filename (vapidir, basename, null); + if (File.test (filename, FileTest.EXISTS)) { + return filename; + } + } + } + + var filename = Path.build_filename ("/usr/local/share/vala/vapi", basename, null); + if (File.test (filename, FileTest.EXISTS)) { + return filename; + } + + filename = Path.build_filename ("/usr/share/vala/vapi", basename, null); + if (File.test (filename, FileTest.EXISTS)) { + return filename; + } + + return null; + } + + private bool add_package (string! pkg) { + var package_path = get_package_path (pkg); + + if (package_path == null) { + return false; + } + + context.add_source_file (new SourceFile (context, package_path, true)); + + return true; + } + + private int run () { + context = new CodeContext (); + + /* default package */ + if (!add_package ("glib-2.0")) { + Report.error (null, "glib-2.0 not found in specified Vala API directories"); + } + + if (packages != null) { + foreach (string package in packages) { + if (!add_package (package)) { + Report.error (null, "%s not found in specified Vala API directories".printf (package)); + } + } + packages = null; + } + + if (Report.get_errors () > 0) { + return quit (); + } + + foreach (string source in sources) { + if (File.test (source, FileTest.EXISTS)) { + context.add_source_file (new SourceFile (context, source)); + } else { + Report.error (null, "%s not found".printf (source)); + } + } + sources = null; + + if (Report.get_errors () > 0) { + return quit (); + } + + var parser = new Parser (); + parser.parse (context); + + if (Report.get_errors () > 0) { + return quit (); + } + + var gidlparser = new GIdlParser (); + gidlparser.parse (context); + + if (Report.get_errors () > 0) { + return quit (); + } + + var builder = new SymbolBuilder (); + builder.build (context); + + if (Report.get_errors () > 0) { + return quit (); + } + + var attributeprocessor = new AttributeProcessor (); + attributeprocessor.process (context); + + if (Report.get_errors () > 0) { + return quit (); + } + + var resolver = new SymbolResolver (); + resolver.resolve (context); + + if (Report.get_errors () > 0) { + return quit (); + } + + if (library != null) { + var interface_writer = new InterfaceWriter (); + interface_writer.write_file (context, "%s.vala".printf (library)); + + library = null; + } + + return quit (); + } + + static int main (int argc, string[] argv) { + Error err = null; + + var opt_context = new OptionContext ("- Vala API Generator"); + opt_context.set_help_enabled (true); + opt_context.add_main_entries (options, null); + opt_context.parse (ref argc, out argv, out err); + + if (err != null) { + return 1; + } + + if (sources == null) { + stderr.printf ("No source file specified.\n"); + return 1; + } + + var vapigen = new VAPIGen (); + return vapigen.run (); + } +}