From 93d9fe647be1f2effc0bfeeec903b5e030182f6c Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Tue, 27 Jun 2017 12:21:44 +0200 Subject: [PATCH] Prepare valadoc source-tree for merge --- .gitignore | 34 - AUTHORS | 1 - COPYING | 340 ---- ChangeLog | 0 INSTALL | 291 ---- MAINTAINERS | 4 - Makefile.am | 17 - NEWS | 0 README | 0 autogen.sh | 18 - configure.ac | 143 -- doc/Makefile.am | 16 - {src/libvaladoc => libvaladoc}/Makefile.am | 0 {src/libvaladoc => libvaladoc}/api/array.vala | 0 .../api/attribute.vala | 0 .../api/attributeargument.vala | 0 .../api/browsable.vala | 0 .../api/callable.vala | 0 .../api/childsymbolregistrar.vala | 0 {src/libvaladoc => libvaladoc}/api/class.vala | 0 .../api/constant.vala | 0 .../api/delegate.vala | 0 .../libvaladoc => libvaladoc}/api/driver.vala | 0 {src/libvaladoc => libvaladoc}/api/enum.vala | 0 .../api/enumvalue.vala | 0 .../api/errorcode.vala | 0 .../api/errordomain.vala | 0 {src/libvaladoc => libvaladoc}/api/field.vala | 0 .../api/formalparameter.vala | 0 .../api/formalparametertype.vala | 0 .../api/girsourcecomment.vala | 0 .../api/interface.vala | 0 {src/libvaladoc => libvaladoc}/api/item.vala | 0 .../libvaladoc => libvaladoc}/api/member.vala | 0 .../libvaladoc => libvaladoc}/api/method.vala | 0 .../api/methodbindingtype.vala | 0 .../api/namespace.vala | 0 {src/libvaladoc => libvaladoc}/api/node.vala | 0 .../api/nodetype.vala | 0 .../api/ownership.vala | 0 .../api/package.vala | 0 .../api/pointer.vala | 0 .../api/property.vala | 0 .../api/propertyaccessor.vala | 0 .../api/propertyaccessortype.vala | 0 .../api/propertybindingtype.vala | 0 .../libvaladoc => libvaladoc}/api/signal.vala | 0 .../api/signaturebuilder.vala | 0 .../api/sourcecomment.vala | 0 .../api/sourcefile.vala | 0 .../libvaladoc => libvaladoc}/api/struct.vala | 0 .../libvaladoc => libvaladoc}/api/symbol.vala | 0 .../api/symbolaccessibility.vala | 0 {src/libvaladoc => libvaladoc}/api/tree.vala | 0 .../api/typeparameter.vala | 0 .../api/typereference.vala | 0 .../api/typesymbol.vala | 0 .../api/visitor.vala | 0 .../charts/chart.vala | 0 .../charts/chartfactory.vala | 0 .../charts/hierarchychart.vala | 0 .../charts/simplechartfactory.vala | 0 .../content/block.vala | 0 .../content/blockcontent.vala | 0 .../content/comment.vala | 0 .../content/contentelement.vala | 0 .../content/contentfactory.vala | 0 .../content/contentrenderer.vala | 0 .../content/contentvisitor.vala | 0 .../content/embedded.vala | 0 .../content/headline.vala | 0 .../content/inline.vala | 0 .../content/inlinecontent.vala | 0 .../content/inlinetaglet.vala | 0 .../content/link.vala | 0 .../content/list.vala | 0 .../content/listitem.vala | 0 .../content/note.vala | 0 .../content/page.vala | 0 .../content/paragraph.vala | 0 .../content/resourcelocator.vala | 0 .../content/run.vala | 0 .../content/sourcecode.vala | 0 .../content/styleattributes.vala | 0 .../content/symbollink.vala | 0 .../content/table.vala | 0 .../content/tablecell.vala | 0 .../content/tablerow.vala | 0 .../content/taglet.vala | 0 .../content/text.vala | 0 .../content/warning.vala | 0 .../content/wikilink.vala | 0 .../ctyperesolver.vala | 0 .../devhelp-markupwriter.vala | 0 {src/libvaladoc => libvaladoc}/doclet.vala | 0 .../documentation/commentscanner.vala | 0 .../documentation/documentation.vala | 0 .../documentation/documentationparser.vala | 0 .../documentation/girmetadata.vala | 0 .../documentation/gtkdoccommentparser.vala | 0 .../documentation/gtkdoccommentscanner.vala | 0 .../documentation/gtkdocmarkdownparser.vala | 0 .../documentation/gtkdocmarkdownscanner.vala | 0 .../documentation/importerhelper.vala | 0 .../documentation/wiki.vala | 0 .../documentation/wikiscanner.vala | 0 .../errorreporter.vala | 0 .../libvaladoc => libvaladoc}/filehelper.vala | 0 .../gtkdocmarkupwriter.vala | 0 .../gtkdocrenderer.vala | 0 .../highlighter/codescanner.vala | 0 .../highlighter/codetoken.vala | 0 .../highlighter/highlighter.vala | 0 .../highlighter/scanner.vala | 0 .../highlighter/xmlscanner.vala | 0 .../html/basicdoclet.vala | 0 .../html/cssclassresolver.vala | 0 .../html/htmlchartfactory.vala | 0 .../html/htmlmarkupwriter.vala | 0 .../html/htmlrenderer.vala | 0 .../html/linkhelper.vala | 0 .../importer/documentationimporter.vala | 0 .../importer/girdocumentationimporter.vala | 0 .../importer/internalidregistrar.vala | 0 .../valadocdocumentationimporter.vala | 0 .../valadocdocumentationimporterscanner.vala | 0 .../markupreader.vala | 0 .../markupsourcelocation.vala | 0 .../markuptokentype.vala | 0 .../markupwriter.vala | 0 .../moduleloader.vala | 0 .../parser/manyrule.vala | 0 .../parser/oneofrule.vala | 0 .../parser/optionalrule.vala | 0 .../parser/parser.vala | 0 .../parser/parsercallback.vala | 0 .../parser/rule.vala | 0 .../parser/scanner.vala | 0 .../parser/sequencerule.vala | 0 .../parser/sourcelocation.vala | 0 .../parser/stubrule.vala | 0 .../parser/token.vala | 0 .../parser/tokentype.vala | 0 {src/libvaladoc => libvaladoc}/settings.vala | 0 .../taglets/tagletdeprecated.vala | 0 .../taglets/tagletinheritdoc.vala | 0 .../taglets/tagletinit.vala | 0 .../taglets/tagletlink.vala | 0 .../taglets/tagletparam.vala | 0 .../taglets/tagletreturn.vala | 0 .../taglets/tagletsee.vala | 0 .../taglets/tagletsince.vala | 0 .../taglets/tagletthrows.vala | 0 .../valadoc-1.0.deps.in | 0 .../valadoc-1.0.pc.in | 0 src/Makefile.am | 14 - src/driver/0.20.x/Makefile.am | 72 - src/driver/0.20.x/driver.vala | 69 - src/driver/0.20.x/treebuilder.vala | 1524 ---------------- src/driver/0.22.x/Makefile.am | 72 - src/driver/0.22.x/driver.vala | 69 - src/driver/0.22.x/girwriter.vala | 204 --- src/driver/0.22.x/initializerbuilder.vala | 669 ------- src/driver/0.22.x/symbolresolver.vala | 323 ---- src/driver/0.22.x/treebuilder.vala | 1524 ---------------- src/driver/0.24.x/Makefile.am | 72 - src/driver/0.24.x/girwriter.vala | 204 --- src/driver/0.24.x/initializerbuilder.vala | 669 ------- src/driver/0.24.x/symbolresolver.vala | 323 ---- src/driver/0.24.x/treebuilder.vala | 1524 ---------------- src/driver/0.26.x/Makefile.am | 72 - src/driver/0.26.x/driver.vala | 70 - src/driver/0.26.x/girwriter.vala | 204 --- src/driver/0.26.x/initializerbuilder.vala | 669 ------- src/driver/0.26.x/symbolresolver.vala | 323 ---- src/driver/0.26.x/treebuilder.vala | 1524 ---------------- src/driver/0.28.x/Makefile.am | 72 - src/driver/0.28.x/driver.vala | 70 - src/driver/0.28.x/girwriter.vala | 204 --- src/driver/0.28.x/initializerbuilder.vala | 669 ------- src/driver/0.28.x/symbolresolver.vala | 323 ---- src/driver/0.28.x/treebuilder.vala | 1524 ---------------- src/driver/0.30.x/Makefile.am | 72 - src/driver/0.30.x/driver.vala | 70 - src/driver/0.30.x/girwriter.vala | 204 --- src/driver/0.30.x/initializerbuilder.vala | 669 ------- src/driver/0.30.x/symbolresolver.vala | 323 ---- src/driver/0.30.x/treebuilder.vala | 1524 ---------------- src/driver/0.32.x/Makefile.am | 72 - src/driver/0.32.x/driver.vala | 70 - src/driver/0.32.x/girwriter.vala | 204 --- src/driver/0.32.x/initializerbuilder.vala | 669 ------- src/driver/0.32.x/symbolresolver.vala | 323 ---- src/driver/0.32.x/treebuilder.vala | 1541 ----------------- src/driver/0.34.x/Makefile.am | 72 - src/driver/0.34.x/driver.vala | 70 - src/driver/0.34.x/girwriter.vala | 204 --- src/driver/0.34.x/initializerbuilder.vala | 669 ------- src/driver/0.34.x/symbolresolver.vala | 323 ---- src/driver/0.34.x/treebuilder.vala | 1541 ----------------- src/driver/0.36.x/Makefile.am | 72 - src/driver/0.36.x/driver.vala | 70 - src/driver/0.36.x/girwriter.vala | 204 --- src/driver/0.36.x/initializerbuilder.vala | 669 ------- src/driver/0.36.x/symbolresolver.vala | 323 ---- src/driver/Makefile.am | 51 - src/vapi/config.vapi | 21 - src/vapi/libgvc.vapi | 237 --- valadoc.doap | 36 - {src/valadoc => valadoc}/Makefile.am | 0 THANKS => valadoc/THANKS | 0 {src => valadoc}/doclets/Makefile.am | 0 {src => valadoc}/doclets/devhelp/Makefile.am | 0 {src => valadoc}/doclets/devhelp/doclet.vala | 0 {src => valadoc}/doclets/gtkdoc/Makefile.am | 0 .../doclets/gtkdoc/commentconverter.vala | 0 {src => valadoc}/doclets/gtkdoc/dbus.vala | 0 {src => valadoc}/doclets/gtkdoc/doclet.vala | 0 {src => valadoc}/doclets/gtkdoc/gcomment.vala | 0 .../doclets/gtkdoc/generator.vala | 0 {src => valadoc}/doclets/gtkdoc/utils.vala | 0 {src => valadoc}/doclets/html/Makefile.am | 0 {src => valadoc}/doclets/html/doclet.vala | 0 {src/driver/0.24.x => valadoc}/driver.vala | 0 {src/driver/0.20.x => valadoc}/girwriter.vala | 0 {icons => valadoc/icons}/Makefile.am | 0 {icons => valadoc/icons}/abstractclass.png | Bin {icons => valadoc/icons}/abstractmethod.png | Bin {icons => valadoc/icons}/abstractproperty.png | Bin {icons => valadoc/icons}/class.png | Bin {icons => valadoc/icons}/coll_close.png | Bin {icons => valadoc/icons}/coll_open.png | Bin {icons => valadoc/icons}/constant.png | Bin {icons => valadoc/icons}/constructor.png | Bin {icons => valadoc/icons}/delegate.png | Bin {icons => valadoc/icons}/devhelpstyle.css | 0 {icons => valadoc/icons}/enum.png | Bin {icons => valadoc/icons}/enumvalue.png | Bin {icons => valadoc/icons}/errorcode.png | Bin {icons => valadoc/icons}/errordomain.png | Bin {icons => valadoc/icons}/field.png | Bin {icons => valadoc/icons}/interface.png | Bin {icons => valadoc/icons}/method.png | Bin {icons => valadoc/icons}/namespace.png | Bin {icons => valadoc/icons}/package.png | Bin {icons => valadoc/icons}/packages.png | Bin {icons => valadoc/icons}/property.png | Bin {icons => valadoc/icons}/scripts.js | 0 {icons => valadoc/icons}/signal.png | Bin {icons => valadoc/icons}/staticmethod.png | Bin {icons => valadoc/icons}/struct.png | Bin {icons => valadoc/icons}/style.css | 0 {icons => valadoc/icons}/tip.png | Bin {icons => valadoc/icons}/virtualmethod.png | Bin {icons => valadoc/icons}/virtualproperty.png | Bin {icons => valadoc/icons}/warning.png | Bin {icons => valadoc/icons}/wikistyle.css | 0 .../initializerbuilder.vala | 0 .../0.20.x => valadoc}/symbolresolver.vala | 0 {tests => valadoc/tests}/Makefile.am | 0 .../tests}/drivers/api-test.data.vapi | 0 .../tests}/drivers/driver-0-20.vala | 0 .../tests}/drivers/driver-0-22.vala | 0 .../tests}/drivers/driver-0-24.vala | 0 .../tests}/drivers/driver-0-26.vala | 0 .../tests}/drivers/driver-0-28.vala | 0 .../tests}/drivers/driver-0-30.vala | 0 .../tests}/drivers/driver-0-32.vala | 0 .../tests}/drivers/driver-0-34.vala | 0 .../tests}/drivers/driver-0-36.vala | 0 .../tests}/drivers/generic-api-test.vala | 0 .../tests}/libvaladoc/errorreporter.vala | 0 .../tests}/libvaladoc/gtkdoc-scanner.vala | 0 .../tests}/libvaladoc/markupreader.vala | 0 .../libvaladoc/parser/generic-scanner.vala | 0 .../tests}/libvaladoc/parser/manyrule.vala | 0 .../tests}/libvaladoc/parser/oneofrule.vala | 0 .../libvaladoc/parser/optionalrule.vala | 0 .../libvaladoc/parser/sequencerule.vala | 0 .../tests}/libvaladoc/parser/stubrule.vala | 0 {tests => valadoc/tests}/testrunner.sh | 0 .../0.36.x => valadoc}/treebuilder.vala | 0 {src/valadoc => valadoc}/valadoc.vala | 0 283 files changed, 24223 deletions(-) delete mode 100644 .gitignore delete mode 100644 AUTHORS delete mode 100644 COPYING delete mode 100644 ChangeLog delete mode 100644 INSTALL delete mode 100644 MAINTAINERS delete mode 100644 Makefile.am delete mode 100644 NEWS delete mode 100644 README delete mode 100755 autogen.sh delete mode 100644 configure.ac delete mode 100644 doc/Makefile.am rename {src/libvaladoc => libvaladoc}/Makefile.am (100%) rename {src/libvaladoc => libvaladoc}/api/array.vala (100%) rename {src/libvaladoc => libvaladoc}/api/attribute.vala (100%) rename {src/libvaladoc => libvaladoc}/api/attributeargument.vala (100%) rename {src/libvaladoc => libvaladoc}/api/browsable.vala (100%) rename {src/libvaladoc => libvaladoc}/api/callable.vala (100%) rename {src/libvaladoc => libvaladoc}/api/childsymbolregistrar.vala (100%) rename {src/libvaladoc => libvaladoc}/api/class.vala (100%) rename {src/libvaladoc => libvaladoc}/api/constant.vala (100%) rename {src/libvaladoc => libvaladoc}/api/delegate.vala (100%) rename {src/libvaladoc => libvaladoc}/api/driver.vala (100%) rename {src/libvaladoc => libvaladoc}/api/enum.vala (100%) rename {src/libvaladoc => libvaladoc}/api/enumvalue.vala (100%) rename {src/libvaladoc => libvaladoc}/api/errorcode.vala (100%) rename {src/libvaladoc => libvaladoc}/api/errordomain.vala (100%) rename {src/libvaladoc => libvaladoc}/api/field.vala (100%) rename {src/libvaladoc => libvaladoc}/api/formalparameter.vala (100%) rename {src/libvaladoc => libvaladoc}/api/formalparametertype.vala (100%) rename {src/libvaladoc => libvaladoc}/api/girsourcecomment.vala (100%) rename {src/libvaladoc => libvaladoc}/api/interface.vala (100%) rename {src/libvaladoc => libvaladoc}/api/item.vala (100%) rename {src/libvaladoc => libvaladoc}/api/member.vala (100%) rename {src/libvaladoc => libvaladoc}/api/method.vala (100%) rename {src/libvaladoc => libvaladoc}/api/methodbindingtype.vala (100%) rename {src/libvaladoc => libvaladoc}/api/namespace.vala (100%) rename {src/libvaladoc => libvaladoc}/api/node.vala (100%) rename {src/libvaladoc => libvaladoc}/api/nodetype.vala (100%) rename {src/libvaladoc => libvaladoc}/api/ownership.vala (100%) rename {src/libvaladoc => libvaladoc}/api/package.vala (100%) rename {src/libvaladoc => libvaladoc}/api/pointer.vala (100%) rename {src/libvaladoc => libvaladoc}/api/property.vala (100%) rename {src/libvaladoc => libvaladoc}/api/propertyaccessor.vala (100%) rename {src/libvaladoc => libvaladoc}/api/propertyaccessortype.vala (100%) rename {src/libvaladoc => libvaladoc}/api/propertybindingtype.vala (100%) rename {src/libvaladoc => libvaladoc}/api/signal.vala (100%) rename {src/libvaladoc => libvaladoc}/api/signaturebuilder.vala (100%) rename {src/libvaladoc => libvaladoc}/api/sourcecomment.vala (100%) rename {src/libvaladoc => libvaladoc}/api/sourcefile.vala (100%) rename {src/libvaladoc => libvaladoc}/api/struct.vala (100%) rename {src/libvaladoc => libvaladoc}/api/symbol.vala (100%) rename {src/libvaladoc => libvaladoc}/api/symbolaccessibility.vala (100%) rename {src/libvaladoc => libvaladoc}/api/tree.vala (100%) rename {src/libvaladoc => libvaladoc}/api/typeparameter.vala (100%) rename {src/libvaladoc => libvaladoc}/api/typereference.vala (100%) rename {src/libvaladoc => libvaladoc}/api/typesymbol.vala (100%) rename {src/libvaladoc => libvaladoc}/api/visitor.vala (100%) rename {src/libvaladoc => libvaladoc}/charts/chart.vala (100%) rename {src/libvaladoc => libvaladoc}/charts/chartfactory.vala (100%) rename {src/libvaladoc => libvaladoc}/charts/hierarchychart.vala (100%) rename {src/libvaladoc => libvaladoc}/charts/simplechartfactory.vala (100%) rename {src/libvaladoc => libvaladoc}/content/block.vala (100%) rename {src/libvaladoc => libvaladoc}/content/blockcontent.vala (100%) rename {src/libvaladoc => libvaladoc}/content/comment.vala (100%) rename {src/libvaladoc => libvaladoc}/content/contentelement.vala (100%) rename {src/libvaladoc => libvaladoc}/content/contentfactory.vala (100%) rename {src/libvaladoc => libvaladoc}/content/contentrenderer.vala (100%) rename {src/libvaladoc => libvaladoc}/content/contentvisitor.vala (100%) rename {src/libvaladoc => libvaladoc}/content/embedded.vala (100%) rename {src/libvaladoc => libvaladoc}/content/headline.vala (100%) rename {src/libvaladoc => libvaladoc}/content/inline.vala (100%) rename {src/libvaladoc => libvaladoc}/content/inlinecontent.vala (100%) rename {src/libvaladoc => libvaladoc}/content/inlinetaglet.vala (100%) rename {src/libvaladoc => libvaladoc}/content/link.vala (100%) rename {src/libvaladoc => libvaladoc}/content/list.vala (100%) rename {src/libvaladoc => libvaladoc}/content/listitem.vala (100%) rename {src/libvaladoc => libvaladoc}/content/note.vala (100%) rename {src/libvaladoc => libvaladoc}/content/page.vala (100%) rename {src/libvaladoc => libvaladoc}/content/paragraph.vala (100%) rename {src/libvaladoc => libvaladoc}/content/resourcelocator.vala (100%) rename {src/libvaladoc => libvaladoc}/content/run.vala (100%) rename {src/libvaladoc => libvaladoc}/content/sourcecode.vala (100%) rename {src/libvaladoc => libvaladoc}/content/styleattributes.vala (100%) rename {src/libvaladoc => libvaladoc}/content/symbollink.vala (100%) rename {src/libvaladoc => libvaladoc}/content/table.vala (100%) rename {src/libvaladoc => libvaladoc}/content/tablecell.vala (100%) rename {src/libvaladoc => libvaladoc}/content/tablerow.vala (100%) rename {src/libvaladoc => libvaladoc}/content/taglet.vala (100%) rename {src/libvaladoc => libvaladoc}/content/text.vala (100%) rename {src/libvaladoc => libvaladoc}/content/warning.vala (100%) rename {src/libvaladoc => libvaladoc}/content/wikilink.vala (100%) rename {src/libvaladoc => libvaladoc}/ctyperesolver.vala (100%) rename {src/libvaladoc => libvaladoc}/devhelp-markupwriter.vala (100%) rename {src/libvaladoc => libvaladoc}/doclet.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/commentscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/documentation.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/documentationparser.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/girmetadata.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/gtkdoccommentparser.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/gtkdoccommentscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/gtkdocmarkdownparser.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/gtkdocmarkdownscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/importerhelper.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/wiki.vala (100%) rename {src/libvaladoc => libvaladoc}/documentation/wikiscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/errorreporter.vala (100%) rename {src/libvaladoc => libvaladoc}/filehelper.vala (100%) rename {src/libvaladoc => libvaladoc}/gtkdocmarkupwriter.vala (100%) rename {src/libvaladoc => libvaladoc}/gtkdocrenderer.vala (100%) rename {src/libvaladoc => libvaladoc}/highlighter/codescanner.vala (100%) rename {src/libvaladoc => libvaladoc}/highlighter/codetoken.vala (100%) rename {src/libvaladoc => libvaladoc}/highlighter/highlighter.vala (100%) rename {src/libvaladoc => libvaladoc}/highlighter/scanner.vala (100%) rename {src/libvaladoc => libvaladoc}/highlighter/xmlscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/html/basicdoclet.vala (100%) rename {src/libvaladoc => libvaladoc}/html/cssclassresolver.vala (100%) rename {src/libvaladoc => libvaladoc}/html/htmlchartfactory.vala (100%) rename {src/libvaladoc => libvaladoc}/html/htmlmarkupwriter.vala (100%) rename {src/libvaladoc => libvaladoc}/html/htmlrenderer.vala (100%) rename {src/libvaladoc => libvaladoc}/html/linkhelper.vala (100%) rename {src/libvaladoc => libvaladoc}/importer/documentationimporter.vala (100%) rename {src/libvaladoc => libvaladoc}/importer/girdocumentationimporter.vala (100%) rename {src/libvaladoc => libvaladoc}/importer/internalidregistrar.vala (100%) rename {src/libvaladoc => libvaladoc}/importer/valadocdocumentationimporter.vala (100%) rename {src/libvaladoc => libvaladoc}/importer/valadocdocumentationimporterscanner.vala (100%) rename {src/libvaladoc => libvaladoc}/markupreader.vala (100%) rename {src/libvaladoc => libvaladoc}/markupsourcelocation.vala (100%) rename {src/libvaladoc => libvaladoc}/markuptokentype.vala (100%) rename {src/libvaladoc => libvaladoc}/markupwriter.vala (100%) rename {src/libvaladoc => libvaladoc}/moduleloader.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/manyrule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/oneofrule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/optionalrule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/parser.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/parsercallback.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/rule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/scanner.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/sequencerule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/sourcelocation.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/stubrule.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/token.vala (100%) rename {src/libvaladoc => libvaladoc}/parser/tokentype.vala (100%) rename {src/libvaladoc => libvaladoc}/settings.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletdeprecated.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletinheritdoc.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletinit.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletlink.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletparam.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletreturn.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletsee.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletsince.vala (100%) rename {src/libvaladoc => libvaladoc}/taglets/tagletthrows.vala (100%) rename {src/libvaladoc => libvaladoc}/valadoc-1.0.deps.in (100%) rename {src/libvaladoc => libvaladoc}/valadoc-1.0.pc.in (100%) delete mode 100644 src/Makefile.am delete mode 100644 src/driver/0.20.x/Makefile.am delete mode 100644 src/driver/0.20.x/driver.vala delete mode 100644 src/driver/0.20.x/treebuilder.vala delete mode 100644 src/driver/0.22.x/Makefile.am delete mode 100644 src/driver/0.22.x/driver.vala delete mode 100644 src/driver/0.22.x/girwriter.vala delete mode 100644 src/driver/0.22.x/initializerbuilder.vala delete mode 100644 src/driver/0.22.x/symbolresolver.vala delete mode 100644 src/driver/0.22.x/treebuilder.vala delete mode 100644 src/driver/0.24.x/Makefile.am delete mode 100644 src/driver/0.24.x/girwriter.vala delete mode 100644 src/driver/0.24.x/initializerbuilder.vala delete mode 100644 src/driver/0.24.x/symbolresolver.vala delete mode 100644 src/driver/0.24.x/treebuilder.vala delete mode 100644 src/driver/0.26.x/Makefile.am delete mode 100644 src/driver/0.26.x/driver.vala delete mode 100644 src/driver/0.26.x/girwriter.vala delete mode 100644 src/driver/0.26.x/initializerbuilder.vala delete mode 100644 src/driver/0.26.x/symbolresolver.vala delete mode 100644 src/driver/0.26.x/treebuilder.vala delete mode 100644 src/driver/0.28.x/Makefile.am delete mode 100644 src/driver/0.28.x/driver.vala delete mode 100644 src/driver/0.28.x/girwriter.vala delete mode 100644 src/driver/0.28.x/initializerbuilder.vala delete mode 100644 src/driver/0.28.x/symbolresolver.vala delete mode 100644 src/driver/0.28.x/treebuilder.vala delete mode 100644 src/driver/0.30.x/Makefile.am delete mode 100644 src/driver/0.30.x/driver.vala delete mode 100644 src/driver/0.30.x/girwriter.vala delete mode 100644 src/driver/0.30.x/initializerbuilder.vala delete mode 100644 src/driver/0.30.x/symbolresolver.vala delete mode 100644 src/driver/0.30.x/treebuilder.vala delete mode 100644 src/driver/0.32.x/Makefile.am delete mode 100644 src/driver/0.32.x/driver.vala delete mode 100644 src/driver/0.32.x/girwriter.vala delete mode 100644 src/driver/0.32.x/initializerbuilder.vala delete mode 100644 src/driver/0.32.x/symbolresolver.vala delete mode 100644 src/driver/0.32.x/treebuilder.vala delete mode 100644 src/driver/0.34.x/Makefile.am delete mode 100644 src/driver/0.34.x/driver.vala delete mode 100644 src/driver/0.34.x/girwriter.vala delete mode 100644 src/driver/0.34.x/initializerbuilder.vala delete mode 100644 src/driver/0.34.x/symbolresolver.vala delete mode 100644 src/driver/0.34.x/treebuilder.vala delete mode 100644 src/driver/0.36.x/Makefile.am delete mode 100644 src/driver/0.36.x/driver.vala delete mode 100644 src/driver/0.36.x/girwriter.vala delete mode 100644 src/driver/0.36.x/initializerbuilder.vala delete mode 100644 src/driver/0.36.x/symbolresolver.vala delete mode 100644 src/driver/Makefile.am delete mode 100644 src/vapi/config.vapi delete mode 100644 src/vapi/libgvc.vapi delete mode 100644 valadoc.doap rename {src/valadoc => valadoc}/Makefile.am (100%) rename THANKS => valadoc/THANKS (100%) rename {src => valadoc}/doclets/Makefile.am (100%) rename {src => valadoc}/doclets/devhelp/Makefile.am (100%) rename {src => valadoc}/doclets/devhelp/doclet.vala (100%) rename {src => valadoc}/doclets/gtkdoc/Makefile.am (100%) rename {src => valadoc}/doclets/gtkdoc/commentconverter.vala (100%) rename {src => valadoc}/doclets/gtkdoc/dbus.vala (100%) rename {src => valadoc}/doclets/gtkdoc/doclet.vala (100%) rename {src => valadoc}/doclets/gtkdoc/gcomment.vala (100%) rename {src => valadoc}/doclets/gtkdoc/generator.vala (100%) rename {src => valadoc}/doclets/gtkdoc/utils.vala (100%) rename {src => valadoc}/doclets/html/Makefile.am (100%) rename {src => valadoc}/doclets/html/doclet.vala (100%) rename {src/driver/0.24.x => valadoc}/driver.vala (100%) rename {src/driver/0.20.x => valadoc}/girwriter.vala (100%) rename {icons => valadoc/icons}/Makefile.am (100%) rename {icons => valadoc/icons}/abstractclass.png (100%) rename {icons => valadoc/icons}/abstractmethod.png (100%) rename {icons => valadoc/icons}/abstractproperty.png (100%) rename {icons => valadoc/icons}/class.png (100%) rename {icons => valadoc/icons}/coll_close.png (100%) rename {icons => valadoc/icons}/coll_open.png (100%) rename {icons => valadoc/icons}/constant.png (100%) rename {icons => valadoc/icons}/constructor.png (100%) rename {icons => valadoc/icons}/delegate.png (100%) rename {icons => valadoc/icons}/devhelpstyle.css (100%) rename {icons => valadoc/icons}/enum.png (100%) rename {icons => valadoc/icons}/enumvalue.png (100%) rename {icons => valadoc/icons}/errorcode.png (100%) rename {icons => valadoc/icons}/errordomain.png (100%) rename {icons => valadoc/icons}/field.png (100%) rename {icons => valadoc/icons}/interface.png (100%) rename {icons => valadoc/icons}/method.png (100%) rename {icons => valadoc/icons}/namespace.png (100%) rename {icons => valadoc/icons}/package.png (100%) rename {icons => valadoc/icons}/packages.png (100%) rename {icons => valadoc/icons}/property.png (100%) rename {icons => valadoc/icons}/scripts.js (100%) rename {icons => valadoc/icons}/signal.png (100%) rename {icons => valadoc/icons}/staticmethod.png (100%) rename {icons => valadoc/icons}/struct.png (100%) rename {icons => valadoc/icons}/style.css (100%) rename {icons => valadoc/icons}/tip.png (100%) rename {icons => valadoc/icons}/virtualmethod.png (100%) rename {icons => valadoc/icons}/virtualproperty.png (100%) rename {icons => valadoc/icons}/warning.png (100%) rename {icons => valadoc/icons}/wikistyle.css (100%) rename {src/driver/0.20.x => valadoc}/initializerbuilder.vala (100%) rename {src/driver/0.20.x => valadoc}/symbolresolver.vala (100%) rename {tests => valadoc/tests}/Makefile.am (100%) rename {tests => valadoc/tests}/drivers/api-test.data.vapi (100%) rename {tests => valadoc/tests}/drivers/driver-0-20.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-22.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-24.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-26.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-28.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-30.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-32.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-34.vala (100%) rename {tests => valadoc/tests}/drivers/driver-0-36.vala (100%) rename {tests => valadoc/tests}/drivers/generic-api-test.vala (100%) rename {tests => valadoc/tests}/libvaladoc/errorreporter.vala (100%) rename {tests => valadoc/tests}/libvaladoc/gtkdoc-scanner.vala (100%) rename {tests => valadoc/tests}/libvaladoc/markupreader.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/generic-scanner.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/manyrule.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/oneofrule.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/optionalrule.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/sequencerule.vala (100%) rename {tests => valadoc/tests}/libvaladoc/parser/stubrule.vala (100%) rename {tests => valadoc/tests}/testrunner.sh (100%) rename {src/driver/0.36.x => valadoc}/treebuilder.vala (100%) rename {src/valadoc => valadoc}/valadoc.vala (100%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b31f516bf..000000000 --- a/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -Makefile.in -Makefile -*~ -*.o -*.lo -*.la -*.c -*.h -*.stamp -*.gir -*.vapi -*.deps -.deps -.libs -.dirstamp - -config.* -aclocal.m4 -autom4te.cache -build-aux -ChangeLog -configure -depcomp -libtool -install-sh -m4 -missing -ltmain.sh -ylwrap -compile -stamp-h1 -*.pc - -src/valadoc/valadoc diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 00dc670ea..000000000 --- a/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Florian Brosch diff --git a/COPYING b/COPYING deleted file mode 100644 index 08ddefd04..000000000 --- a/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 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. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, 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 or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -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 give any other recipients of the Program a copy of this License -along with the Program. - -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 Program or any portion -of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -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 Program, 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 Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) 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; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, 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 executable. However, as a -special exception, the source code 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. - -If distribution of executable or 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 counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program 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. - - 5. 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 Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program 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 to -this License. - - 7. 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 Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program 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 Program. - -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. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program 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. - - 9. The Free Software Foundation may publish revised and/or new versions -of the 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 Program -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 Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, 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 - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), 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 Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. 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 program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. - diff --git a/ChangeLog b/ChangeLog deleted file mode 100644 index e69de29bb..000000000 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 8b82ade08..000000000 --- a/INSTALL +++ /dev/null @@ -1,291 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006, 2007, 2008 Free Software Foundation, Inc. - - This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - - Briefly, the shell commands `./configure; make; make install' should -configure, build, and install this package. The following -more-detailed instructions are generic; see the `README' file for -instructions specific to this package. - - 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 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. - - Running `configure' might take a while. 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. - - 6. Often, you can also type `make uninstall' to remove the installed - files again. - -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=c99 CFLAGS=-g 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 can use 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 `..'. - - With a non-GNU `make', it is safer 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. - - On MacOS X 10.5 and later systems, you can create libraries and -executables that work on multiple system types--known as "fat" or -"universal" binaries--by specifying multiple `-arch' options to the -compiler but only a single `-arch' option to the preprocessor. Like -this: - - ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ - CPP="gcc -E" CXXCPP="g++ -E" - - This is not guaranteed to produce working output in all cases, you -may have to build one architecture at a time and combine the results -using the `lipo' tool if you have problems. - -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. - -Particular systems -================== - - On HP-UX, the default C compiler is not ANSI C compatible. If GNU -CC is not installed, it is recommended to use the following options in -order to use an ANSI C compiler: - - ./configure CC="cc -Ae" - -and if that doesn't work, install pre-built binaries of GCC for HP-UX. - - On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot -parse its `' header file. The option `-nodtk' can be used as -a workaround. If GNU CC is not installed, it is therefore recommended -to try - - ./configure CC="cc" - -and if that doesn't work, try - - ./configure CC="cc -nodtk" - -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). - -Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: - - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash - -`configure' Invocation -====================== - - `configure' recognizes the following options to control how it -operates. - -`--help' -`-h' - Print a summary of all of the options to `configure', and exit. - -`--help=short' -`--help=recursive' - Print a summary of the options unique to this package's - `configure', and exit. The `short' variant lists options used - only in the top level, while the `recursive' variant lists options - also present in any nested packages. - -`--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. - -`--prefix=DIR' - Use DIR as the installation prefix. *Note Installation Names:: - for more details, including other options available for fine-tuning - the installation locations. - -`--no-create' -`-n' - Run the configure checks, but stop before creating any output - files. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - diff --git a/MAINTAINERS b/MAINTAINERS deleted file mode 100644 index 53f5dc2ee..000000000 --- a/MAINTAINERS +++ /dev/null @@ -1,4 +0,0 @@ -Florian Brosch -E-mail: flo.brosch@gmail.com -Userid: flobrosch - diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 0c214ce72..000000000 --- a/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -# Makefile.am - -NULL = - -ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} - -SUBDIRS = src \ - tests \ - icons \ - doc \ - $(NULL) - - -.PHONY: test -test: - cd tests && $(MAKE) $(AM_MAKEFLAGS) check - diff --git a/NEWS b/NEWS deleted file mode 100644 index e69de29bb..000000000 diff --git a/README b/README deleted file mode 100644 index e69de29bb..000000000 diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index 944efd33b..000000000 --- a/autogen.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -test -n "$srcdir" || srcdir=`dirname "$0"` -test -n "$srcdir" || srcdir=. - -olddir=`pwd` -cd $srcdir - -AUTORECONF=`which autoreconf` -if test -z $AUTORECONF; then - echo "*** No autoreconf found, please install it ***" - exit 1 -fi - -autoreconf --force --install --verbose - -cd $olddir -test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/configure.ac b/configure.ac deleted file mode 100644 index ceeba4062..000000000 --- a/configure.ac +++ /dev/null @@ -1,143 +0,0 @@ -dnl configure.in -AC_PREREQ([2.65]) -AC_INIT([valadoc],[0.36.0], - [https://bugzilla.gnome.org/browse.cgi?product=valadoc], - [valadoc], - [https://wiki.gnome.org/Projects/Valadoc]) - -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_SRCDIR([Makefile.am]) -AC_CONFIG_HEADERS(config.h) -AC_CONFIG_SRCDIR([configure.ac]) -AM_INIT_AUTOMAKE([1.11 foreign tar-ustar dist-xz no-dist-gzip subdir-objects]) - -AM_MAINTAINER_MODE([enable]) - -AC_PROG_CC -AC_PROG_INSTALL -LT_INIT([disable-static]) -PKG_PROG_PKG_CONFIG([0.21]) - -AC_CHECK_PROG([HELP2MAN], [help2man], [help2man]) -AM_CONDITIONAL([HAVE_HELP2MAN], [test x$HELP2MAN = xhelp2man]) - -## -## Settings: -## - -VALA_REQUIRED=0.19.0 -LIBGEE_REQUIRED=0.19.91 -LIBGVC_REQUIRED=2.16 -GLIB_REQUIRED=2.24.0 -LIBGDKPIXBUF_REQUIRED=2.0 - - - -## -## Dependencies: -## - -AC_SUBST(VALAFLAGS) -AM_PROG_VALAC([$VALA_REQUIRED]) - -PKG_CHECK_MODULES(LIBGVC, libgvc >= $LIBGVC_REQUIRED) - -PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED) - -PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= $GLIB_REQUIRED) - -PKG_CHECK_MODULES(LIBGEE, gee-0.8 >= $LIBGEE_REQUIRED) - - -AC_MSG_CHECKING([for CGRAPH]) -valadoc_tmp_LIBADD="$LIBADD" -valadoc_tmp_CFLAGS="$CFLAGS" -LIBADD="$LIBADD $LIBGVC_LIBS" -CFLAGS="$CFLAGS $LIBGVC_CFLAGS" -AC_RUN_IFELSE( - [AC_LANG_SOURCE([ - #include - - int main(void) { - #ifdef WITH_CGRAPH - return 0; - #else - return -1; - #endif - } - ])], [ - AC_MSG_RESULT([yes]) - VALAFLAGS="$VALAFLAGS -D WITH_CGRAPH" - have_cgraph=yes - ], [ - AC_MSG_RESULT([no]) - have_cgraph=no - ] -) -LIBADD="$valadoc_tmp_LIBADD" -CFLAGS="$valadoc_tmp_CFLAGS" -AM_CONDITIONAL(HAVE_CGRAPH, test "$have_cgraph" = "yes") - - -## -## Drivers: -## - -PKG_CHECK_MODULES(LIBVALA_0_36_X, libvala-0.36 > 0.35.0, have_libvala_0_36_x="yes", have_libvala_0_36_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_36_X, test "$have_libvala_0_36_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_34_X, libvala-0.34 > 0.33.0, have_libvala_0_34_x="yes", have_libvala_0_34_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_34_X, test "$have_libvala_0_34_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_32_X, libvala-0.32 > 0.31.0, have_libvala_0_32_x="yes", have_libvala_0_32_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_32_X, test "$have_libvala_0_32_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_30_X, libvala-0.30 > 0.29.0, have_libvala_0_30_x="yes", have_libvala_0_30_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_30_X, test "$have_libvala_0_30_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_28_X, libvala-0.28 > 0.27.0, have_libvala_0_28_x="yes", have_libvala_0_28_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_28_X, test "$have_libvala_0_28_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_26_X, libvala-0.26 > 0.25.2, have_libvala_0_26_x="yes", have_libvala_0_26_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_26_X, test "$have_libvala_0_26_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_24_X, libvala-0.24 > 0.23.1, have_libvala_0_24_x="yes", have_libvala_0_24_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_24_X, test "$have_libvala_0_24_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_22_X, libvala-0.22 >= 0.21.0, have_libvala_0_22_x="yes", have_libvala_0_22_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_22_X, test "$have_libvala_0_22_x" = "yes") - -PKG_CHECK_MODULES(LIBVALA_0_20_X, libvala-0.20 >= 0.19.0, have_libvala_0_20_x="yes", have_libvala_0_20_x="no") -AM_CONDITIONAL(HAVE_LIBVALA_0_20_X, test "$have_libvala_0_20_x" = "yes") - - -AC_CONFIG_FILES([ -Makefile -src/libvaladoc/valadoc-1.0.pc -src/libvaladoc/valadoc-1.0.deps -src/Makefile -icons/Makefile -doc/Makefile -src/libvaladoc/Makefile -src/driver/Makefile -src/driver/0.20.x/Makefile -src/driver/0.22.x/Makefile -src/driver/0.24.x/Makefile -src/driver/0.26.x/Makefile -src/driver/0.28.x/Makefile -src/driver/0.30.x/Makefile -src/driver/0.32.x/Makefile -src/driver/0.34.x/Makefile -src/driver/0.36.x/Makefile -src/doclets/Makefile -src/doclets/html/Makefile -src/doclets/devhelp/Makefile -src/doclets/gtkdoc/Makefile -src/valadoc/Makefile -tests/Makefile -]) - -AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 2ae874a5a..000000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -dist_man_MANS = valadoc.1 - -EXTRA_DIST = valadoc.h2m - -if HAVE_HELP2MAN -manpages: valadoc.1 - @rm $^ - $(MAKE) $(AM_MAKEFLAGS) $^ - -valadoc.1: - $(HELP2MAN) $(top_builddir)/src/valadoc/valadoc \ - --include $(srcdir)/valadoc.h2m \ - --libtool --no-info \ - --output=$@ -endif - diff --git a/src/libvaladoc/Makefile.am b/libvaladoc/Makefile.am similarity index 100% rename from src/libvaladoc/Makefile.am rename to libvaladoc/Makefile.am diff --git a/src/libvaladoc/api/array.vala b/libvaladoc/api/array.vala similarity index 100% rename from src/libvaladoc/api/array.vala rename to libvaladoc/api/array.vala diff --git a/src/libvaladoc/api/attribute.vala b/libvaladoc/api/attribute.vala similarity index 100% rename from src/libvaladoc/api/attribute.vala rename to libvaladoc/api/attribute.vala diff --git a/src/libvaladoc/api/attributeargument.vala b/libvaladoc/api/attributeargument.vala similarity index 100% rename from src/libvaladoc/api/attributeargument.vala rename to libvaladoc/api/attributeargument.vala diff --git a/src/libvaladoc/api/browsable.vala b/libvaladoc/api/browsable.vala similarity index 100% rename from src/libvaladoc/api/browsable.vala rename to libvaladoc/api/browsable.vala diff --git a/src/libvaladoc/api/callable.vala b/libvaladoc/api/callable.vala similarity index 100% rename from src/libvaladoc/api/callable.vala rename to libvaladoc/api/callable.vala diff --git a/src/libvaladoc/api/childsymbolregistrar.vala b/libvaladoc/api/childsymbolregistrar.vala similarity index 100% rename from src/libvaladoc/api/childsymbolregistrar.vala rename to libvaladoc/api/childsymbolregistrar.vala diff --git a/src/libvaladoc/api/class.vala b/libvaladoc/api/class.vala similarity index 100% rename from src/libvaladoc/api/class.vala rename to libvaladoc/api/class.vala diff --git a/src/libvaladoc/api/constant.vala b/libvaladoc/api/constant.vala similarity index 100% rename from src/libvaladoc/api/constant.vala rename to libvaladoc/api/constant.vala diff --git a/src/libvaladoc/api/delegate.vala b/libvaladoc/api/delegate.vala similarity index 100% rename from src/libvaladoc/api/delegate.vala rename to libvaladoc/api/delegate.vala diff --git a/src/libvaladoc/api/driver.vala b/libvaladoc/api/driver.vala similarity index 100% rename from src/libvaladoc/api/driver.vala rename to libvaladoc/api/driver.vala diff --git a/src/libvaladoc/api/enum.vala b/libvaladoc/api/enum.vala similarity index 100% rename from src/libvaladoc/api/enum.vala rename to libvaladoc/api/enum.vala diff --git a/src/libvaladoc/api/enumvalue.vala b/libvaladoc/api/enumvalue.vala similarity index 100% rename from src/libvaladoc/api/enumvalue.vala rename to libvaladoc/api/enumvalue.vala diff --git a/src/libvaladoc/api/errorcode.vala b/libvaladoc/api/errorcode.vala similarity index 100% rename from src/libvaladoc/api/errorcode.vala rename to libvaladoc/api/errorcode.vala diff --git a/src/libvaladoc/api/errordomain.vala b/libvaladoc/api/errordomain.vala similarity index 100% rename from src/libvaladoc/api/errordomain.vala rename to libvaladoc/api/errordomain.vala diff --git a/src/libvaladoc/api/field.vala b/libvaladoc/api/field.vala similarity index 100% rename from src/libvaladoc/api/field.vala rename to libvaladoc/api/field.vala diff --git a/src/libvaladoc/api/formalparameter.vala b/libvaladoc/api/formalparameter.vala similarity index 100% rename from src/libvaladoc/api/formalparameter.vala rename to libvaladoc/api/formalparameter.vala diff --git a/src/libvaladoc/api/formalparametertype.vala b/libvaladoc/api/formalparametertype.vala similarity index 100% rename from src/libvaladoc/api/formalparametertype.vala rename to libvaladoc/api/formalparametertype.vala diff --git a/src/libvaladoc/api/girsourcecomment.vala b/libvaladoc/api/girsourcecomment.vala similarity index 100% rename from src/libvaladoc/api/girsourcecomment.vala rename to libvaladoc/api/girsourcecomment.vala diff --git a/src/libvaladoc/api/interface.vala b/libvaladoc/api/interface.vala similarity index 100% rename from src/libvaladoc/api/interface.vala rename to libvaladoc/api/interface.vala diff --git a/src/libvaladoc/api/item.vala b/libvaladoc/api/item.vala similarity index 100% rename from src/libvaladoc/api/item.vala rename to libvaladoc/api/item.vala diff --git a/src/libvaladoc/api/member.vala b/libvaladoc/api/member.vala similarity index 100% rename from src/libvaladoc/api/member.vala rename to libvaladoc/api/member.vala diff --git a/src/libvaladoc/api/method.vala b/libvaladoc/api/method.vala similarity index 100% rename from src/libvaladoc/api/method.vala rename to libvaladoc/api/method.vala diff --git a/src/libvaladoc/api/methodbindingtype.vala b/libvaladoc/api/methodbindingtype.vala similarity index 100% rename from src/libvaladoc/api/methodbindingtype.vala rename to libvaladoc/api/methodbindingtype.vala diff --git a/src/libvaladoc/api/namespace.vala b/libvaladoc/api/namespace.vala similarity index 100% rename from src/libvaladoc/api/namespace.vala rename to libvaladoc/api/namespace.vala diff --git a/src/libvaladoc/api/node.vala b/libvaladoc/api/node.vala similarity index 100% rename from src/libvaladoc/api/node.vala rename to libvaladoc/api/node.vala diff --git a/src/libvaladoc/api/nodetype.vala b/libvaladoc/api/nodetype.vala similarity index 100% rename from src/libvaladoc/api/nodetype.vala rename to libvaladoc/api/nodetype.vala diff --git a/src/libvaladoc/api/ownership.vala b/libvaladoc/api/ownership.vala similarity index 100% rename from src/libvaladoc/api/ownership.vala rename to libvaladoc/api/ownership.vala diff --git a/src/libvaladoc/api/package.vala b/libvaladoc/api/package.vala similarity index 100% rename from src/libvaladoc/api/package.vala rename to libvaladoc/api/package.vala diff --git a/src/libvaladoc/api/pointer.vala b/libvaladoc/api/pointer.vala similarity index 100% rename from src/libvaladoc/api/pointer.vala rename to libvaladoc/api/pointer.vala diff --git a/src/libvaladoc/api/property.vala b/libvaladoc/api/property.vala similarity index 100% rename from src/libvaladoc/api/property.vala rename to libvaladoc/api/property.vala diff --git a/src/libvaladoc/api/propertyaccessor.vala b/libvaladoc/api/propertyaccessor.vala similarity index 100% rename from src/libvaladoc/api/propertyaccessor.vala rename to libvaladoc/api/propertyaccessor.vala diff --git a/src/libvaladoc/api/propertyaccessortype.vala b/libvaladoc/api/propertyaccessortype.vala similarity index 100% rename from src/libvaladoc/api/propertyaccessortype.vala rename to libvaladoc/api/propertyaccessortype.vala diff --git a/src/libvaladoc/api/propertybindingtype.vala b/libvaladoc/api/propertybindingtype.vala similarity index 100% rename from src/libvaladoc/api/propertybindingtype.vala rename to libvaladoc/api/propertybindingtype.vala diff --git a/src/libvaladoc/api/signal.vala b/libvaladoc/api/signal.vala similarity index 100% rename from src/libvaladoc/api/signal.vala rename to libvaladoc/api/signal.vala diff --git a/src/libvaladoc/api/signaturebuilder.vala b/libvaladoc/api/signaturebuilder.vala similarity index 100% rename from src/libvaladoc/api/signaturebuilder.vala rename to libvaladoc/api/signaturebuilder.vala diff --git a/src/libvaladoc/api/sourcecomment.vala b/libvaladoc/api/sourcecomment.vala similarity index 100% rename from src/libvaladoc/api/sourcecomment.vala rename to libvaladoc/api/sourcecomment.vala diff --git a/src/libvaladoc/api/sourcefile.vala b/libvaladoc/api/sourcefile.vala similarity index 100% rename from src/libvaladoc/api/sourcefile.vala rename to libvaladoc/api/sourcefile.vala diff --git a/src/libvaladoc/api/struct.vala b/libvaladoc/api/struct.vala similarity index 100% rename from src/libvaladoc/api/struct.vala rename to libvaladoc/api/struct.vala diff --git a/src/libvaladoc/api/symbol.vala b/libvaladoc/api/symbol.vala similarity index 100% rename from src/libvaladoc/api/symbol.vala rename to libvaladoc/api/symbol.vala diff --git a/src/libvaladoc/api/symbolaccessibility.vala b/libvaladoc/api/symbolaccessibility.vala similarity index 100% rename from src/libvaladoc/api/symbolaccessibility.vala rename to libvaladoc/api/symbolaccessibility.vala diff --git a/src/libvaladoc/api/tree.vala b/libvaladoc/api/tree.vala similarity index 100% rename from src/libvaladoc/api/tree.vala rename to libvaladoc/api/tree.vala diff --git a/src/libvaladoc/api/typeparameter.vala b/libvaladoc/api/typeparameter.vala similarity index 100% rename from src/libvaladoc/api/typeparameter.vala rename to libvaladoc/api/typeparameter.vala diff --git a/src/libvaladoc/api/typereference.vala b/libvaladoc/api/typereference.vala similarity index 100% rename from src/libvaladoc/api/typereference.vala rename to libvaladoc/api/typereference.vala diff --git a/src/libvaladoc/api/typesymbol.vala b/libvaladoc/api/typesymbol.vala similarity index 100% rename from src/libvaladoc/api/typesymbol.vala rename to libvaladoc/api/typesymbol.vala diff --git a/src/libvaladoc/api/visitor.vala b/libvaladoc/api/visitor.vala similarity index 100% rename from src/libvaladoc/api/visitor.vala rename to libvaladoc/api/visitor.vala diff --git a/src/libvaladoc/charts/chart.vala b/libvaladoc/charts/chart.vala similarity index 100% rename from src/libvaladoc/charts/chart.vala rename to libvaladoc/charts/chart.vala diff --git a/src/libvaladoc/charts/chartfactory.vala b/libvaladoc/charts/chartfactory.vala similarity index 100% rename from src/libvaladoc/charts/chartfactory.vala rename to libvaladoc/charts/chartfactory.vala diff --git a/src/libvaladoc/charts/hierarchychart.vala b/libvaladoc/charts/hierarchychart.vala similarity index 100% rename from src/libvaladoc/charts/hierarchychart.vala rename to libvaladoc/charts/hierarchychart.vala diff --git a/src/libvaladoc/charts/simplechartfactory.vala b/libvaladoc/charts/simplechartfactory.vala similarity index 100% rename from src/libvaladoc/charts/simplechartfactory.vala rename to libvaladoc/charts/simplechartfactory.vala diff --git a/src/libvaladoc/content/block.vala b/libvaladoc/content/block.vala similarity index 100% rename from src/libvaladoc/content/block.vala rename to libvaladoc/content/block.vala diff --git a/src/libvaladoc/content/blockcontent.vala b/libvaladoc/content/blockcontent.vala similarity index 100% rename from src/libvaladoc/content/blockcontent.vala rename to libvaladoc/content/blockcontent.vala diff --git a/src/libvaladoc/content/comment.vala b/libvaladoc/content/comment.vala similarity index 100% rename from src/libvaladoc/content/comment.vala rename to libvaladoc/content/comment.vala diff --git a/src/libvaladoc/content/contentelement.vala b/libvaladoc/content/contentelement.vala similarity index 100% rename from src/libvaladoc/content/contentelement.vala rename to libvaladoc/content/contentelement.vala diff --git a/src/libvaladoc/content/contentfactory.vala b/libvaladoc/content/contentfactory.vala similarity index 100% rename from src/libvaladoc/content/contentfactory.vala rename to libvaladoc/content/contentfactory.vala diff --git a/src/libvaladoc/content/contentrenderer.vala b/libvaladoc/content/contentrenderer.vala similarity index 100% rename from src/libvaladoc/content/contentrenderer.vala rename to libvaladoc/content/contentrenderer.vala diff --git a/src/libvaladoc/content/contentvisitor.vala b/libvaladoc/content/contentvisitor.vala similarity index 100% rename from src/libvaladoc/content/contentvisitor.vala rename to libvaladoc/content/contentvisitor.vala diff --git a/src/libvaladoc/content/embedded.vala b/libvaladoc/content/embedded.vala similarity index 100% rename from src/libvaladoc/content/embedded.vala rename to libvaladoc/content/embedded.vala diff --git a/src/libvaladoc/content/headline.vala b/libvaladoc/content/headline.vala similarity index 100% rename from src/libvaladoc/content/headline.vala rename to libvaladoc/content/headline.vala diff --git a/src/libvaladoc/content/inline.vala b/libvaladoc/content/inline.vala similarity index 100% rename from src/libvaladoc/content/inline.vala rename to libvaladoc/content/inline.vala diff --git a/src/libvaladoc/content/inlinecontent.vala b/libvaladoc/content/inlinecontent.vala similarity index 100% rename from src/libvaladoc/content/inlinecontent.vala rename to libvaladoc/content/inlinecontent.vala diff --git a/src/libvaladoc/content/inlinetaglet.vala b/libvaladoc/content/inlinetaglet.vala similarity index 100% rename from src/libvaladoc/content/inlinetaglet.vala rename to libvaladoc/content/inlinetaglet.vala diff --git a/src/libvaladoc/content/link.vala b/libvaladoc/content/link.vala similarity index 100% rename from src/libvaladoc/content/link.vala rename to libvaladoc/content/link.vala diff --git a/src/libvaladoc/content/list.vala b/libvaladoc/content/list.vala similarity index 100% rename from src/libvaladoc/content/list.vala rename to libvaladoc/content/list.vala diff --git a/src/libvaladoc/content/listitem.vala b/libvaladoc/content/listitem.vala similarity index 100% rename from src/libvaladoc/content/listitem.vala rename to libvaladoc/content/listitem.vala diff --git a/src/libvaladoc/content/note.vala b/libvaladoc/content/note.vala similarity index 100% rename from src/libvaladoc/content/note.vala rename to libvaladoc/content/note.vala diff --git a/src/libvaladoc/content/page.vala b/libvaladoc/content/page.vala similarity index 100% rename from src/libvaladoc/content/page.vala rename to libvaladoc/content/page.vala diff --git a/src/libvaladoc/content/paragraph.vala b/libvaladoc/content/paragraph.vala similarity index 100% rename from src/libvaladoc/content/paragraph.vala rename to libvaladoc/content/paragraph.vala diff --git a/src/libvaladoc/content/resourcelocator.vala b/libvaladoc/content/resourcelocator.vala similarity index 100% rename from src/libvaladoc/content/resourcelocator.vala rename to libvaladoc/content/resourcelocator.vala diff --git a/src/libvaladoc/content/run.vala b/libvaladoc/content/run.vala similarity index 100% rename from src/libvaladoc/content/run.vala rename to libvaladoc/content/run.vala diff --git a/src/libvaladoc/content/sourcecode.vala b/libvaladoc/content/sourcecode.vala similarity index 100% rename from src/libvaladoc/content/sourcecode.vala rename to libvaladoc/content/sourcecode.vala diff --git a/src/libvaladoc/content/styleattributes.vala b/libvaladoc/content/styleattributes.vala similarity index 100% rename from src/libvaladoc/content/styleattributes.vala rename to libvaladoc/content/styleattributes.vala diff --git a/src/libvaladoc/content/symbollink.vala b/libvaladoc/content/symbollink.vala similarity index 100% rename from src/libvaladoc/content/symbollink.vala rename to libvaladoc/content/symbollink.vala diff --git a/src/libvaladoc/content/table.vala b/libvaladoc/content/table.vala similarity index 100% rename from src/libvaladoc/content/table.vala rename to libvaladoc/content/table.vala diff --git a/src/libvaladoc/content/tablecell.vala b/libvaladoc/content/tablecell.vala similarity index 100% rename from src/libvaladoc/content/tablecell.vala rename to libvaladoc/content/tablecell.vala diff --git a/src/libvaladoc/content/tablerow.vala b/libvaladoc/content/tablerow.vala similarity index 100% rename from src/libvaladoc/content/tablerow.vala rename to libvaladoc/content/tablerow.vala diff --git a/src/libvaladoc/content/taglet.vala b/libvaladoc/content/taglet.vala similarity index 100% rename from src/libvaladoc/content/taglet.vala rename to libvaladoc/content/taglet.vala diff --git a/src/libvaladoc/content/text.vala b/libvaladoc/content/text.vala similarity index 100% rename from src/libvaladoc/content/text.vala rename to libvaladoc/content/text.vala diff --git a/src/libvaladoc/content/warning.vala b/libvaladoc/content/warning.vala similarity index 100% rename from src/libvaladoc/content/warning.vala rename to libvaladoc/content/warning.vala diff --git a/src/libvaladoc/content/wikilink.vala b/libvaladoc/content/wikilink.vala similarity index 100% rename from src/libvaladoc/content/wikilink.vala rename to libvaladoc/content/wikilink.vala diff --git a/src/libvaladoc/ctyperesolver.vala b/libvaladoc/ctyperesolver.vala similarity index 100% rename from src/libvaladoc/ctyperesolver.vala rename to libvaladoc/ctyperesolver.vala diff --git a/src/libvaladoc/devhelp-markupwriter.vala b/libvaladoc/devhelp-markupwriter.vala similarity index 100% rename from src/libvaladoc/devhelp-markupwriter.vala rename to libvaladoc/devhelp-markupwriter.vala diff --git a/src/libvaladoc/doclet.vala b/libvaladoc/doclet.vala similarity index 100% rename from src/libvaladoc/doclet.vala rename to libvaladoc/doclet.vala diff --git a/src/libvaladoc/documentation/commentscanner.vala b/libvaladoc/documentation/commentscanner.vala similarity index 100% rename from src/libvaladoc/documentation/commentscanner.vala rename to libvaladoc/documentation/commentscanner.vala diff --git a/src/libvaladoc/documentation/documentation.vala b/libvaladoc/documentation/documentation.vala similarity index 100% rename from src/libvaladoc/documentation/documentation.vala rename to libvaladoc/documentation/documentation.vala diff --git a/src/libvaladoc/documentation/documentationparser.vala b/libvaladoc/documentation/documentationparser.vala similarity index 100% rename from src/libvaladoc/documentation/documentationparser.vala rename to libvaladoc/documentation/documentationparser.vala diff --git a/src/libvaladoc/documentation/girmetadata.vala b/libvaladoc/documentation/girmetadata.vala similarity index 100% rename from src/libvaladoc/documentation/girmetadata.vala rename to libvaladoc/documentation/girmetadata.vala diff --git a/src/libvaladoc/documentation/gtkdoccommentparser.vala b/libvaladoc/documentation/gtkdoccommentparser.vala similarity index 100% rename from src/libvaladoc/documentation/gtkdoccommentparser.vala rename to libvaladoc/documentation/gtkdoccommentparser.vala diff --git a/src/libvaladoc/documentation/gtkdoccommentscanner.vala b/libvaladoc/documentation/gtkdoccommentscanner.vala similarity index 100% rename from src/libvaladoc/documentation/gtkdoccommentscanner.vala rename to libvaladoc/documentation/gtkdoccommentscanner.vala diff --git a/src/libvaladoc/documentation/gtkdocmarkdownparser.vala b/libvaladoc/documentation/gtkdocmarkdownparser.vala similarity index 100% rename from src/libvaladoc/documentation/gtkdocmarkdownparser.vala rename to libvaladoc/documentation/gtkdocmarkdownparser.vala diff --git a/src/libvaladoc/documentation/gtkdocmarkdownscanner.vala b/libvaladoc/documentation/gtkdocmarkdownscanner.vala similarity index 100% rename from src/libvaladoc/documentation/gtkdocmarkdownscanner.vala rename to libvaladoc/documentation/gtkdocmarkdownscanner.vala diff --git a/src/libvaladoc/documentation/importerhelper.vala b/libvaladoc/documentation/importerhelper.vala similarity index 100% rename from src/libvaladoc/documentation/importerhelper.vala rename to libvaladoc/documentation/importerhelper.vala diff --git a/src/libvaladoc/documentation/wiki.vala b/libvaladoc/documentation/wiki.vala similarity index 100% rename from src/libvaladoc/documentation/wiki.vala rename to libvaladoc/documentation/wiki.vala diff --git a/src/libvaladoc/documentation/wikiscanner.vala b/libvaladoc/documentation/wikiscanner.vala similarity index 100% rename from src/libvaladoc/documentation/wikiscanner.vala rename to libvaladoc/documentation/wikiscanner.vala diff --git a/src/libvaladoc/errorreporter.vala b/libvaladoc/errorreporter.vala similarity index 100% rename from src/libvaladoc/errorreporter.vala rename to libvaladoc/errorreporter.vala diff --git a/src/libvaladoc/filehelper.vala b/libvaladoc/filehelper.vala similarity index 100% rename from src/libvaladoc/filehelper.vala rename to libvaladoc/filehelper.vala diff --git a/src/libvaladoc/gtkdocmarkupwriter.vala b/libvaladoc/gtkdocmarkupwriter.vala similarity index 100% rename from src/libvaladoc/gtkdocmarkupwriter.vala rename to libvaladoc/gtkdocmarkupwriter.vala diff --git a/src/libvaladoc/gtkdocrenderer.vala b/libvaladoc/gtkdocrenderer.vala similarity index 100% rename from src/libvaladoc/gtkdocrenderer.vala rename to libvaladoc/gtkdocrenderer.vala diff --git a/src/libvaladoc/highlighter/codescanner.vala b/libvaladoc/highlighter/codescanner.vala similarity index 100% rename from src/libvaladoc/highlighter/codescanner.vala rename to libvaladoc/highlighter/codescanner.vala diff --git a/src/libvaladoc/highlighter/codetoken.vala b/libvaladoc/highlighter/codetoken.vala similarity index 100% rename from src/libvaladoc/highlighter/codetoken.vala rename to libvaladoc/highlighter/codetoken.vala diff --git a/src/libvaladoc/highlighter/highlighter.vala b/libvaladoc/highlighter/highlighter.vala similarity index 100% rename from src/libvaladoc/highlighter/highlighter.vala rename to libvaladoc/highlighter/highlighter.vala diff --git a/src/libvaladoc/highlighter/scanner.vala b/libvaladoc/highlighter/scanner.vala similarity index 100% rename from src/libvaladoc/highlighter/scanner.vala rename to libvaladoc/highlighter/scanner.vala diff --git a/src/libvaladoc/highlighter/xmlscanner.vala b/libvaladoc/highlighter/xmlscanner.vala similarity index 100% rename from src/libvaladoc/highlighter/xmlscanner.vala rename to libvaladoc/highlighter/xmlscanner.vala diff --git a/src/libvaladoc/html/basicdoclet.vala b/libvaladoc/html/basicdoclet.vala similarity index 100% rename from src/libvaladoc/html/basicdoclet.vala rename to libvaladoc/html/basicdoclet.vala diff --git a/src/libvaladoc/html/cssclassresolver.vala b/libvaladoc/html/cssclassresolver.vala similarity index 100% rename from src/libvaladoc/html/cssclassresolver.vala rename to libvaladoc/html/cssclassresolver.vala diff --git a/src/libvaladoc/html/htmlchartfactory.vala b/libvaladoc/html/htmlchartfactory.vala similarity index 100% rename from src/libvaladoc/html/htmlchartfactory.vala rename to libvaladoc/html/htmlchartfactory.vala diff --git a/src/libvaladoc/html/htmlmarkupwriter.vala b/libvaladoc/html/htmlmarkupwriter.vala similarity index 100% rename from src/libvaladoc/html/htmlmarkupwriter.vala rename to libvaladoc/html/htmlmarkupwriter.vala diff --git a/src/libvaladoc/html/htmlrenderer.vala b/libvaladoc/html/htmlrenderer.vala similarity index 100% rename from src/libvaladoc/html/htmlrenderer.vala rename to libvaladoc/html/htmlrenderer.vala diff --git a/src/libvaladoc/html/linkhelper.vala b/libvaladoc/html/linkhelper.vala similarity index 100% rename from src/libvaladoc/html/linkhelper.vala rename to libvaladoc/html/linkhelper.vala diff --git a/src/libvaladoc/importer/documentationimporter.vala b/libvaladoc/importer/documentationimporter.vala similarity index 100% rename from src/libvaladoc/importer/documentationimporter.vala rename to libvaladoc/importer/documentationimporter.vala diff --git a/src/libvaladoc/importer/girdocumentationimporter.vala b/libvaladoc/importer/girdocumentationimporter.vala similarity index 100% rename from src/libvaladoc/importer/girdocumentationimporter.vala rename to libvaladoc/importer/girdocumentationimporter.vala diff --git a/src/libvaladoc/importer/internalidregistrar.vala b/libvaladoc/importer/internalidregistrar.vala similarity index 100% rename from src/libvaladoc/importer/internalidregistrar.vala rename to libvaladoc/importer/internalidregistrar.vala diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala b/libvaladoc/importer/valadocdocumentationimporter.vala similarity index 100% rename from src/libvaladoc/importer/valadocdocumentationimporter.vala rename to libvaladoc/importer/valadocdocumentationimporter.vala diff --git a/src/libvaladoc/importer/valadocdocumentationimporterscanner.vala b/libvaladoc/importer/valadocdocumentationimporterscanner.vala similarity index 100% rename from src/libvaladoc/importer/valadocdocumentationimporterscanner.vala rename to libvaladoc/importer/valadocdocumentationimporterscanner.vala diff --git a/src/libvaladoc/markupreader.vala b/libvaladoc/markupreader.vala similarity index 100% rename from src/libvaladoc/markupreader.vala rename to libvaladoc/markupreader.vala diff --git a/src/libvaladoc/markupsourcelocation.vala b/libvaladoc/markupsourcelocation.vala similarity index 100% rename from src/libvaladoc/markupsourcelocation.vala rename to libvaladoc/markupsourcelocation.vala diff --git a/src/libvaladoc/markuptokentype.vala b/libvaladoc/markuptokentype.vala similarity index 100% rename from src/libvaladoc/markuptokentype.vala rename to libvaladoc/markuptokentype.vala diff --git a/src/libvaladoc/markupwriter.vala b/libvaladoc/markupwriter.vala similarity index 100% rename from src/libvaladoc/markupwriter.vala rename to libvaladoc/markupwriter.vala diff --git a/src/libvaladoc/moduleloader.vala b/libvaladoc/moduleloader.vala similarity index 100% rename from src/libvaladoc/moduleloader.vala rename to libvaladoc/moduleloader.vala diff --git a/src/libvaladoc/parser/manyrule.vala b/libvaladoc/parser/manyrule.vala similarity index 100% rename from src/libvaladoc/parser/manyrule.vala rename to libvaladoc/parser/manyrule.vala diff --git a/src/libvaladoc/parser/oneofrule.vala b/libvaladoc/parser/oneofrule.vala similarity index 100% rename from src/libvaladoc/parser/oneofrule.vala rename to libvaladoc/parser/oneofrule.vala diff --git a/src/libvaladoc/parser/optionalrule.vala b/libvaladoc/parser/optionalrule.vala similarity index 100% rename from src/libvaladoc/parser/optionalrule.vala rename to libvaladoc/parser/optionalrule.vala diff --git a/src/libvaladoc/parser/parser.vala b/libvaladoc/parser/parser.vala similarity index 100% rename from src/libvaladoc/parser/parser.vala rename to libvaladoc/parser/parser.vala diff --git a/src/libvaladoc/parser/parsercallback.vala b/libvaladoc/parser/parsercallback.vala similarity index 100% rename from src/libvaladoc/parser/parsercallback.vala rename to libvaladoc/parser/parsercallback.vala diff --git a/src/libvaladoc/parser/rule.vala b/libvaladoc/parser/rule.vala similarity index 100% rename from src/libvaladoc/parser/rule.vala rename to libvaladoc/parser/rule.vala diff --git a/src/libvaladoc/parser/scanner.vala b/libvaladoc/parser/scanner.vala similarity index 100% rename from src/libvaladoc/parser/scanner.vala rename to libvaladoc/parser/scanner.vala diff --git a/src/libvaladoc/parser/sequencerule.vala b/libvaladoc/parser/sequencerule.vala similarity index 100% rename from src/libvaladoc/parser/sequencerule.vala rename to libvaladoc/parser/sequencerule.vala diff --git a/src/libvaladoc/parser/sourcelocation.vala b/libvaladoc/parser/sourcelocation.vala similarity index 100% rename from src/libvaladoc/parser/sourcelocation.vala rename to libvaladoc/parser/sourcelocation.vala diff --git a/src/libvaladoc/parser/stubrule.vala b/libvaladoc/parser/stubrule.vala similarity index 100% rename from src/libvaladoc/parser/stubrule.vala rename to libvaladoc/parser/stubrule.vala diff --git a/src/libvaladoc/parser/token.vala b/libvaladoc/parser/token.vala similarity index 100% rename from src/libvaladoc/parser/token.vala rename to libvaladoc/parser/token.vala diff --git a/src/libvaladoc/parser/tokentype.vala b/libvaladoc/parser/tokentype.vala similarity index 100% rename from src/libvaladoc/parser/tokentype.vala rename to libvaladoc/parser/tokentype.vala diff --git a/src/libvaladoc/settings.vala b/libvaladoc/settings.vala similarity index 100% rename from src/libvaladoc/settings.vala rename to libvaladoc/settings.vala diff --git a/src/libvaladoc/taglets/tagletdeprecated.vala b/libvaladoc/taglets/tagletdeprecated.vala similarity index 100% rename from src/libvaladoc/taglets/tagletdeprecated.vala rename to libvaladoc/taglets/tagletdeprecated.vala diff --git a/src/libvaladoc/taglets/tagletinheritdoc.vala b/libvaladoc/taglets/tagletinheritdoc.vala similarity index 100% rename from src/libvaladoc/taglets/tagletinheritdoc.vala rename to libvaladoc/taglets/tagletinheritdoc.vala diff --git a/src/libvaladoc/taglets/tagletinit.vala b/libvaladoc/taglets/tagletinit.vala similarity index 100% rename from src/libvaladoc/taglets/tagletinit.vala rename to libvaladoc/taglets/tagletinit.vala diff --git a/src/libvaladoc/taglets/tagletlink.vala b/libvaladoc/taglets/tagletlink.vala similarity index 100% rename from src/libvaladoc/taglets/tagletlink.vala rename to libvaladoc/taglets/tagletlink.vala diff --git a/src/libvaladoc/taglets/tagletparam.vala b/libvaladoc/taglets/tagletparam.vala similarity index 100% rename from src/libvaladoc/taglets/tagletparam.vala rename to libvaladoc/taglets/tagletparam.vala diff --git a/src/libvaladoc/taglets/tagletreturn.vala b/libvaladoc/taglets/tagletreturn.vala similarity index 100% rename from src/libvaladoc/taglets/tagletreturn.vala rename to libvaladoc/taglets/tagletreturn.vala diff --git a/src/libvaladoc/taglets/tagletsee.vala b/libvaladoc/taglets/tagletsee.vala similarity index 100% rename from src/libvaladoc/taglets/tagletsee.vala rename to libvaladoc/taglets/tagletsee.vala diff --git a/src/libvaladoc/taglets/tagletsince.vala b/libvaladoc/taglets/tagletsince.vala similarity index 100% rename from src/libvaladoc/taglets/tagletsince.vala rename to libvaladoc/taglets/tagletsince.vala diff --git a/src/libvaladoc/taglets/tagletthrows.vala b/libvaladoc/taglets/tagletthrows.vala similarity index 100% rename from src/libvaladoc/taglets/tagletthrows.vala rename to libvaladoc/taglets/tagletthrows.vala diff --git a/src/libvaladoc/valadoc-1.0.deps.in b/libvaladoc/valadoc-1.0.deps.in similarity index 100% rename from src/libvaladoc/valadoc-1.0.deps.in rename to libvaladoc/valadoc-1.0.deps.in diff --git a/src/libvaladoc/valadoc-1.0.pc.in b/libvaladoc/valadoc-1.0.pc.in similarity index 100% rename from src/libvaladoc/valadoc-1.0.pc.in rename to libvaladoc/valadoc-1.0.pc.in diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 63efb92ef..000000000 --- a/src/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -NULL = - -SUBDIRS = \ - libvaladoc \ - valadoc \ - doclets \ - driver \ - $(NULL) - -EXTRA_DIST = \ - vapi/config.vapi \ - vapi/libgvc.vapi \ - $(NULL) - diff --git a/src/driver/0.20.x/Makefile.am b/src/driver/0.20.x/Makefile.am deleted file mode 100644 index cafd9c2be..000000000 --- a/src/driver/0.20.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.20 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_20_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.20.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.20 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_20_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.20.x/driver.vala b/src/driver/0.20.x/driver.vala deleted file mode 100644 index 6bed3b942..000000000 --- a/src/driver/0.20.x/driver.vala +++ /dev/null @@ -1,69 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.20.x/treebuilder.vala b/src/driver/0.20.x/treebuilder.vala deleted file mode 100644 index 59df9b6d3..000000000 --- a/src/driver/0.20.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_array ((Vala.ArrayType) vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 20; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 12; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.22.x/Makefile.am b/src/driver/0.22.x/Makefile.am deleted file mode 100644 index 4f114b7e8..000000000 --- a/src/driver/0.22.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.22 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_22_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.22.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.22 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_22_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.22.x/driver.vala b/src/driver/0.22.x/driver.vala deleted file mode 100644 index 6bed3b942..000000000 --- a/src/driver/0.22.x/driver.vala +++ /dev/null @@ -1,69 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.22.x/girwriter.vala b/src/driver/0.22.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.22.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.22.x/initializerbuilder.vala b/src/driver/0.22.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.22.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.22.x/symbolresolver.vala b/src/driver/0.22.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.22.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.22.x/treebuilder.vala b/src/driver/0.22.x/treebuilder.vala deleted file mode 100644 index bb4ef567c..000000000 --- a/src/driver/0.22.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_array ((Vala.ArrayType) vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 22; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 12; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.24.x/Makefile.am b/src/driver/0.24.x/Makefile.am deleted file mode 100644 index 1331ac5d8..000000000 --- a/src/driver/0.24.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.24 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_24_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.24.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.24 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_24_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.24.x/girwriter.vala b/src/driver/0.24.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.24.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.24.x/initializerbuilder.vala b/src/driver/0.24.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.24.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.24.x/symbolresolver.vala b/src/driver/0.24.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.24.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.24.x/treebuilder.vala b/src/driver/0.24.x/treebuilder.vala deleted file mode 100644 index 591109795..000000000 --- a/src/driver/0.24.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_array ((Vala.ArrayType) vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 24; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 12; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusServerModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusServerModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.26.x/Makefile.am b/src/driver/0.26.x/Makefile.am deleted file mode 100644 index bff3f52eb..000000000 --- a/src/driver/0.26.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.26 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_26_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.26.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.26 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_26_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.26.x/driver.vala b/src/driver/0.26.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.26.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.26.x/girwriter.vala b/src/driver/0.26.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.26.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.26.x/initializerbuilder.vala b/src/driver/0.26.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.26.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.26.x/symbolresolver.vala b/src/driver/0.26.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.26.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.26.x/treebuilder.vala b/src/driver/0.26.x/treebuilder.vala deleted file mode 100644 index 53440a180..000000000 --- a/src/driver/0.26.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_type_reference (vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 26; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 12; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.28.x/Makefile.am b/src/driver/0.28.x/Makefile.am deleted file mode 100644 index 4398045ea..000000000 --- a/src/driver/0.28.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.28 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_28_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.28.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.28 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_28_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.28.x/driver.vala b/src/driver/0.28.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.28.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.28.x/girwriter.vala b/src/driver/0.28.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.28.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.28.x/initializerbuilder.vala b/src/driver/0.28.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.28.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.28.x/symbolresolver.vala b/src/driver/0.28.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.28.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.28.x/treebuilder.vala b/src/driver/0.28.x/treebuilder.vala deleted file mode 100644 index 4d2865e1e..000000000 --- a/src/driver/0.28.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_type_reference (vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 28; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 24; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.30.x/Makefile.am b/src/driver/0.30.x/Makefile.am deleted file mode 100644 index fac86d65b..000000000 --- a/src/driver/0.30.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.30 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_30_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.30.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.30 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_30_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.30.x/driver.vala b/src/driver/0.30.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.30.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.30.x/girwriter.vala b/src/driver/0.30.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.30.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.30.x/initializerbuilder.vala b/src/driver/0.30.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.30.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.30.x/symbolresolver.vala b/src/driver/0.30.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.30.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.30.x/treebuilder.vala b/src/driver/0.30.x/treebuilder.vala deleted file mode 100644 index fbf942942..000000000 --- a/src/driver/0.30.x/treebuilder.vala +++ /dev/null @@ -1,1524 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_type_reference (vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 30; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 24; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.32.x/Makefile.am b/src/driver/0.32.x/Makefile.am deleted file mode 100644 index 3803a6988..000000000 --- a/src/driver/0.32.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.32 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_32_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.32.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.32 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_32_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.32.x/driver.vala b/src/driver/0.32.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.32.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.32.x/girwriter.vala b/src/driver/0.32.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.32.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.32.x/initializerbuilder.vala b/src/driver/0.32.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.32.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.32.x/symbolresolver.vala b/src/driver/0.32.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.32.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.32.x/treebuilder.vala b/src/driver/0.32.x/treebuilder.vala deleted file mode 100644 index 5b9c5ea9b..000000000 --- a/src/driver/0.32.x/treebuilder.vala +++ /dev/null @@ -1,1541 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_type_reference (vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Version") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - if ((tmp = att.args.get ("deprecated")) != null) { - new_attribute.add_boolean ("deprecated", bool.parse (tmp), att); - } - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - if ((tmp = att.args.get ("deprecated_since")) != null) { - new_attribute.add_string ("deprecated_since", tmp, att); - if (att.args.get ("deprecated") == null) { - new_attribute.add_boolean ("deprecated", true, att); - } - } - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - parent.add_attribute (new_attribute); - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 32; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 24; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.34.x/Makefile.am b/src/driver/0.34.x/Makefile.am deleted file mode 100644 index 93626cf03..000000000 --- a/src/driver/0.34.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.34 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_34_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.34.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.34 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_34_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.34.x/driver.vala b/src/driver/0.34.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.34.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.34.x/girwriter.vala b/src/driver/0.34.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.34.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.34.x/initializerbuilder.vala b/src/driver/0.34.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.34.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.34.x/symbolresolver.vala b/src/driver/0.34.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.34.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/0.34.x/treebuilder.vala b/src/driver/0.34.x/treebuilder.vala deleted file mode 100644 index 9931efd15..000000000 --- a/src/driver/0.34.x/treebuilder.vala +++ /dev/null @@ -1,1541 +0,0 @@ -/* treebuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; -using Gee; - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.TreeBuilder : Vala.CodeVisitor { - private ArrayList packages = new ArrayList (); - private PackageMetaData source_package; - - private HashMap files = new HashMap (); - private HashMap symbol_map = new HashMap (); - - private ErrorReporter reporter; - private Settings settings; - - private Api.Node current_node; - private Api.Tree tree; - - private Valadoc.Api.Class glib_error = null; - - - // - // Accessors - // - - public Api.Class get_glib_error () { - return glib_error; - } - - public HashMap get_symbol_map () { - return symbol_map; - } - - - // - // - // - - private class PackageMetaData { - public Package package; - public HashMap namespaces = new HashMap (); - public ArrayList files = new ArrayList (); - - public PackageMetaData (Package package) { - this.package = package; - } - - public Namespace get_namespace (Vala.Namespace vns, SourceFile file) { - Namespace? ns = namespaces.get (vns); - if (ns != null) { - return ns; - } - - // find documentation comment if existing: - SourceComment? comment = null; - if (vns.source_reference != null) { - foreach (Vala.Comment c in vns.get_comments()) { - if (c.source_reference.file == file.data || - (c.source_reference.file.file_type == Vala.SourceFileType.SOURCE - && ((Vala.SourceFile) file.data).file_type == Vala.SourceFileType.SOURCE) - ) { - Vala.SourceReference pos = c.source_reference; - if (c is Vala.GirComment) { - comment = new GirSourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } else { - comment = new SourceComment (c.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - break; - } - } - } - - // find parent if existing - var parent_vns = vns.parent_symbol; - - if (parent_vns == null) { - ns = new Namespace (package, file, vns.name, comment, vns); - package.add_child (ns); - } else { - Namespace parent_ns = get_namespace ((Vala.Namespace) parent_vns, file); - ns = new Namespace (parent_ns, file, vns.name, comment, vns); - parent_ns.add_child (ns); - } - - namespaces.set (vns, ns); - return ns; - } - - public void register_source_file (Vala.SourceFile file) { - files.add (file); - } - - public bool is_package_for_file (Vala.SourceFile source_file) { - if (source_file.file_type == Vala.SourceFileType.SOURCE && !package.is_package) { - return true; - } - - return files.contains (source_file); - } - } - - - // - // Type constructor translation helpers: - // - - private Pointer create_pointer (Vala.PointerType vtyperef, Item parent, Api.Node caller) { - Pointer ptr = new Pointer (parent, vtyperef); - - Vala.DataType vntype = vtyperef.base_type; - if (vntype is Vala.PointerType) { - ptr.data_type = create_pointer ((Vala.PointerType) vntype, ptr, caller); - } else if (vntype is Vala.ArrayType) { - ptr.data_type = create_array ((Vala.ArrayType) vntype, ptr, caller); - } else { - ptr.data_type = create_type_reference (vntype, ptr, caller); - } - - return ptr; - } - - private Api.Array create_array (Vala.ArrayType vtyperef, Item parent, Api.Node caller) { - Api.Array arr = new Api.Array (parent, vtyperef); - - Vala.DataType vntype = vtyperef.element_type; - if (vntype is Vala.ArrayType) { - arr.data_type = create_type_reference (vntype, arr, caller); - } else { - arr.data_type = create_type_reference (vntype, arr, caller); - } - - return arr; - } - - private TypeReference create_type_reference (Vala.DataType? vtyperef, Item parent, Api.Node caller) { - bool is_nullable = vtyperef != null - && vtyperef.nullable - && !(vtyperef is Vala.GenericType) - && !(vtyperef is Vala.PointerType); - string? signature = (vtyperef != null - && vtyperef.data_type != null)? Vala.GVariantModule.get_dbus_signature (vtyperef.data_type) : null; - bool pass_ownership = type_reference_pass_ownership (vtyperef); - Ownership ownership = get_type_reference_ownership (vtyperef); - bool is_dynamic = vtyperef != null && vtyperef.is_dynamic; - - TypeReference type_ref = new TypeReference (parent, - ownership, - pass_ownership, - is_dynamic, - is_nullable, - signature, - vtyperef); - - if (vtyperef is Vala.PointerType) { - type_ref.data_type = create_pointer ((Vala.PointerType) vtyperef, type_ref, caller); - } else if (vtyperef is Vala.ArrayType) { - type_ref.data_type = create_array ((Vala.ArrayType) vtyperef, type_ref, caller); - //} else if (vtyperef is Vala.GenericType) { - // type_ref.data_type = new TypeParameter (caller, - // caller.get_source_file (), - // ((Vala.GenericType) vtyperef).type_parameter.name, - // vtyperef); - } - - // type parameters: - if (vtyperef != null) { - foreach (Vala.DataType vdtype in vtyperef.get_type_arguments ()) { - var type_param = create_type_reference (vdtype, type_ref, caller); - type_ref.add_type_argument (type_param); - } - } - - return type_ref; - } - - - - // - // Translation helpers: - // - - private void process_attributes (Api.Symbol parent, GLib.List lst) { - // attributes without arguments: - string[] attributes = { - "ReturnsModifiedPointer", - "DestroysInstance", - "GenericAccessors", - "NoAccessorMethod", - "NoArrayLength", - "Experimental", - "Diagnostics", - "PrintfFormat", - "PointerType", - "ScanfFormat", - "ThreadLocal", - "SimpleType", - "HasEmitter", - "ModuleInit", - "NoWrapper", - "Immutable", - "ErrorBase", - "NoReturn", - "NoThrow", - "Compact", - "Assert", - "Flags" - }; - - string? tmp = ""; - - foreach (Vala.Attribute att in lst) { - if (att.name == "CCode" && (tmp = att.args.get ("has_target")) != null && tmp == "false") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - new_attribute.add_boolean ("has_target", false, att); - parent.add_attribute (new_attribute); - } else if (att.name == "Version") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - if ((tmp = att.args.get ("deprecated")) != null) { - new_attribute.add_boolean ("deprecated", bool.parse (tmp), att); - } - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - if ((tmp = att.args.get ("deprecated_since")) != null) { - new_attribute.add_string ("deprecated_since", tmp, att); - if (att.args.get ("deprecated") == null) { - new_attribute.add_boolean ("deprecated", true, att); - } - } - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - parent.add_attribute (new_attribute); - } else if (att.name == "Deprecated") { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - if ((tmp = att.args.get ("since")) != null) { - new_attribute.add_string ("since", tmp, att); - } - if ((tmp = att.args.get ("replacement")) != null) { - new_attribute.add_string ("replacement", tmp, att); - } - parent.add_attribute (new_attribute); - } else if (att.name in attributes) { - Attribute new_attribute = new Attribute (parent, parent.get_source_file (), att.name, att); - parent.add_attribute (new_attribute); - } - } - } - - private string? get_ccode_type_id (Vala.CodeNode node) { - return Vala.CCodeBaseModule.get_ccode_type_id (node); - } - - private bool is_reference_counting (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.is_reference_counting (sym); - } - - private string? get_ref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_ref_function (sym); - } - - private string? get_unref_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_unref_function (sym); - } - - private string? get_finalize_function_name (Vala.Class element) { - if (!element.is_fundamental ()) { - return null; - } - - return "%s_finalize".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_free_function_name (Vala.Class element) { - if (!element.is_compact) { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_free_function (element); - } - - private string? get_finish_name (Vala.Method m) { - return Vala.CCodeBaseModule.get_ccode_finish_name (m); - } - - private string? get_take_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_take_value_function (sym); - } - - private string? get_get_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_get_value_function (sym); - } - - private string? get_set_value_function (Vala.Class sym) { - return Vala.CCodeBaseModule.get_ccode_set_value_function (sym); - } - - - private string? get_param_spec_function (Vala.CodeNode sym) { - return Vala.CCodeBaseModule.get_ccode_param_spec_function (sym); - } - - private string? get_dup_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_dup_function (sym); - } - - private string? get_copy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_copy_function (sym); - } - - private string? get_destroy_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_destroy_function (sym); - } - - private string? get_free_function (Vala.TypeSymbol sym) { - return Vala.CCodeBaseModule.get_ccode_free_function (sym); - } - - private string? get_nick (Vala.Property prop) { - return Vala.CCodeBaseModule.get_ccode_nick (prop); - } - - private string? get_cname (Vala.Symbol symbol) { - return Vala.CCodeBaseModule.get_ccode_name (symbol); - } - - private SourceComment? create_comment (Vala.Comment? comment) { - if (comment != null) { - Vala.SourceReference pos = comment.source_reference; - SourceFile file = files.get (pos.file); - if (comment is Vala.GirComment) { - var tmp = new GirSourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - if (((Vala.GirComment) comment).return_content != null) { - Vala.SourceReference return_pos = ((Vala.GirComment) comment).return_content.source_reference; - tmp.return_comment = new SourceComment (((Vala.GirComment) comment).return_content.content, - file, - return_pos.begin.line, - return_pos.begin.column, - return_pos.end.line, - return_pos.end.column); - } - - Vala.MapIterator it = ((Vala.GirComment) comment).parameter_iterator (); - while (it.next ()) { - Vala.Comment vala_param = it.get_value (); - Vala.SourceReference param_pos = vala_param.source_reference; - var param_comment = new SourceComment (vala_param.content, - file, - param_pos.begin.line, - param_pos.begin.column, - param_pos.end.line, - param_pos.end.column); - tmp.add_parameter_content (it.get_key (), param_comment); - } - return tmp; - } else { - return new SourceComment (comment.content, - file, - pos.begin.line, - pos.begin.column, - pos.end.line, - pos.end.column); - } - } - - return null; - } - - private string get_method_name (Vala.Method element) { - if (element is Vala.CreationMethod) { - if (element.name == ".new") { - return element.parent_symbol.name; - } else { - return element.parent_symbol.name + "." + element.name; - } - } - - return element.name; - } - - private string? get_quark_macro_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } - - private string? get_private_cname (Vala.Class element) { - if (element.is_compact) { - return null; - } - - string? cname = get_cname (element); - return (cname != null)? cname + "Private" : null; - } - - private string? get_class_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_GET_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_class_type_macro_name (Vala.Class element) { - if (element.is_compact) { - return null; - } - - return "%s_CLASS".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string? get_is_type_macro_name (Vala.TypeSymbol element) { - string? name = Vala.CCodeBaseModule.get_ccode_type_check_function (element); - return (name != null && name != "")? name : null; - } - - private string? get_is_class_type_macro_name (Vala.TypeSymbol element) { - string? name = get_is_type_macro_name (element); - return (name != null)? name + "_CLASS" : null; - } - - private string? get_type_function_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return "%s_get_type".printf (Vala.CCodeBaseModule.get_ccode_lower_case_name (element, null)); - } - - private string? get_type_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && ((Vala.Class) element).is_compact) - || element is Vala.ErrorDomain - || element is Vala.Delegate) - { - return null; - } - - return Vala.CCodeBaseModule.get_ccode_type_id (element); - } - - private string? get_type_cast_macro_name (Vala.TypeSymbol element) { - if ((element is Vala.Class - && !((Vala.Class) element).is_compact) - || element is Vala.Interface) - { - return Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null); - } else { - return null; - } - } - - private string? get_interface_macro_name (Vala.Interface element) { - return "%s_GET_INTERFACE".printf (Vala.CCodeBaseModule.get_ccode_upper_case_name (element, null)); - } - - private string get_quark_function_name (Vala.ErrorDomain element) { - return Vala.CCodeBaseModule.get_ccode_lower_case_prefix (element) + "quark"; - } - - private PackageMetaData? get_package_meta_data (Package pkg) { - foreach (PackageMetaData data in packages) { - if (data.package == pkg) { - return data; - } - } - - return null; - } - - private PackageMetaData register_package (Package package) { - PackageMetaData meta_data = new PackageMetaData (package); - tree.add_package (package); - packages.add (meta_data); - return meta_data; - } - - private SourceFile register_source_file (PackageMetaData meta_data, Vala.SourceFile source_file) { - SourceFile file = new SourceFile (meta_data.package, - source_file.get_relative_filename (), - source_file.get_csource_filename (), - source_file); - files.set (source_file, file); - - meta_data.register_source_file (source_file); - return file; - } - - private SourceFile? get_source_file (Vala.Symbol symbol) { - Vala.SourceReference source_ref = symbol.source_reference; - if (source_ref == null) { - return null; - } - - SourceFile? file = files.get (source_ref.file); - assert (file != null); - return file; - } - - private Package? find_package_for_file (Vala.SourceFile source_file) { - foreach (PackageMetaData pkg in this.packages) { - if (pkg.is_package_for_file (source_file)) { - return pkg.package; - } - } - - return null; - } - - - private Namespace get_namespace (Package pkg, Vala.Symbol symbol, SourceFile? file) { - // Find the closest namespace in our vala-tree - Vala.Symbol namespace_symbol = symbol; - while (!(namespace_symbol is Vala.Namespace)) { - namespace_symbol = namespace_symbol.parent_symbol; - } - - PackageMetaData? meta_data = get_package_meta_data (pkg); - assert (meta_data != null); - - return meta_data.get_namespace ((Vala.Namespace) namespace_symbol, file); - } - - private MethodBindingType get_method_binding_type (Vala.Method element) { - if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.is_abstract) { - return MethodBindingType.ABSTRACT; - } else if (element.is_virtual) { - return MethodBindingType.VIRTUAL; - } else if (element.overrides) { - return MethodBindingType.OVERRIDE; - } else if (element.is_inline) { - return MethodBindingType.INLINE; - } else if (element.binding != Vala.MemberBinding.INSTANCE) { - return MethodBindingType.STATIC; - } - return MethodBindingType.UNMODIFIED; - } - - - private SymbolAccessibility get_access_modifier(Vala.Symbol symbol) { - switch (symbol.access) { - case Vala.SymbolAccessibility.PROTECTED: - return SymbolAccessibility.PROTECTED; - - case Vala.SymbolAccessibility.INTERNAL: - return SymbolAccessibility.INTERNAL; - - case Vala.SymbolAccessibility.PRIVATE: - return SymbolAccessibility.PRIVATE; - - case Vala.SymbolAccessibility.PUBLIC: - return SymbolAccessibility.PUBLIC; - - default: - error ("Unknown symbol accessibility modifier found"); - } - } - - private PropertyAccessorType get_property_accessor_type (Vala.PropertyAccessor element) { - if (element.construction) { - if (element.writable) { - return (PropertyAccessorType.CONSTRUCT | PropertyAccessorType.SET); - } - return PropertyAccessorType.CONSTRUCT; - } else if (element.writable) { - return PropertyAccessorType.SET; - } else if (element.readable) { - return PropertyAccessorType.GET; - } - - error ("Unknown symbol accessibility type"); - } - - private bool type_reference_pass_ownership (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode? node = element.parent_node; - if (node == null) { - return false; - } - if (node is Vala.Parameter) { - return (((Vala.Parameter)node).direction == Vala.ParameterDirection.IN && - ((Vala.Parameter)node).variable_type.value_owned); - } - if (node is Vala.Property) { - return ((Vala.Property)node).property_type.value_owned; - } - - return false; - } - - private bool is_type_reference_unowned (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are weak, not unowned - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == true) - { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false) - ? element.is_weak () - : false; - } - - private bool is_type_reference_owned (Vala.DataType? element) { - if (element == null) { - return false; - } - - weak Vala.CodeNode parent = element.parent_node; - - // parameter: - if (parent is Vala.Parameter) { - if (((Vala.Parameter)parent).direction != Vala.ParameterDirection.IN) { - return false; - } - return ((Vala.Parameter)parent).variable_type.value_owned; - } - - return false; - } - - private bool is_type_reference_weak (Vala.DataType? element) { - if (element == null) { - return false; - } - - // non ref counted types are unowned, not weak - if (element.data_type is Vala.TypeSymbol - && is_reference_counting ((Vala.TypeSymbol) element.data_type) == false) - { - return false; - } - - // arrays are unowned, not weak - if (element is Vala.ArrayType) { - return false; - } - - // FormalParameters are weak by default - return (element.parent_node is Vala.Parameter == false)? element.is_weak () : false; - } - - private Ownership get_type_reference_ownership (Vala.DataType? element) { - if (is_type_reference_owned (element)) { - return Ownership.OWNED; - } else if (is_type_reference_weak (element)) { - return Ownership.WEAK; - } else if (is_type_reference_unowned (element)) { - return Ownership.UNOWNED; - } - - return Ownership.DEFAULT; - } - - private Ownership get_property_ownership (Vala.PropertyAccessor element) { - if (element.value_type.value_owned) { - return Ownership.OWNED; - } - - // the exact type (weak, unowned) does not matter - return Ownership.UNOWNED; - } - - private PropertyBindingType get_property_binding_type (Vala.Property element) { - if (element.is_abstract) { - return PropertyBindingType.ABSTRACT; - } else if (element.is_virtual) { - return PropertyBindingType.VIRTUAL; - } else if (element.overrides) { - return PropertyBindingType.OVERRIDE; - } - - return PropertyBindingType.UNMODIFIED; - } - - private FormalParameterType get_formal_parameter_type (Vala.Parameter element) { - if (element.direction == Vala.ParameterDirection.OUT) { - return FormalParameterType.OUT; - } else if (element.direction == Vala.ParameterDirection.REF) { - return FormalParameterType.REF; - } else if (element.direction == Vala.ParameterDirection.IN) { - return FormalParameterType.IN; - } - - error ("Unknown formal parameter type"); - } - - - // - // Vala tree creation: - // - - private string get_package_name (string path) { - string file_name = Path.get_basename (path); - return file_name.substring (0, file_name.last_index_of_char ('.')); - } - - private bool add_package (Vala.CodeContext context, string pkg) { - // ignore multiple occurences of the same package - if (context.has_package (pkg)) { - return true; - } - - string vapi_name = pkg + ".vapi"; - string gir_name = pkg + ".gir"; - foreach (string source_file in settings.source_files) { - string basename = Path.get_basename (source_file); - if (basename == vapi_name || basename == gir_name) { - return true; - } - } - - - var package_path = context.get_vapi_path (pkg) ?? context.get_gir_path (pkg); - if (package_path == null) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (pkg)); - return false; - } - - context.add_package (pkg); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, package_path); - context.add_source_file (vfile); - Package vdpkg = new Package (pkg, true, null); - register_source_file (register_package (vdpkg), vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg)), pkg); - return true; - } - - private void add_deps (Vala.CodeContext context, string file_path, string pkg_name) { - if (FileUtils.test (file_path, FileTest.EXISTS)) { - try { - string deps_content; - ulong deps_len; - FileUtils.get_contents (file_path, out deps_content, out deps_len); - foreach (string dep in deps_content.split ("\n")) { - dep = dep.strip (); - if (dep != "") { - if (!add_package (context, dep)) { - Vala.Report.error (null, "%s, dependency of %s, not found in specified Vala API directories".printf (dep, pkg_name)); - } - } - } - } catch (FileError e) { - Vala.Report.error (null, "Unable to read dependency file: %s".printf (e.message)); - } - } - } - - /** - * Adds the specified packages to the list of used packages. - * - * @param context The code context - * @param packages a list of package names - */ - private void add_depencies (Vala.CodeContext context, string[] packages) { - foreach (string package in packages) { - if (!add_package (context, package)) { - Vala.Report.error (null, "Package `%s' not found in specified Vala API directories or GObject-Introspection GIR directories".printf (package)); - } - } - } - - /** - * Add the specified source file to the context. Only .vala, .vapi, .gs, - * and .c files are supported. - */ - private void add_documented_files (Vala.CodeContext context, string[] sources) { - if (sources == null) { - return; - } - - foreach (string source in sources) { - if (FileUtils.test (source, FileTest.EXISTS)) { - var rpath = realpath (source); - if (source.has_suffix (".vala") || source.has_suffix (".gs")) { - var source_file = new Vala.SourceFile (context, Vala.SourceFileType.SOURCE, rpath); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, source_file); - - if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - } - - context.add_source_file (source_file); - } else if (source.has_suffix (".vapi") || source.has_suffix (".gir")) { - string file_name = get_package_name (source); - - var vfile = new Vala.SourceFile (context, Vala.SourceFileType.PACKAGE, rpath); - context.add_source_file (vfile); - - if (source_package == null) { - source_package = register_package (new Package (settings.pkg_name, false, null)); - } - - register_source_file (source_package, vfile); - - add_deps (context, Path.build_filename (Path.get_dirname (source), "%s.deps".printf (file_name)), file_name); - } else if (source.has_suffix (".c")) { - context.add_c_source_file (rpath); - tree.add_external_c_files (rpath); - } else { - Vala.Report.error (null, "%s is not a supported source file type. Only .vala, .vapi, .gs, and .c files are supported.".printf (source)); - } - } else { - Vala.Report.error (null, "%s not found".printf (source)); - } - } - } - - private Vala.CodeContext create_valac_tree (Settings settings) { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); - - - // settings: - context.experimental = settings.experimental; - context.experimental_non_null = settings.experimental || settings.experimental_non_null; - context.vapi_directories = settings.vapi_directories; - context.report.enable_warnings = settings.verbose; - context.metadata_directories = settings.metadata_directories; - context.gir_directories = settings.gir_directories; - - if (settings.basedir == null) { - context.basedir = realpath ("."); - } else { - context.basedir = realpath (settings.basedir); - } - - if (settings.directory != null) { - context.directory = realpath (settings.directory); - } else { - context.directory = context.basedir; - } - - - // add default packages: - if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - context.add_define ("GOBJECT"); - } - - - if (settings.defines != null) { - foreach (string define in settings.defines) { - context.add_define (define); - } - } - - for (int i = 2; i <= 34; i += 2) { - context.add_define ("VALA_0_%d".printf (i)); - } - - if (context.profile == Vala.Profile.GOBJECT) { - int glib_major = 2; - int glib_minor = 24; - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - if (settings.target_glib != null && settings.target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) { - Vala.Report.error (null, "Invalid format for --target-glib"); - } - - context.target_glib_major = glib_major; - context.target_glib_minor = glib_minor; - if (context.target_glib_major != 2) { - Vala.Report.error (null, "This version of valac only supports GLib 2"); - } - - for (int i = 16; i <= glib_minor; i += 2) { - context.add_define ("GLIB_2_%d".printf (i)); - } - - // default packages - if (!this.add_package (context, "glib-2.0")) { // - Vala.Report.error (null, "glib-2.0 not found in specified Vala API directories"); - } - - if (!this.add_package (context, "gobject-2.0")) { // - Vala.Report.error (null, "gobject-2.0 not found in specified Vala API directories"); - } - } - - // add user defined files: - add_depencies (context, settings.packages); - if (reporter.errors > 0) { - return context; - } - - add_documented_files (context, settings.source_files); - if (reporter.errors > 0) { - return context; - } - - - // parse vala-code: - Vala.Parser parser = new Vala.Parser (); - - parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - // parse gir: - Vala.GirParser gir_parser = new Vala.GirParser (); - - gir_parser.parse (context); - if (context.report.get_errors () > 0) { - return context; - } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - - return context; - } - - - - // - // Valadoc tree creation: - // - - private void process_children (Api.Node node, Vala.CodeNode element) { - Api.Node old_node = current_node; - current_node = node; - element.accept_children (this); - current_node = old_node; - } - - private Api.Node get_parent_node_for (Vala.Symbol element) { - if (current_node != null) { - return current_node; - } - - Vala.SourceFile vala_source_file = element.source_reference.file; - Package package = find_package_for_file (vala_source_file); - SourceFile? source_file = get_source_file (element); - - return get_namespace (package, element, source_file); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Vala.Namespace element) { - element.accept_children (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_class == null && element.name == "string"; - - Class node = new Class (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_private_cname (element), - get_class_macro_name (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_class_type_macro_name (element), - get_is_class_type_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - get_ccode_type_id (element), - get_param_spec_function (element), - get_ref_function (element), - get_unref_function (element), - get_free_function_name (element), - get_finalize_function_name (element), - get_take_value_function (element), - get_get_value_function (element), - get_set_value_function (element), - element.is_fundamental (), - element.is_abstract, - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // relations - foreach (Vala.DataType vala_type_ref in element.get_base_types ()) { - var type_ref = create_type_reference (vala_type_ref, node, node); - - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else if (vala_type_ref.data_type is Vala.Class) { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - - // save GLib.Error - if (glib_error == null && node.get_full_name () == "GLib.Error") { - glib_error = node; - } - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Interface node = new Interface (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_is_type_macro_name (element), - get_type_cast_macro_name (element), - get_type_function_name (element), - get_interface_macro_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - // prerequisites: - foreach (Vala.DataType vala_type_ref in element.get_prerequisites ()) { - TypeReference type_ref = create_type_reference (vala_type_ref, node, node); - if (vala_type_ref.data_type is Vala.Interface) { - node.add_interface (type_ref); - } else { - node.base_type = type_ref; - } - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - bool is_basic_type = element.base_type == null - && (element.is_boolean_type () - || element.is_floating_type () - || element.is_integer_type ()); - - Struct node = new Struct (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - get_ccode_type_id (element), - get_dup_function (element), - get_copy_function (element), - get_destroy_function (element), - get_free_function (element), - is_basic_type, - element); - symbol_map.set (element, node); - parent.add_child (node); - - // parent type: - Vala.ValueType? basetype = element.base_type as Vala.ValueType; - if (basetype != null) { - node.base_type = create_type_reference (basetype, node, node); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Field node = new Field (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element.binding == Vala.MemberBinding.STATIC, - element.is_volatile, - element); - node.field_type = create_type_reference (element.variable_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Property node = new Property (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_nick (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - get_property_binding_type (element), - element); - node.property_type = create_type_reference (element.property_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - // Process property type - if (element.get_accessor != null) { - var accessor = element.get_accessor; - node.getter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - if (element.set_accessor != null) { - var accessor = element.set_accessor; - node.setter = new PropertyAccessor (node, - file, - element.name, - get_access_modifier (accessor), - get_cname (accessor), - get_property_accessor_type (accessor), - get_property_ownership (accessor), - accessor); - } - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Method node = new Method (parent, - file, - get_method_name (element), - get_access_modifier (element), - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.dbus_result_name (element), - (element.coroutine)? get_finish_name (element) : null, - get_method_binding_type (element), - element.coroutine, - Vala.GDBusModule.is_dbus_visible (element), - element is Vala.CreationMethod, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Api.Signal node = new Api.Signal (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - (element.default_handler != null)? get_cname (element.default_handler) : null, - Vala.GDBusModule.get_dbus_name_for_member (element), - Vala.GDBusModule.is_dbus_visible (element), - element.is_virtual, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Delegate node = new Delegate (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - !element.has_target, - element); - node.return_type = create_type_reference (element.return_type, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Enum (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_type_macro_name (element), - get_type_function_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue element) { - Api.Enum parent = (Enum) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.EnumValue (parent, - file, - element.name, - comment, - get_cname (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Constant node = new Constant (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - element); - node.constant_type = create_type_reference (element.type_reference, node, node); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - SourceComment? comment = create_comment (element.comment); - - Symbol node = new ErrorDomain (parent, - file, - element.name, - get_access_modifier (element), - comment, - get_cname (element), - get_quark_macro_name (element), - get_quark_function_name (element), - Vala.GDBusModule.get_dbus_name (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode element) { - Api.ErrorDomain parent = (ErrorDomain) get_parent_node_for (element); - SourceFile? file = get_source_file (element); - if (file == null) { - file = parent.get_source_file (); - } - - SourceComment? comment = create_comment (element.comment); - - Symbol node = new Api.ErrorCode (parent, - file, - element.name, - comment, - get_cname (element), - Vala.GDBusModule.get_dbus_name_for_member (element), - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_attributes (node, element.attributes); - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (Vala.TypeParameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - Symbol node = new TypeParameter (parent, - file, - element.name, - element); - symbol_map.set (element, node); - parent.add_child (node); - - process_children (node, element); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (Vala.Parameter element) { - Api.Node parent = get_parent_node_for (element); - SourceFile? file = get_source_file (element); - - FormalParameter node = new FormalParameter (parent, - file, - element.name, - get_access_modifier(element), - get_formal_parameter_type (element), - element.ellipsis, - element); - node.parameter_type = create_type_reference (element.variable_type, node, node); - parent.add_child (node); - - process_children (node, element); - } - - - // - // startpoint: - // - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - this.settings = settings; - this.reporter = reporter; - - this.tree = new Api.Tree (reporter, settings); - var context = create_valac_tree (settings); - this.tree.data = context; - - reporter.warnings_offset = context.report.get_warnings (); - reporter.errors_offset = context.report.get_errors (); - - if (context == null) { - return null; - } - - // TODO: Register all packages here - // register packages included by gir-files - foreach (Vala.SourceFile vfile in context.get_source_files ()) { - if (vfile.file_type == Vala.SourceFileType.PACKAGE - && vfile.get_nodes ().size > 0 - && files.has_key (vfile) == false) - { - Package vdpkg = new Package (get_package_name (vfile.filename), true, null); - register_source_file (register_package (vdpkg), vfile); - } - } - - context.accept(this); - - return (reporter.errors == 0)? tree : null; - } -} - - diff --git a/src/driver/0.36.x/Makefile.am b/src/driver/0.36.x/Makefile.am deleted file mode 100644 index 4119ee0ff..000000000 --- a/src/driver/0.36.x/Makefile.am +++ /dev/null @@ -1,72 +0,0 @@ -NULL = - -VERSIONED_VAPI_DIR = $(shell pkg-config libvala-0.36 --variable vapidir) - -AM_CFLAGS = \ - -DPACKAGE_ICONDIR=\"$(datadir)/valadoc/icons/\" \ - -I $(top_builddir)/src/libvaladoc/ \ - $(GLIB_CFLAGS) \ - $(LIBGEE_CFLAGS) \ - $(LIBGVC_CFLAGS) \ - $(LIBVALA_0_36_X_CFLAGS) \ - -g \ - -w \ - $(NULL) - -AM_VALAFLAGS = \ - $(VALAFLAGS) \ - --vapidir $(VERSIONED_VAPI_DIR) \ - --vapidir $(top_srcdir)/src/vapi \ - --vapidir $(top_srcdir)/src/libvaladoc \ - --basedir $(srcdir) \ - --directory $(builddir) \ - -C \ - -g \ - $(NULL) - -BUILT_SOURCES = libdriver.vala.stamp - -driver_LTLIBRARIES = libdriver.la - -driverdir = $(libdir)/valadoc/drivers/0.36.x - -libdriver_la_LDFLAGS = -module -avoid-version -no-undefined - -libdriver_la_VALASOURCES = \ - initializerbuilder.vala \ - symbolresolver.vala \ - treebuilder.vala \ - girwriter.vala \ - driver.vala \ - $(NULL) - -nodist_libdriver_la_SOURCES = \ - $(libdriver_la_VALASOURCES:.vala=.c) \ - $(NULL) - -libdriver.vala.stamp: $(libdriver_la_VALASOURCES) Makefile - $(VALAC) \ - $(AM_VALAFLAGS) \ - --pkg libvala-0.36 \ - --pkg gee-0.8 \ - --pkg valadoc-1.0 \ - $(filter %.vala %.c,$^) - touch $@ - -libdriver_la_LIBADD = \ - $(top_builddir)/src/libvaladoc/libvaladoc.la \ - $(GLIB_LIBS) \ - $(LIBVALA_0_36_X_LIBS) \ - $(LIBGEE_LIBS) \ - $(LIBGVC_LIBS) \ - $(NULL) - -EXTRA_DIST = \ - $(libdriver_la_VALASOURCES) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(nodist_libdriver_la_SOURCES) \ - $(NULL) - diff --git a/src/driver/0.36.x/driver.vala b/src/driver/0.36.x/driver.vala deleted file mode 100644 index 902d28d4b..000000000 --- a/src/driver/0.36.x/driver.vala +++ /dev/null @@ -1,70 +0,0 @@ -/* driver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - - -/** - * Creates an simpler, minimized, more abstract AST for valacs AST. - */ -public class Valadoc.Drivers.Driver : Object, Valadoc.Driver { - private SymbolResolver resolver; - private Api.Tree? tree; - - public void write_gir (Settings settings, ErrorReporter reporter) { - var gir_writer = new Drivers.GirWriter (resolver); - - // put .gir file in current directory unless -d has been explicitly specified - string gir_directory = "."; - if (settings.gir_directory != null) { - gir_directory = settings.gir_directory; - } - - gir_writer.write_file ((Vala.CodeContext) tree.data, - gir_directory, - "%s-%s.gir".printf (settings.gir_namespace, settings.gir_version), - settings.gir_namespace, - settings.gir_version, - settings.pkg_name); - } - - public Api.Tree? build (Settings settings, ErrorReporter reporter) { - TreeBuilder builder = new TreeBuilder (); - tree = builder.build (settings, reporter); - if (reporter.errors > 0) { - return null; - } - - resolver = new SymbolResolver (builder); - tree.accept (resolver); - - return tree; - } -} - - -public Type register_plugin (Valadoc.ModuleLoader module_loader) { - return typeof (Valadoc.Drivers.Driver); -} - diff --git a/src/driver/0.36.x/girwriter.vala b/src/driver/0.36.x/girwriter.vala deleted file mode 100644 index c250854d6..000000000 --- a/src/driver/0.36.x/girwriter.vala +++ /dev/null @@ -1,204 +0,0 @@ -/* girwriter.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Api; - - -/** - * Code visitor generating .gir file for the public interface. - */ -public class Valadoc.Drivers.GirWriter : Vala.GIRWriter { - private GtkdocRenderer renderer; - private SymbolResolver resolver; - - public GirWriter (SymbolResolver resolver) { - this.renderer = new GtkdocRenderer (); - this.resolver = resolver; - } - - private string? translate (Content.Comment? documentation) { - if (documentation == null) { - return null; - } - - renderer.render_symbol (documentation); - - return MarkupWriter.escape (renderer.content); - } - - private string? translate_taglet (Content.Taglet? taglet) { - if (taglet == null) { - return null; - } - - renderer.render_children (taglet); - - return MarkupWriter.escape (renderer.content); - } - - protected override string? get_interface_comment (Vala.Interface viface) { - Interface iface = resolver.resolve (viface) as Interface; - return translate (iface.documentation); - } - - protected override string? get_struct_comment (Vala.Struct vst) { - Struct st = resolver.resolve (vst) as Struct; - return translate (st.documentation); - } - - protected override string? get_enum_comment (Vala.Enum ven) { - Enum en = resolver.resolve (ven) as Enum; - return translate (en.documentation); - } - - protected override string? get_class_comment (Vala.Class vc) { - Class c = resolver.resolve (vc) as Class; - return translate (c.documentation); - } - - protected override string? get_error_code_comment (Vala.ErrorCode vecode) { - ErrorCode ecode = resolver.resolve (vecode) as ErrorCode; - return translate (ecode.documentation); - } - - protected override string? get_enum_value_comment (Vala.EnumValue vev) { - Api.EnumValue ev = resolver.resolve (vev) as Api.EnumValue; - return translate (ev.documentation); - } - - protected override string? get_constant_comment (Vala.Constant vc) { - Constant c = resolver.resolve (vc) as Constant; - return translate (c.documentation); - } - - protected override string? get_error_domain_comment (Vala.ErrorDomain vedomain) { - ErrorDomain edomain = resolver.resolve (vedomain) as ErrorDomain; - return translate (edomain.documentation); - } - - protected override string? get_field_comment (Vala.Field vf) { - Field f = resolver.resolve (vf) as Field; - return translate (f.documentation); - } - - protected override string? get_delegate_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - return translate (cb.documentation); - } - - protected override string? get_method_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - return translate (m.documentation); - } - - protected override string? get_property_comment (Vala.Property vprop) { - Property prop = resolver.resolve (vprop) as Property; - return translate (prop.documentation); - } - - protected override string? get_delegate_return_comment (Vala.Delegate vcb) { - Delegate cb = resolver.resolve (vcb) as Delegate; - if (cb.documentation == null) { - return null; - } - - Content.Comment? documentation = cb.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (cb, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_return_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - if (sig.documentation == null) { - return null; - } - - Content.Comment? documentation = sig.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (sig, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_method_return_comment (Vala.Method vm) { - Method m = resolver.resolve (vm) as Method; - if (m.documentation == null) { - return null; - } - - Content.Comment? documentation = m.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (m, typeof(Taglets.Return)); - foreach (Content.Taglet taglet in taglets) { - return translate_taglet (taglet); - } - - return null; - } - - protected override string? get_signal_comment (Vala.Signal vsig) { - Api.Signal sig = resolver.resolve (vsig) as Api.Signal; - return translate (sig.documentation); - } - - protected override string? get_parameter_comment (Vala.Parameter param) { - Api.Symbol symbol = resolver.resolve (((Vala.Symbol) param.parent_symbol)); - if (symbol == null) { - return null; - } - - Content.Comment? documentation = symbol.documentation; - if (documentation == null) { - return null; - } - - Gee.List taglets = documentation.find_taglets (symbol, typeof(Taglets.Param)); - foreach (Content.Taglet _taglet in taglets) { - Taglets.Param taglet = (Taglets.Param) _taglet; - if (taglet.parameter_name == param.name) { - return translate_taglet (taglet); - } - } - - return null; - } -} - - diff --git a/src/driver/0.36.x/initializerbuilder.vala b/src/driver/0.36.x/initializerbuilder.vala deleted file mode 100644 index 7b26ab51f..000000000 --- a/src/driver/0.36.x/initializerbuilder.vala +++ /dev/null @@ -1,669 +0,0 @@ -/* initializerbuilder.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - - -using Valadoc.Content; -using Gee; - - -private class Valadoc.Api.InitializerBuilder : Vala.CodeVisitor { - private HashMap symbol_map; - private SignatureBuilder signature; - - private Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void write_node (Vala.Symbol vsymbol) { - signature.append_symbol (resolve (vsymbol)); - } - - private void write_type (Vala.DataType vsymbol) { - if (vsymbol.data_type != null) { - write_node (vsymbol.data_type); - } else { - signature.append_literal ("null"); - } - - var type_args = vsymbol.get_type_arguments (); - if (type_args.size > 0) { - signature.append ("<"); - bool first = true; - foreach (Vala.DataType type_arg in type_args) { - if (!first) { - signature.append (","); - } else { - first = false; - } - if (!type_arg.value_owned) { - signature.append_keyword ("weak"); - } - signature.append (type_arg.to_qualified_string (null)); - } - signature.append (">"); - } - - if (vsymbol.nullable) { - signature.append ("?"); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_array_creation_expression (Vala.ArrayCreationExpression expr) { - signature.append_keyword ("new"); - write_type (expr.element_type); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression size in expr.get_sizes ()) { - if (!first) { - signature.append (", ", false); - } - size.accept (this); - first = false; - } - - signature.append ("]", false); - - if (expr.initializer_list != null) { - signature.append (" ", false); - expr.initializer_list.accept (this); - } - } - - public InitializerBuilder (SignatureBuilder signature, HashMap symbol_map) { - this.symbol_map = symbol_map; - this.signature = signature; - } - - /** - * {@inheritDoc} - */ - public override void visit_binary_expression (Vala.BinaryExpression expr) { - expr.left.accept (this); - - switch (expr.operator) { - case Vala.BinaryOperator.PLUS: - signature.append ("+ "); - break; - - case Vala.BinaryOperator.MINUS: - signature.append ("- "); - break; - - case Vala.BinaryOperator.MUL: - signature.append ("* "); - break; - - case Vala.BinaryOperator.DIV: - signature.append ("/ "); - break; - - case Vala.BinaryOperator.MOD: - signature.append ("% "); - break; - - case Vala.BinaryOperator.SHIFT_LEFT: - signature.append ("<< "); - break; - - case Vala.BinaryOperator.SHIFT_RIGHT: - signature.append (">> "); - break; - - case Vala.BinaryOperator.LESS_THAN: - signature.append ("< "); - break; - - case Vala.BinaryOperator.GREATER_THAN: - signature.append ("> "); - break; - - case Vala.BinaryOperator.LESS_THAN_OR_EQUAL: - signature.append ("<= "); - break; - - case Vala.BinaryOperator.GREATER_THAN_OR_EQUAL: - signature.append (">= "); - break; - - case Vala.BinaryOperator.EQUALITY: - signature.append ("== "); - break; - - case Vala.BinaryOperator.INEQUALITY: - signature.append ("!= "); - break; - - case Vala.BinaryOperator.BITWISE_AND: - signature.append ("& "); - break; - - case Vala.BinaryOperator.BITWISE_OR: - signature.append ("| "); - break; - - case Vala.BinaryOperator.BITWISE_XOR: - signature.append ("^ "); - break; - - case Vala.BinaryOperator.AND: - signature.append ("&& "); - break; - - case Vala.BinaryOperator.OR: - signature.append ("|| "); - break; - - case Vala.BinaryOperator.IN: - signature.append_keyword ("in"); - signature.append (" "); - break; - - case Vala.BinaryOperator.COALESCE: - signature.append ("?? "); - break; - - default: - assert_not_reached (); - } - - expr.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_unary_expression (Vala.UnaryExpression expr) { - switch (expr.operator) { - case Vala.UnaryOperator.PLUS: - signature.append ("+"); - break; - - case Vala.UnaryOperator.MINUS: - signature.append ("-"); - break; - - case Vala.UnaryOperator.LOGICAL_NEGATION: - signature.append ("!"); - break; - - case Vala.UnaryOperator.BITWISE_COMPLEMENT: - signature.append ("~"); - break; - - case Vala.UnaryOperator.INCREMENT: - signature.append ("++"); - break; - - case Vala.UnaryOperator.DECREMENT: - signature.append ("--"); - break; - - case Vala.UnaryOperator.REF: - signature.append_keyword ("ref"); - break; - - case Vala.UnaryOperator.OUT: - signature.append_keyword ("out"); - break; - - default: - assert_not_reached (); - } - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_assignment (Vala.Assignment a) { - a.left.accept (this); - - switch (a.operator) { - case Vala.AssignmentOperator.SIMPLE: - signature.append ("="); - break; - - case Vala.AssignmentOperator.BITWISE_OR: - signature.append ("|"); - break; - - case Vala.AssignmentOperator.BITWISE_AND: - signature.append ("&"); - break; - - case Vala.AssignmentOperator.BITWISE_XOR: - signature.append ("^"); - break; - - case Vala.AssignmentOperator.ADD: - signature.append ("+"); - break; - - case Vala.AssignmentOperator.SUB: - signature.append ("-"); - break; - - case Vala.AssignmentOperator.MUL: - signature.append ("*"); - break; - - case Vala.AssignmentOperator.DIV: - signature.append ("/"); - break; - - case Vala.AssignmentOperator.PERCENT: - signature.append ("%"); - break; - - case Vala.AssignmentOperator.SHIFT_LEFT: - signature.append ("<<"); - break; - - case Vala.AssignmentOperator.SHIFT_RIGHT: - signature.append (">>"); - break; - - default: - assert_not_reached (); - } - - a.right.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_cast_expression (Vala.CastExpression expr) { - if (expr.is_non_null_cast) { - signature.append ("(!)"); - expr.inner.accept (this); - return; - } - - if (!expr.is_silent_cast) { - signature.append ("(", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - expr.inner.accept (this); - - if (expr.is_silent_cast) { - signature.append_keyword ("as"); - write_type (expr.type_reference); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_initializer_list (Vala.InitializerList list) { - signature.append ("{", false); - - bool first = true; - foreach (Vala.Expression initializer in list.get_initializers ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - initializer.accept (this); - } - - signature.append ("}", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_member_access (Vala.MemberAccess expr) { - if (expr.symbol_reference != null) { - expr.symbol_reference.accept (this); - } else { - signature.append (expr.member_name); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_element_access (Vala.ElementAccess expr) { - expr.container.accept (this); - signature.append ("[", false); - - bool first = true; - foreach (Vala.Expression index in expr.get_indices ()) { - if (!first) { - signature.append (", ", false); - } - first = false; - - index.accept (this); - } - - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_pointer_indirection (Vala.PointerIndirection expr) { - signature.append ("*", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_addressof_expression (Vala.AddressofExpression expr) { - signature.append ("&", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_reference_transfer_expression (Vala.ReferenceTransferExpression expr) { - signature.append ("(", false).append_keyword ("owned", false).append (")", false); - expr.inner.accept (this); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_check (Vala.TypeCheck expr) { - expr.expression.accept (this); - signature.append_keyword ("is"); - write_type (expr.type_reference); - } - - /** - * {@inheritDoc} - */ - public override void visit_method_call (Vala.MethodCall expr) { - // symbol-name: - expr.call.symbol_reference.accept (this); - - // parameters: - signature.append (" (", false); - bool first = true; - foreach (Vala.Expression literal in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - - literal.accept (this); - first = false; - } - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_slice_expression (Vala.SliceExpression expr) { - expr.container.accept (this); - signature.append ("[", false); - expr.start.accept (this); - signature.append (":", false); - expr.stop.accept (this); - signature.append ("]", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_base_access (Vala.BaseAccess expr) { - signature.append_keyword ("base", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_postfix_expression (Vala.PostfixExpression expr) { - expr.inner.accept (this); - if (expr.increment) { - signature.append ("++", false); - } else { - signature.append ("--", false); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_object_creation_expression (Vala.ObjectCreationExpression expr) { - if (!expr.struct_creation) { - signature.append_keyword ("new"); - } - - signature.append_symbol (resolve (expr.symbol_reference)); - - signature.append (" (", false); - - //TODO: rm conditional space - bool first = true; - foreach (Vala.Expression arg in expr.get_argument_list ()) { - if (!first) { - signature.append (", ", false); - } - arg.accept (this); - first = false; - } - - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_sizeof_expression (Vala.SizeofExpression expr) { - signature.append_keyword ("sizeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_typeof_expression (Vala.TypeofExpression expr) { - signature.append_keyword ("typeof", false).append (" (", false); - write_type (expr.type_reference); - signature.append (")", false); - } - - /** - * {@inheritDoc} - */ - public override void visit_lambda_expression (Vala.LambdaExpression expr) { - signature.append ("(", false); - - bool first = true; - foreach (Vala.Parameter param in expr.get_parameters ()) { - if (!first) { - signature.append (", ", false); - } - signature.append (param.name, false); - first = false; - } - - - signature.append (") => {", false); - signature.append_highlighted (" [...] ", false); - signature.append ("}", false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_boolean_literal (Vala.BooleanLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_character_literal (Vala.CharacterLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_integer_literal (Vala.IntegerLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_real_literal (Vala.RealLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_regex_literal (Vala.RegexLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_string_literal (Vala.StringLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - /** - * {@inheritDoc} - */ - public override void visit_null_literal (Vala.NullLiteral lit) { - signature.append_literal (lit.to_string (), false); - } - - - - /** - * {@inheritDoc} - */ - public override void visit_field (Vala.Field field) { - write_node (field); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Vala.Constant constant) { - write_node (constant); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Vala.EnumValue ev) { - write_node (ev); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (Vala.ErrorCode ec) { - write_node (ec); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Vala.Delegate d) { - write_node (d); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Vala.Method m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_creation_method (Vala.CreationMethod m) { - write_node (m); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Vala.Signal sig) { - write_node (sig); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Vala.Class c) { - write_node (c); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Vala.Struct s) { - write_node (s); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Vala.Interface i) { - write_node (i); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Vala.Enum en) { - write_node (en); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (Vala.ErrorDomain ed) { - write_node (ed); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Vala.Property prop) { - write_node (prop); - } -} - diff --git a/src/driver/0.36.x/symbolresolver.vala b/src/driver/0.36.x/symbolresolver.vala deleted file mode 100644 index 4adc06b1a..000000000 --- a/src/driver/0.36.x/symbolresolver.vala +++ /dev/null @@ -1,323 +0,0 @@ -/* symbolresolver.vala - * - * Copyright (C) 2011 Florian Brosch - * - * 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 - * - * Author: - * Florian Brosch - */ - -using Valadoc.Api; -using Gee; - - -public class Valadoc.Drivers.SymbolResolver : Visitor { - private HashMap symbol_map; - private Valadoc.Api.Class glib_error; - private Api.Tree root; - - public SymbolResolver (TreeBuilder builder) { - this.symbol_map = builder.get_symbol_map (); - this.glib_error = builder.get_glib_error (); - } - - public Symbol? resolve (Vala.Symbol symbol) { - return symbol_map.get (symbol); - } - - private void resolve_thrown_list (Symbol symbol, Vala.List types) { - foreach (Vala.DataType type in types) { - Vala.ErrorDomain vala_edom = (Vala.ErrorDomain) type.data_type; - Symbol? edom = symbol_map.get (vala_edom); - symbol.add_child (edom ?? glib_error); - } - } - - private void resolve_array_type_references (Api.Array ptr) { - Api.Item data_type = ptr.data_type; - if (data_type == null) { - // void - } else if (data_type is Api.Array) { - resolve_array_type_references ((Api.Array) data_type); - } else if (data_type is Pointer) { - resolve_pointer_type_references ((Api.Pointer) data_type); - } else { - resolve_type_reference ((TypeReference) data_type); - } - } - - private void resolve_pointer_type_references (Pointer ptr) { - Api.Item type = ptr.data_type; - if (type == null) { - // void - } else if (type is Api.Array) { - resolve_array_type_references ((Api.Array) type); - } else if (type is Pointer) { - resolve_pointer_type_references ((Pointer) type); - } else { - resolve_type_reference ((TypeReference) type); - } - } - - private void resolve_type_reference (TypeReference reference) { - Vala.DataType vtyperef = (Vala.DataType) reference.data; - if (vtyperef is Vala.ErrorType) { - Vala.ErrorDomain verrdom = ((Vala.ErrorType) vtyperef).error_domain; - if (verrdom != null) { - reference.data_type = resolve (verrdom); - } else { - reference.data_type = glib_error; - } - } else if (vtyperef is Vala.DelegateType) { - reference.data_type = resolve (((Vala.DelegateType) vtyperef).delegate_symbol); - } else if (vtyperef is Vala.GenericType) { - reference.data_type = resolve (((Vala.GenericType) vtyperef).type_parameter); - } else if (vtyperef.data_type != null) { - reference.data_type = resolve (vtyperef.data_type); - } - - // Type parameters: - foreach (TypeReference type_param_ref in reference.get_type_arguments ()) { - resolve_type_reference (type_param_ref); - } - - if (reference.data_type is Pointer) { - resolve_pointer_type_references ((Pointer)reference.data_type); - } else if (reference.data_type is Api.Array) { - resolve_array_type_references ((Api.Array)reference.data_type); - } - } - - /** - * {@inheritDoc} - */ - public override void visit_tree (Api.Tree item) { - this.root = item; - item.accept_children (this); - this.root = null; - } - - /** - * {@inheritDoc} - */ - public override void visit_package (Package item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_namespace (Namespace item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_interface (Interface item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (var type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_class (Class item) { - Collection interfaces = item.get_implemented_interface_list (); - foreach (TypeReference type_ref in interfaces) { - resolve_type_reference (type_ref); - } - - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_struct (Struct item) { - if (item.base_type != null) { - resolve_type_reference (item.base_type); - } - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_property (Property item) { - Vala.Property vala_property = item.data as Vala.Property; - Vala.Property? base_vala_property = null; - - if (vala_property.base_property != null) { - base_vala_property = vala_property.base_property; - } else if (vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property == vala_property && vala_property.base_interface_property != null) { - base_vala_property = vala_property.base_interface_property; - } - if (base_vala_property != null) { - item.base_property = (Property?) resolve (base_vala_property); - } - - resolve_type_reference (item.property_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_field (Field item) { - resolve_type_reference (item.field_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_constant (Constant item) { - resolve_type_reference (item.constant_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_delegate (Delegate item) { - Vala.Delegate vala_delegate = item.data as Vala.Delegate; - - resolve_type_reference (item.return_type); - - resolve_thrown_list (item, vala_delegate.get_error_types ()); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_signal (Api.Signal item) { - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_method (Method item) { - Vala.Method vala_method = item.data as Vala.Method; - Vala.Method? base_vala_method = null; - if (vala_method.base_method != null) { - base_vala_method = vala_method.base_method; - } else if (vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method == vala_method && vala_method.base_interface_method != null) { - base_vala_method = vala_method.base_interface_method; - } - if (base_vala_method != null) { - item.base_method = (Method?) resolve (base_vala_method); - } - - resolve_thrown_list (item, vala_method.get_error_types ()); - - resolve_type_reference (item.return_type); - - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_type_parameter (TypeParameter item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_formal_parameter (FormalParameter item) { - if (item.ellipsis) { - return; - } - - if (((Vala.Parameter) item.data).initializer != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.Parameter) item.data).initializer.accept (ibuilder); - item.default_value = signature.get (); - } - - resolve_type_reference (item.parameter_type); - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_domain (ErrorDomain item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_error_code (ErrorCode item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum (Enum item) { - item.accept_all_children (this, false); - } - - /** - * {@inheritDoc} - */ - public override void visit_enum_value (Api.EnumValue item) { - - if (((Vala.EnumValue) item.data).value != null) { - SignatureBuilder signature = new SignatureBuilder (); - InitializerBuilder ibuilder = new InitializerBuilder (signature, symbol_map); - ((Vala.EnumValue) item.data).value.accept (ibuilder); - item.default_value = signature.get (); - } - - item.accept_all_children (this, false); - } -} - - - diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am deleted file mode 100644 index 87d89a6c7..000000000 --- a/src/driver/Makefile.am +++ /dev/null @@ -1,51 +0,0 @@ -NULL = - -if HAVE_LIBVALA_0_20_X -DRIVER_0_20_X_DIR = 0.20.x -endif - -if HAVE_LIBVALA_0_22_X -DRIVER_0_22_X_DIR = 0.22.x -endif - -if HAVE_LIBVALA_0_24_X -DRIVER_0_24_X_DIR = 0.24.x -endif - -if HAVE_LIBVALA_0_26_X -DRIVER_0_26_X_DIR = 0.26.x -endif - -if HAVE_LIBVALA_0_28_X -DRIVER_0_28_X_DIR = 0.28.x -endif - -if HAVE_LIBVALA_0_30_X -DRIVER_0_30_X_DIR = 0.30.x -endif - -if HAVE_LIBVALA_0_32_X -DRIVER_0_32_X_DIR = 0.32.x -endif - -if HAVE_LIBVALA_0_34_X -DRIVER_0_34_X_DIR = 0.34.x -endif - -if HAVE_LIBVALA_0_36_X -DRIVER_0_36_X_DIR = 0.36.x -endif - - -SUBDIRS = \ - $(DRIVER_0_20_X_DIR) \ - $(DRIVER_0_22_X_DIR) \ - $(DRIVER_0_24_X_DIR) \ - $(DRIVER_0_26_X_DIR) \ - $(DRIVER_0_28_X_DIR) \ - $(DRIVER_0_30_X_DIR) \ - $(DRIVER_0_32_X_DIR) \ - $(DRIVER_0_34_X_DIR) \ - $(DRIVER_0_36_X_DIR) \ - $(NULL) - diff --git a/src/vapi/config.vapi b/src/vapi/config.vapi deleted file mode 100644 index 55fed8674..000000000 --- a/src/vapi/config.vapi +++ /dev/null @@ -1,21 +0,0 @@ -/* config.vapi - * - * Author: - * Florian Brosch - */ - -[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] -namespace Config { - [CCode (cname = "PACKAGE_VERSION")] - public const string version; - - [CCode (cname = "PACKAGE_DATADIR")] - public const string plugin_dir; - - [CCode (cname = "PACKAGE_VAPIDIR")] - public const string vapi_dir; - - [CCode (cname = "DEFAULT_DRIVER")] - public const string default_driver; -} - diff --git a/src/vapi/libgvc.vapi b/src/vapi/libgvc.vapi deleted file mode 100644 index 58219c898..000000000 --- a/src/vapi/libgvc.vapi +++ /dev/null @@ -1,237 +0,0 @@ -/* - * libgvc.vapi - * - * Copyright (C) 2009 Martin Olsson - * - * 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 - * - * Author: - * Martin Olsson - */ - -[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "graphviz/gvc.h")] -namespace Gvc { - - [CCode (cname = "aginitlib", cheader_filename="gvc.h")] - public void initlib ( size_t graphinfo, size_t nodeinfo, size_t edgeinfo); - - [CCode (cname = "aginit")] -#if WITH_CGRAPH - public void init (Graph g, int kind, string rec_name, bool move_to_front); -#else - public void init (); -#endif - - -#if WITH_CGRAPH - [SimpleType] - [CCode (cname = "Agdesc_t")] - public struct Desc { - } - - public Desc Agdirected; // Desc.DIRECTED | Desc.MAINGRAPH; - public Desc Agstrictdirected; // Desc.DIRECTED | Desc.STRICT | Desc.MAINGRAPH; - public Desc Agundirected; // Desc.MAINGRAPH; - public Desc Agstrictundirected; // Desc.STRICT | Desc.MAINGRAPH; -#else - [CCode (cprefix = "")] - public enum GraphKind { - AGRAPH, - AGRAPHSTRICT, - AGDIGRAPH, - AGDIGRAPHSTRICT, - AGMETAGRAPH, - } -#endif - - [CCode (cname = "agerrlevel_t", cheader_filename = "gvc.h", cprefix = "")] - public enum ErrorLevel { - AGWARN, - AGERR, - AGMAX, - AGPREV - } - - [Compact] - [CCode (cname = "GVC_t", free_function = "gvFreeContext")] - public class Context { - [CCode (cname = "gvContext")] - public Context (); - - [CCode (cname = "gvParseArgs")] - public int parse_args ( [CCode (array_length_pos = 0.9)] string[] argv ); - - [CCode (cname = "gvLayout")] - public int layout (Graph graph, [CCode (type = "char*")] string layout_engine); - - [CCode (cname = "gvFreeLayout")] - public int free_layout (Graph graph); - - [CCode (cname = "gvRender")] - public int render (Graph graph, [CCode (type = "char*")] string file_type, GLib.FileStream? file); - - [CCode (cname = "gvRenderFilename")] - public int render_filename (Graph graph, [CCode (type = "char*")] string file_type, [CCode (type = "char*")] string filename); - - [CCode (cname = "gvLayoutJobs")] - public int layout_jobs (Graph graph); - - [CCode (cname = "gvRenderJobs")] - public int render_jobs (Graph graph); - - [CCode (cname = "gvRenderData")] - public int render_data (Graph graph, [CCode (type = "char*")] string file_type, [CCode (type = "char**")] out uint8[] output_data); - } - - [Compact] - [CCode (cname = "Agnode_t", ref_function = "", unref_function = "", free_function = "")] - public class Node { - [CCode (cname = "name")] - public string name; - - [CCode (cname = "agget")] - public unowned string? get ([CCode (type = "char*")] string attribute_name); - - [CCode (cname = "agset")] - public void set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value); - - [CCode (cname = "agsafeset")] - public void safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value); - } - - [Compact] - [CCode (cname = "Agedge_t", ref_function = "", unref_function = "", free_function = "")] - public class Edge { - [CCode (cname = "agget")] - public unowned string? get ([CCode (type = "char*")] string attribute_name); - - [CCode (cname = "agset")] - public int set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value); - - [CCode (cname = "agsafeset")] - public int safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value); - } - - [Compact] - [CCode (cname = "Agraph_t", free_function = "agclose")] - public class Graph { - [CCode (cname = "agopen")] -#if WITH_CGRAPH - public Graph ([CCode (type = "char*")] string graph_name, Desc desc, int disc = 0); -#else - public Graph ([CCode (type = "char*")] string graph_name, GraphKind kind); -#endif - - [CCode (cname = "agread")] - public static Graph read (GLib.FileStream file); - - [CCode (cname = "agmemread")] - public static Graph read_string (string str); - - [CCode (cname = "agnode")] -#if WITH_CGRAPH - public Node create_node ([CCode (type = "char*")] string node_name, int createflag = 1); -#else - public Node create_node ([CCode (type = "char*")] string node_name); -#endif - - [CCode (cname = "agedge")] -#if WITH_CGRAPH - public Edge create_edge (Node from, Node to, string? name = null, int createflag = 1); -#else - public Edge create_edge (Node from, Node to); -#endif - - [CCode (cname = "agsubg")] - public unowned Graph create_subgraph ([CCode (type = "char*")] string? name); - - [CCode (cname = "agfindsubg")] - public Graph find_subgraph ([CCode (type = "char*")] string name); - - [CCode (cname = "agidsubg")] - public Graph create_subgraph_id (ulong id); - - [CCode (cname = "agfstsubg")] - public Graph get_first_subgraph (); - - [CCode (cname = "agnxtsubg")] - public Graph get_next_subgraph (); - - [CCode (cname = "agparent")] - public Graph get_parent_graph (); - - [CCode (cname = "agdelsubg")] - public int delete_subgraph (Graph subgraph); - - [CCode (cname = "agfindnode")] - public Node? find_node ([CCode (type = "char*")] string node_name); - - [CCode (cname = "agfstnode")] - public Node? get_first_node (); - - [CCode (cname = "agnxtnode")] - public Node? get_next_node (Node node); - - [CCode (cname = "agget")] - public unowned string? get ([CCode (type = "char*")] string attribute_name); - - [CCode (cname = "agset")] - public int set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value); - - [CCode (cname = "agsafeset")] - public int safe_set ([CCode (type = "char*")] string attribute_name, [CCode (type = "char*")] string attribute_value, [CCode (type = "char*")] string? default_value); - - [CCode (cname = "AG_IS_DIRECTED")] - public bool is_directed (); - - [CCode (cname = "AG_IS_STRICT")] - public bool is_strict (); - - } - - [CCode (cname = "char", copy_function = "agdupstr_html", free_function = "agstrfree")] - public class HtmlString : string { - [CCode (cname = "agstrdup_html")] - public HtmlString (string markup); - } - - [CCode(cprefix = "ag")] - namespace Error { - [CCode (cname = "agerrno")] - public static ErrorLevel errno; - - [CCode (cname = "agerr")] - [PrintfFormat] - public static int error (ErrorLevel level, string fmt, ...); - - [CCode (cname = "agerrors")] - public static int errors (); - - [CCode (cname = "agseterr")] - public static void set_error (ErrorLevel err); - - [CCode (cname = "aglasterr")] - public static string? last_error (); - - [CCode (cname = "agerrorf")] - [PrintfFormat] - public static void errorf (string format, ...); - - [CCode (cname = "agwarningf")] - [PrintfFormat] - void warningf (string fmt, ...); - } - -} diff --git a/valadoc.doap b/valadoc.doap deleted file mode 100644 index 088c94b1a..000000000 --- a/valadoc.doap +++ /dev/null @@ -1,36 +0,0 @@ - - - - valadoc - A documentation tool for vala - Valadoc is a documentation generator for generating API documentation -from Vala source code based on libvala. - - - - - - - Vala - - - - Florian Brosch - - flobrosch - - - - - Rico Tzschichholz - - ricotz - - - - - diff --git a/src/valadoc/Makefile.am b/valadoc/Makefile.am similarity index 100% rename from src/valadoc/Makefile.am rename to valadoc/Makefile.am diff --git a/THANKS b/valadoc/THANKS similarity index 100% rename from THANKS rename to valadoc/THANKS diff --git a/src/doclets/Makefile.am b/valadoc/doclets/Makefile.am similarity index 100% rename from src/doclets/Makefile.am rename to valadoc/doclets/Makefile.am diff --git a/src/doclets/devhelp/Makefile.am b/valadoc/doclets/devhelp/Makefile.am similarity index 100% rename from src/doclets/devhelp/Makefile.am rename to valadoc/doclets/devhelp/Makefile.am diff --git a/src/doclets/devhelp/doclet.vala b/valadoc/doclets/devhelp/doclet.vala similarity index 100% rename from src/doclets/devhelp/doclet.vala rename to valadoc/doclets/devhelp/doclet.vala diff --git a/src/doclets/gtkdoc/Makefile.am b/valadoc/doclets/gtkdoc/Makefile.am similarity index 100% rename from src/doclets/gtkdoc/Makefile.am rename to valadoc/doclets/gtkdoc/Makefile.am diff --git a/src/doclets/gtkdoc/commentconverter.vala b/valadoc/doclets/gtkdoc/commentconverter.vala similarity index 100% rename from src/doclets/gtkdoc/commentconverter.vala rename to valadoc/doclets/gtkdoc/commentconverter.vala diff --git a/src/doclets/gtkdoc/dbus.vala b/valadoc/doclets/gtkdoc/dbus.vala similarity index 100% rename from src/doclets/gtkdoc/dbus.vala rename to valadoc/doclets/gtkdoc/dbus.vala diff --git a/src/doclets/gtkdoc/doclet.vala b/valadoc/doclets/gtkdoc/doclet.vala similarity index 100% rename from src/doclets/gtkdoc/doclet.vala rename to valadoc/doclets/gtkdoc/doclet.vala diff --git a/src/doclets/gtkdoc/gcomment.vala b/valadoc/doclets/gtkdoc/gcomment.vala similarity index 100% rename from src/doclets/gtkdoc/gcomment.vala rename to valadoc/doclets/gtkdoc/gcomment.vala diff --git a/src/doclets/gtkdoc/generator.vala b/valadoc/doclets/gtkdoc/generator.vala similarity index 100% rename from src/doclets/gtkdoc/generator.vala rename to valadoc/doclets/gtkdoc/generator.vala diff --git a/src/doclets/gtkdoc/utils.vala b/valadoc/doclets/gtkdoc/utils.vala similarity index 100% rename from src/doclets/gtkdoc/utils.vala rename to valadoc/doclets/gtkdoc/utils.vala diff --git a/src/doclets/html/Makefile.am b/valadoc/doclets/html/Makefile.am similarity index 100% rename from src/doclets/html/Makefile.am rename to valadoc/doclets/html/Makefile.am diff --git a/src/doclets/html/doclet.vala b/valadoc/doclets/html/doclet.vala similarity index 100% rename from src/doclets/html/doclet.vala rename to valadoc/doclets/html/doclet.vala diff --git a/src/driver/0.24.x/driver.vala b/valadoc/driver.vala similarity index 100% rename from src/driver/0.24.x/driver.vala rename to valadoc/driver.vala diff --git a/src/driver/0.20.x/girwriter.vala b/valadoc/girwriter.vala similarity index 100% rename from src/driver/0.20.x/girwriter.vala rename to valadoc/girwriter.vala diff --git a/icons/Makefile.am b/valadoc/icons/Makefile.am similarity index 100% rename from icons/Makefile.am rename to valadoc/icons/Makefile.am diff --git a/icons/abstractclass.png b/valadoc/icons/abstractclass.png similarity index 100% rename from icons/abstractclass.png rename to valadoc/icons/abstractclass.png diff --git a/icons/abstractmethod.png b/valadoc/icons/abstractmethod.png similarity index 100% rename from icons/abstractmethod.png rename to valadoc/icons/abstractmethod.png diff --git a/icons/abstractproperty.png b/valadoc/icons/abstractproperty.png similarity index 100% rename from icons/abstractproperty.png rename to valadoc/icons/abstractproperty.png diff --git a/icons/class.png b/valadoc/icons/class.png similarity index 100% rename from icons/class.png rename to valadoc/icons/class.png diff --git a/icons/coll_close.png b/valadoc/icons/coll_close.png similarity index 100% rename from icons/coll_close.png rename to valadoc/icons/coll_close.png diff --git a/icons/coll_open.png b/valadoc/icons/coll_open.png similarity index 100% rename from icons/coll_open.png rename to valadoc/icons/coll_open.png diff --git a/icons/constant.png b/valadoc/icons/constant.png similarity index 100% rename from icons/constant.png rename to valadoc/icons/constant.png diff --git a/icons/constructor.png b/valadoc/icons/constructor.png similarity index 100% rename from icons/constructor.png rename to valadoc/icons/constructor.png diff --git a/icons/delegate.png b/valadoc/icons/delegate.png similarity index 100% rename from icons/delegate.png rename to valadoc/icons/delegate.png diff --git a/icons/devhelpstyle.css b/valadoc/icons/devhelpstyle.css similarity index 100% rename from icons/devhelpstyle.css rename to valadoc/icons/devhelpstyle.css diff --git a/icons/enum.png b/valadoc/icons/enum.png similarity index 100% rename from icons/enum.png rename to valadoc/icons/enum.png diff --git a/icons/enumvalue.png b/valadoc/icons/enumvalue.png similarity index 100% rename from icons/enumvalue.png rename to valadoc/icons/enumvalue.png diff --git a/icons/errorcode.png b/valadoc/icons/errorcode.png similarity index 100% rename from icons/errorcode.png rename to valadoc/icons/errorcode.png diff --git a/icons/errordomain.png b/valadoc/icons/errordomain.png similarity index 100% rename from icons/errordomain.png rename to valadoc/icons/errordomain.png diff --git a/icons/field.png b/valadoc/icons/field.png similarity index 100% rename from icons/field.png rename to valadoc/icons/field.png diff --git a/icons/interface.png b/valadoc/icons/interface.png similarity index 100% rename from icons/interface.png rename to valadoc/icons/interface.png diff --git a/icons/method.png b/valadoc/icons/method.png similarity index 100% rename from icons/method.png rename to valadoc/icons/method.png diff --git a/icons/namespace.png b/valadoc/icons/namespace.png similarity index 100% rename from icons/namespace.png rename to valadoc/icons/namespace.png diff --git a/icons/package.png b/valadoc/icons/package.png similarity index 100% rename from icons/package.png rename to valadoc/icons/package.png diff --git a/icons/packages.png b/valadoc/icons/packages.png similarity index 100% rename from icons/packages.png rename to valadoc/icons/packages.png diff --git a/icons/property.png b/valadoc/icons/property.png similarity index 100% rename from icons/property.png rename to valadoc/icons/property.png diff --git a/icons/scripts.js b/valadoc/icons/scripts.js similarity index 100% rename from icons/scripts.js rename to valadoc/icons/scripts.js diff --git a/icons/signal.png b/valadoc/icons/signal.png similarity index 100% rename from icons/signal.png rename to valadoc/icons/signal.png diff --git a/icons/staticmethod.png b/valadoc/icons/staticmethod.png similarity index 100% rename from icons/staticmethod.png rename to valadoc/icons/staticmethod.png diff --git a/icons/struct.png b/valadoc/icons/struct.png similarity index 100% rename from icons/struct.png rename to valadoc/icons/struct.png diff --git a/icons/style.css b/valadoc/icons/style.css similarity index 100% rename from icons/style.css rename to valadoc/icons/style.css diff --git a/icons/tip.png b/valadoc/icons/tip.png similarity index 100% rename from icons/tip.png rename to valadoc/icons/tip.png diff --git a/icons/virtualmethod.png b/valadoc/icons/virtualmethod.png similarity index 100% rename from icons/virtualmethod.png rename to valadoc/icons/virtualmethod.png diff --git a/icons/virtualproperty.png b/valadoc/icons/virtualproperty.png similarity index 100% rename from icons/virtualproperty.png rename to valadoc/icons/virtualproperty.png diff --git a/icons/warning.png b/valadoc/icons/warning.png similarity index 100% rename from icons/warning.png rename to valadoc/icons/warning.png diff --git a/icons/wikistyle.css b/valadoc/icons/wikistyle.css similarity index 100% rename from icons/wikistyle.css rename to valadoc/icons/wikistyle.css diff --git a/src/driver/0.20.x/initializerbuilder.vala b/valadoc/initializerbuilder.vala similarity index 100% rename from src/driver/0.20.x/initializerbuilder.vala rename to valadoc/initializerbuilder.vala diff --git a/src/driver/0.20.x/symbolresolver.vala b/valadoc/symbolresolver.vala similarity index 100% rename from src/driver/0.20.x/symbolresolver.vala rename to valadoc/symbolresolver.vala diff --git a/tests/Makefile.am b/valadoc/tests/Makefile.am similarity index 100% rename from tests/Makefile.am rename to valadoc/tests/Makefile.am diff --git a/tests/drivers/api-test.data.vapi b/valadoc/tests/drivers/api-test.data.vapi similarity index 100% rename from tests/drivers/api-test.data.vapi rename to valadoc/tests/drivers/api-test.data.vapi diff --git a/tests/drivers/driver-0-20.vala b/valadoc/tests/drivers/driver-0-20.vala similarity index 100% rename from tests/drivers/driver-0-20.vala rename to valadoc/tests/drivers/driver-0-20.vala diff --git a/tests/drivers/driver-0-22.vala b/valadoc/tests/drivers/driver-0-22.vala similarity index 100% rename from tests/drivers/driver-0-22.vala rename to valadoc/tests/drivers/driver-0-22.vala diff --git a/tests/drivers/driver-0-24.vala b/valadoc/tests/drivers/driver-0-24.vala similarity index 100% rename from tests/drivers/driver-0-24.vala rename to valadoc/tests/drivers/driver-0-24.vala diff --git a/tests/drivers/driver-0-26.vala b/valadoc/tests/drivers/driver-0-26.vala similarity index 100% rename from tests/drivers/driver-0-26.vala rename to valadoc/tests/drivers/driver-0-26.vala diff --git a/tests/drivers/driver-0-28.vala b/valadoc/tests/drivers/driver-0-28.vala similarity index 100% rename from tests/drivers/driver-0-28.vala rename to valadoc/tests/drivers/driver-0-28.vala diff --git a/tests/drivers/driver-0-30.vala b/valadoc/tests/drivers/driver-0-30.vala similarity index 100% rename from tests/drivers/driver-0-30.vala rename to valadoc/tests/drivers/driver-0-30.vala diff --git a/tests/drivers/driver-0-32.vala b/valadoc/tests/drivers/driver-0-32.vala similarity index 100% rename from tests/drivers/driver-0-32.vala rename to valadoc/tests/drivers/driver-0-32.vala diff --git a/tests/drivers/driver-0-34.vala b/valadoc/tests/drivers/driver-0-34.vala similarity index 100% rename from tests/drivers/driver-0-34.vala rename to valadoc/tests/drivers/driver-0-34.vala diff --git a/tests/drivers/driver-0-36.vala b/valadoc/tests/drivers/driver-0-36.vala similarity index 100% rename from tests/drivers/driver-0-36.vala rename to valadoc/tests/drivers/driver-0-36.vala diff --git a/tests/drivers/generic-api-test.vala b/valadoc/tests/drivers/generic-api-test.vala similarity index 100% rename from tests/drivers/generic-api-test.vala rename to valadoc/tests/drivers/generic-api-test.vala diff --git a/tests/libvaladoc/errorreporter.vala b/valadoc/tests/libvaladoc/errorreporter.vala similarity index 100% rename from tests/libvaladoc/errorreporter.vala rename to valadoc/tests/libvaladoc/errorreporter.vala diff --git a/tests/libvaladoc/gtkdoc-scanner.vala b/valadoc/tests/libvaladoc/gtkdoc-scanner.vala similarity index 100% rename from tests/libvaladoc/gtkdoc-scanner.vala rename to valadoc/tests/libvaladoc/gtkdoc-scanner.vala diff --git a/tests/libvaladoc/markupreader.vala b/valadoc/tests/libvaladoc/markupreader.vala similarity index 100% rename from tests/libvaladoc/markupreader.vala rename to valadoc/tests/libvaladoc/markupreader.vala diff --git a/tests/libvaladoc/parser/generic-scanner.vala b/valadoc/tests/libvaladoc/parser/generic-scanner.vala similarity index 100% rename from tests/libvaladoc/parser/generic-scanner.vala rename to valadoc/tests/libvaladoc/parser/generic-scanner.vala diff --git a/tests/libvaladoc/parser/manyrule.vala b/valadoc/tests/libvaladoc/parser/manyrule.vala similarity index 100% rename from tests/libvaladoc/parser/manyrule.vala rename to valadoc/tests/libvaladoc/parser/manyrule.vala diff --git a/tests/libvaladoc/parser/oneofrule.vala b/valadoc/tests/libvaladoc/parser/oneofrule.vala similarity index 100% rename from tests/libvaladoc/parser/oneofrule.vala rename to valadoc/tests/libvaladoc/parser/oneofrule.vala diff --git a/tests/libvaladoc/parser/optionalrule.vala b/valadoc/tests/libvaladoc/parser/optionalrule.vala similarity index 100% rename from tests/libvaladoc/parser/optionalrule.vala rename to valadoc/tests/libvaladoc/parser/optionalrule.vala diff --git a/tests/libvaladoc/parser/sequencerule.vala b/valadoc/tests/libvaladoc/parser/sequencerule.vala similarity index 100% rename from tests/libvaladoc/parser/sequencerule.vala rename to valadoc/tests/libvaladoc/parser/sequencerule.vala diff --git a/tests/libvaladoc/parser/stubrule.vala b/valadoc/tests/libvaladoc/parser/stubrule.vala similarity index 100% rename from tests/libvaladoc/parser/stubrule.vala rename to valadoc/tests/libvaladoc/parser/stubrule.vala diff --git a/tests/testrunner.sh b/valadoc/tests/testrunner.sh similarity index 100% rename from tests/testrunner.sh rename to valadoc/tests/testrunner.sh diff --git a/src/driver/0.36.x/treebuilder.vala b/valadoc/treebuilder.vala similarity index 100% rename from src/driver/0.36.x/treebuilder.vala rename to valadoc/treebuilder.vala diff --git a/src/valadoc/valadoc.vala b/valadoc/valadoc.vala similarity index 100% rename from src/valadoc/valadoc.vala rename to valadoc/valadoc.vala -- 2.47.3