From 0ae4d5508c1326935a7c52d719bb2a96631761ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Fri, 26 May 2006 09:56:54 +0000 Subject: [PATCH] fix member access to namespaces adapt to CCodeWriter changes don't touch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2006-05-26 Jürg Billeter * vala/valasemanticanalyzer.vala: fix member access to namespaces * vala/valacodegenerator.vala: adapt to CCodeWriter changes * ccode/valaccodewriter.vala: don't touch file if nothing has changed, required to get incremental builds working * vapi/glib-2.0.vala: extend file functions * ccode/Makefile.am,vala/Makefile.am,compiler/Makefile.am: support incremental builds svn path=/trunk/; revision=37 --- vala/ChangeLog | 11 +++ vala/ccode/Makefile.am | 90 +++++++++++---------- vala/ccode/valaccodewriter.vala | 42 +++++++++- vala/compiler/Makefile.am | 13 +-- vala/vala/Makefile.am | 155 ++++++++++++++++++------------------ vala/vala/valacodegenerator.vala | 4 +- vala/vala/valasemanticanalyzer.vala | 2 +- vala/vapi/glib-2.0.vala | 24 +++++- 8 files changed, 208 insertions(+), 133 deletions(-) diff --git a/vala/ChangeLog b/vala/ChangeLog index f52afb9..08ed9c1 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,3 +1,14 @@ +2006-05-26 Jürg Billeter + + * vala/valasemanticanalyzer.vala: fix member access to namespaces + * vala/valacodegenerator.vala: adapt to CCodeWriter changes + * ccode/valaccodewriter.vala: don't touch file if nothing has changed, + required to get incremental builds working + * vapi/glib-2.0.vala: extend file functions + + * ccode/Makefile.am,vala/Makefile.am,compiler/Makefile.am: support + incremental builds + 2006-05-25 Jürg Billeter * vala/scanner.l: support ELLIPSIS, use g_strdup instead of strdup diff --git a/vala/ccode/Makefile.am b/vala/ccode/Makefile.am index e26f458..ab53e7e 100644 --- a/vala/ccode/Makefile.am +++ b/vala/ccode/Makefile.am @@ -4,141 +4,145 @@ INCLUDES = \ $(GLIB_CFLAGS) \ $(NULL) +BUILT_SOURCES = valaccode.vala.stamp + noinst_LTLIBRARIES = \ libvalaccode.la $(NULL) libvalaccode_la_VALASOURCES = \ - valaccodeassignment.vala \ - valaccodebinaryexpression.vala \ - valaccodeblock.vala \ - valaccodebreakstatement.vala \ - valaccodecasestatement.vala \ - valaccodecomment.vala \ - valaccodeconstant.vala \ - valaccodecontinuestatement.vala \ - valaccodedeclaration.vala \ - valaccodedeclarator.vala \ - valaccodeemptystatement.vala \ - valaccodeenum.vala \ - valaccodeexpressionstatement.vala \ - valaccodeexpression.vala \ - valaccodeformalparameter.vala \ - valaccodeforstatement.vala \ - valaccodefragment.vala \ - valaccodefunctioncall.vala \ - valaccodefunctiondeclarator.vala \ - valaccodefunction.vala \ - valaccodeidentifier.vala \ - valaccodeifstatement.vala \ - valaccodeincludedirective.vala \ - valaccodeinitializerlist.vala \ - valaccodemacroreplacement.vala \ - valaccodememberaccess.vala \ - valaccodemodifiers.vala \ - valaccodenewline.vala \ - valaccodenode.vala \ - valaccodeoncesection.vala \ - valaccodeparenthesizedexpression.vala \ - valaccodereturnstatement.vala \ - valaccodestatement.vala \ - valaccodestruct.vala \ - valaccodeswitchstatement.vala \ - valaccodetypedefinition.vala \ - valaccodeunaryexpression.vala \ - valaccodevariabledeclarator.vala \ - valaccodewhilestatement.vala \ - valaccodewriter.vala \ $(NULL) libvalaccode_la_SOURCES = \ + valaccode.vala.stamp \ valaccodeassignment.c \ valaccodeassignment.h \ + valaccodeassignment.vala \ valaccodebinaryexpression.c \ valaccodebinaryexpression.h \ + valaccodebinaryexpression.vala \ valaccodeblock.c \ valaccodeblock.h \ + valaccodeblock.vala \ valaccodebreakstatement.c \ valaccodebreakstatement.h \ + valaccodebreakstatement.vala \ valaccodecasestatement.c \ valaccodecasestatement.h \ + valaccodecasestatement.vala \ valaccodecomment.c \ valaccodecomment.h \ + valaccodecomment.vala \ valaccodeconstant.c \ valaccodeconstant.h \ + valaccodeconstant.vala \ valaccodecontinuestatement.c \ valaccodecontinuestatement.h \ + valaccodecontinuestatement.vala \ valaccodedeclaration.c \ valaccodedeclaration.h \ + valaccodedeclaration.vala \ valaccodedeclarator.c \ valaccodedeclarator.h \ + valaccodedeclarator.vala \ valaccodeemptystatement.c \ valaccodeemptystatement.h \ + valaccodeemptystatement.vala \ valaccodeenum.c \ valaccodeenum.h \ + valaccodeenum.vala \ valaccodeexpression.c \ valaccodeexpression.h \ + valaccodeexpression.vala \ valaccodeexpressionstatement.c \ valaccodeexpressionstatement.h \ + valaccodeexpressionstatement.vala \ valaccodeformalparameter.c \ valaccodeformalparameter.h \ + valaccodeformalparameter.vala \ valaccodeforstatement.c \ valaccodeforstatement.h \ + valaccodeforstatement.vala \ valaccodefragment.c \ valaccodefragment.h \ + valaccodefragment.vala \ valaccodefunction.c \ + valaccodefunction.h \ + valaccodefunction.vala \ valaccodefunctioncall.c \ valaccodefunctioncall.h \ + valaccodefunctioncall.vala \ valaccodefunctiondeclarator.c \ valaccodefunctiondeclarator.h \ - valaccodefunction.h \ + valaccodefunctiondeclarator.vala \ valaccodeidentifier.c \ valaccodeidentifier.h \ + valaccodeidentifier.vala \ valaccodeifstatement.c \ valaccodeifstatement.h \ + valaccodeifstatement.vala \ valaccodeincludedirective.c \ valaccodeincludedirective.h \ + valaccodeincludedirective.vala \ valaccodeinitializerlist.c \ valaccodeinitializerlist.h \ + valaccodeinitializerlist.vala \ valaccodemacroreplacement.c \ valaccodemacroreplacement.h \ + valaccodemacroreplacement.vala \ valaccodememberaccess.c \ valaccodememberaccess.h \ + valaccodememberaccess.vala \ valaccodemodifiers.c \ valaccodemodifiers.h \ + valaccodemodifiers.vala \ valaccodenewline.c \ valaccodenewline.h \ + valaccodenewline.vala \ valaccodenode.c \ valaccodenode.h \ + valaccodenode.vala \ valaccodeoncesection.c \ valaccodeoncesection.h \ + valaccodeoncesection.vala \ valaccodeparenthesizedexpression.c \ valaccodeparenthesizedexpression.h \ + valaccodeparenthesizedexpression.vala \ valaccodereturnstatement.c \ valaccodereturnstatement.h \ + valaccodereturnstatement.vala \ valaccodestatement.c \ valaccodestatement.h \ + valaccodestatement.vala \ valaccodestruct.c \ valaccodestruct.h \ + valaccodestruct.vala \ valaccodeswitchstatement.c \ valaccodeswitchstatement.h \ + valaccodeswitchstatement.vala \ valaccodetypedefinition.c \ valaccodetypedefinition.h \ + valaccodetypedefinition.vala \ valaccodeunaryexpression.c \ valaccodeunaryexpression.h \ + valaccodeunaryexpression.vala \ valaccodevariabledeclarator.c \ valaccodevariabledeclarator.h \ + valaccodevariabledeclarator.vala \ valaccodewhilestatement.c \ valaccodewhilestatement.h \ + valaccodewhilestatement.vala \ valaccodewriter.c \ valaccodewriter.h \ + valaccodewriter.vala \ $(NULL) -$(subst .vala,.c,$(libvalaccode_la_VALASOURCES)) $(subst .vala,.h,$(libvalaccode_la_VALASOURCES)) valaccode.vala: $(libvalaccode_la_VALASOURCES) +valaccode.vala valaccode.vala.stamp: $(filter %.vala,$(libvalaccode_la_SOURCES)) $(VALAC) --vapidir $(srcdir)/../vapi --library valaccode $^ + touch $@ libvalaccode_la_LIBADD = \ $(GLIB_LIBS) \ $(NULL) -EXTRA_DIST = $(libvalaccode_la_VALASOURCES) valaccode.vala +EXTRA_DIST = valaccode.vala valaccode.vala.stamp diff --git a/vala/ccode/valaccodewriter.vala b/vala/ccode/valaccodewriter.vala index 57065e3..9722167 100644 --- a/vala/ccode/valaccodewriter.vala +++ b/vala/ccode/valaccodewriter.vala @@ -24,7 +24,26 @@ using GLib; namespace Vala { public class CCodeWriter { - public File stream { get; construct; } + string _filename; + string temp_filename; + bool file_exists; + public string filename { + get { + return _filename; + } + construct { + _filename = value; + file_exists = File.test (_filename, FileTest.EXISTS); + if (file_exists) { + temp_filename = "%s.valatmp".printf (_filename); + stream = File.open (temp_filename, "w"); + } else { + stream = File.open (_filename, "w"); + } + } + } + + File stream; int indent; /* at begin of line */ @@ -32,6 +51,27 @@ namespace Vala { public void close () { stream.close (); + + if (file_exists) { + var changed = true; + + var old_file = MappedFile.new (_filename, false, null); + var new_file = MappedFile.new (temp_filename, false, null); + var len = old_file.get_length (); + if (len == new_file.get_length ()) { + if (Memory.cmp (old_file.get_contents (), new_file.get_contents (), len) == 0) { + changed = false; + } + } + old_file.free (); + new_file.free (); + + if (changed) { + File.rename (temp_filename, _filename); + } else { + File.unlink (temp_filename); + } + } } public void write_indent () { diff --git a/vala/compiler/Makefile.am b/vala/compiler/Makefile.am index 55201e0..971d7d7 100644 --- a/vala/compiler/Makefile.am +++ b/vala/compiler/Makefile.am @@ -6,21 +6,22 @@ INCLUDES = \ -I../vala \ $(NULL) +BUILT_SOURCES = valac.vala.stamp + bin_PROGRAMS = \ valac \ $(NULL) -valac_VALASOURCES = \ - valacompiler.vala \ - $(NULL) - valac_SOURCES = \ + valac.vala.stamp \ valacompiler.c \ valacompiler.h \ + valacompiler.vala \ $(NULL) -$(subst .vala,.c,$(valac_VALASOURCES)) $(subst .vala,.h,$(valac_VALASOURCES)): $(valac_VALASOURCES) +valac.vala.stamp: $(filter %.vala,$(valac_SOURCES)) $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg valaccode --vapidir ../vala --pkg vala $^ + touch $@ valac_LDADD = \ $(GLIB_LIBS) \ @@ -28,4 +29,4 @@ valac_LDADD = \ ../vala/libvala.la \ $(NULL) -EXTRA_DIST = $(valac_VALASOURCES) +EXTRA_DIST = valac.vala.stamp diff --git a/vala/vala/Makefile.am b/vala/vala/Makefile.am index 2a0e267..89d7904 100644 --- a/vala/vala/Makefile.am +++ b/vala/vala/Makefile.am @@ -5,234 +5,231 @@ INCLUDES = \ -I ../ccode \ $(NULL) -BUILT_SOURCES = parser.h +BUILT_SOURCES = parser.h vala.vala.stamp AM_YFLAGS = -d noinst_LTLIBRARIES = \ libvala.la $(NULL) -libvala_la_VALASOURCES = \ - valaassignment.vala \ - valaattributeprocessor.vala \ - valaattribute.vala \ - valabinaryexpression.vala \ - valablock.vala \ - valabooleanliteral.vala \ - valabreakstatement.vala \ - valacastexpression.vala \ - valacharacterliteral.vala \ - valaclass.vala \ - valacodecontext.vala \ - valacodegenerator.vala \ - valacodenode.vala \ - valacodevisitor.vala \ - valaconditionalexpression.vala \ - valaconstant.vala \ - valacontinuestatement.vala \ - valadeclarationstatement.vala \ - valaemptystatement.vala \ - valaenum.vala \ - valaenumvalue.vala \ - valaexpressionstatement.vala \ - valaexpression.vala \ - valafield.vala \ - valaforeachstatement.vala \ - valaformalparameter.vala \ - valaforstatement.vala \ - valaifstatement.vala \ - valainitializerlist.vala \ - valaintegerliteral.vala \ - valainterfacewriter.vala \ - valainvocationexpression.vala \ - valaliteralexpression.vala \ - valaliteral.vala \ - valalocalvariabledeclaration.vala \ - valamemberaccessibility.vala \ - valamemberaccess.vala \ - valamethod.vala \ - valanamedargument.vala \ - valanamespacereference.vala \ - valanamespace.vala \ - valanullliteral.vala \ - valaobjectcreationexpression.vala \ - valaparenthesizedexpression.vala \ - valaparser.vala \ - valapostfixexpression.vala \ - valapropertyaccessor.vala \ - valaproperty.vala \ - valareport.vala \ - valareturnstatement.vala \ - valasemanticanalyzer.vala \ - valasimplename.vala \ - valasourcefilecycle.vala \ - valasourcefile.vala \ - valasourcereference.vala \ - valastatement.vala \ - valastringliteral.vala \ - valastruct.vala \ - valasymbolbuilder.vala \ - valasymbolresolver.vala \ - valasymbol.vala \ - valatypecheck.vala \ - valatypeparameter.vala \ - valatypereference.vala \ - valatype.vala \ - valaunaryexpression.vala \ - valavariabledeclarator.vala \ - valawhilestatement.vala \ - $(NULL) - libvala_la_SOURCES = \ parser.y \ scanner.l \ vala.h \ + vala.vala.stamp \ valaassignment.c \ valaassignment.h \ + valaassignment.vala \ valaattribute.c \ valaattribute.h \ + valaattribute.vala \ valaattributeprocessor.c \ valaattributeprocessor.h \ + valaattributeprocessor.vala \ valabinaryexpression.c \ valabinaryexpression.h \ + valabinaryexpression.vala \ valablock.c \ valablock.h \ + valablock.vala \ valabooleanliteral.c \ valabooleanliteral.h \ + valabooleanliteral.vala \ valabreakstatement.c \ valabreakstatement.h \ + valabreakstatement.vala \ valacastexpression.c \ valacastexpression.h \ + valacastexpression.vala \ valacharacterliteral.c \ valacharacterliteral.h \ + valacharacterliteral.vala \ valaclass.c \ valaclass.h \ + valaclass.vala \ valacodecontext.c \ valacodecontext.h \ + valacodecontext.vala \ valacodegenerator.c \ valacodegenerator.h \ + valacodegenerator.vala \ valacodenode.c \ valacodenode.h \ + valacodenode.vala \ valacodevisitor.c \ valacodevisitor.h \ + valacodevisitor.vala \ valaconditionalexpression.c \ valaconditionalexpression.h \ + valaconditionalexpression.vala \ valaconstant.c \ valaconstant.h \ + valaconstant.vala \ valacontinuestatement.c \ valacontinuestatement.h \ + valacontinuestatement.vala \ valadeclarationstatement.c \ valadeclarationstatement.h \ + valadeclarationstatement.vala \ valaemptystatement.c \ valaemptystatement.h \ + valaemptystatement.vala \ valaenum.c \ valaenum.h \ + valaenum.vala \ valaenumvalue.c \ valaenumvalue.h \ + valaenumvalue.vala \ valaexpression.c \ valaexpression.h \ + valaexpression.vala \ valaexpressionstatement.c \ valaexpressionstatement.h \ + valaexpressionstatement.vala \ valafield.c \ valafield.h \ + valafield.vala \ valaforeachstatement.c \ valaforeachstatement.h \ + valaforeachstatement.vala \ valaformalparameter.c \ valaformalparameter.h \ + valaformalparameter.vala \ valaforstatement.c \ valaforstatement.h \ + valaforstatement.vala \ valaifstatement.c \ valaifstatement.h \ + valaifstatement.vala \ valainitializerlist.c \ valainitializerlist.h \ + valainitializerlist.vala \ valaintegerliteral.c \ valaintegerliteral.h \ + valaintegerliteral.vala \ valainterfacewriter.c \ valainterfacewriter.h \ + valainterfacewriter.vala \ valainvocationexpression.c \ valainvocationexpression.h \ + valainvocationexpression.vala \ valaliteral.c \ + valaliteral.h \ + valaliteral.vala \ valaliteralexpression.c \ valaliteralexpression.h \ - valaliteral.h \ + valaliteralexpression.vala \ valalocalvariabledeclaration.c \ valalocalvariabledeclaration.h \ + valalocalvariabledeclaration.vala \ valamemberaccess.c \ valamemberaccess.h \ + valamemberaccess.vala \ valamemberaccessibility.c \ valamemberaccessibility.h \ + valamemberaccessibility.vala \ valamethod.c \ valamethod.h \ + valamethod.vala \ valanamedargument.c \ valanamedargument.h \ + valanamedargument.vala \ valanamespace.c \ valanamespace.h \ + valanamespace.vala \ valanamespacereference.c \ valanamespacereference.h \ + valanamespacereference.vala \ valanullliteral.c \ valanullliteral.h \ + valanullliteral.vala \ valaobjectcreationexpression.c \ valaobjectcreationexpression.h \ + valaobjectcreationexpression.vala \ valaparenthesizedexpression.c \ valaparenthesizedexpression.h \ + valaparenthesizedexpression.vala \ valaparser.c \ valaparser.h \ + valaparser.vala \ valapostfixexpression.c \ valapostfixexpression.h \ + valapostfixexpression.vala \ valapropertyaccessor.c \ valapropertyaccessor.h \ + valapropertyaccessor.vala \ valaproperty.c \ valaproperty.h \ + valaproperty.vala \ valareport.c \ valareport.h \ + valareport.vala \ valareturnstatement.c \ valareturnstatement.h \ + valareturnstatement.vala \ valasemanticanalyzer.c \ valasemanticanalyzer.h \ + valasemanticanalyzer.vala \ valasimplename.c \ valasimplename.h \ + valasimplename.vala \ valasourcefile.c \ + valasourcefile.h \ + valasourcefile.vala \ valasourcefilecycle.c \ valasourcefilecycle.h \ - valasourcefile.h \ + valasourcefilecycle.vala \ valasourcereference.c \ valasourcereference.h \ + valasourcereference.vala \ valastatement.c \ valastatement.h \ + valastatement.vala \ valastringliteral.c \ valastringliteral.h \ + valastringliteral.vala \ valastruct.c \ valastruct.h \ + valastruct.vala \ valasymbolbuilder.c \ valasymbolbuilder.h \ + valasymbolbuilder.vala \ valasymbol.c \ valasymbol.h \ + valasymbol.vala \ valasymbolresolver.c \ valasymbolresolver.h \ + valasymbolresolver.vala \ valatype.c \ + valatype.h \ + valatype.vala \ valatypecheck.c \ valatypecheck.h \ - valatype.h \ + valatypecheck.vala \ valatypeparameter.c \ valatypeparameter.h \ + valatypeparameter.vala \ valatypereference.c \ valatypereference.h \ + valatypereference.vala \ valaunaryexpression.c \ valaunaryexpression.h \ + valaunaryexpression.vala \ valavariabledeclarator.c \ valavariabledeclarator.h \ + valavariabledeclarator.vala \ valawhilestatement.c \ valawhilestatement.h \ + valawhilestatement.vala \ $(NULL) -vala.h: vala.vala - -$(subst .vala,.c,$(libvala_la_VALASOURCES)) $(subst .vala,.h,$(libvala_la_VALASOURCES)) vala.vala: $(libvala_la_VALASOURCES) +vala.vala vala.vala.stamp: $(filter %.vala,$(libvala_la_SOURCES)) $(VALAC) --vapidir $(srcdir)/../vapi --vapidir ../ccode --pkg valaccode --library vala $^ + touch $@ libvala_la_LIBADD = \ $(GLIB_LIBS) \ ../ccode/libvalaccode.la \ $(NULL) -EXTRA_DIST = $(libvala_la_VALASOURCES) vala.vala +EXTRA_DIST = vala.vala vala.vala.stamp diff --git a/vala/vala/valacodegenerator.vala b/vala/vala/valacodegenerator.vala index 60626e4..2aca867 100644 --- a/vala/vala/valacodegenerator.vala +++ b/vala/vala/valacodegenerator.vala @@ -132,7 +132,7 @@ namespace Vala { comment = new CCodeComment (text = source_file.comment); } - var writer = new CCodeWriter (stream = File.open (source_file.get_cheader_filename (), "w")); + var writer = new CCodeWriter (filename = source_file.get_cheader_filename ()); if (comment != null) { comment.write (writer); } @@ -156,7 +156,7 @@ namespace Vala { once.write (writer); writer.close (); - writer = new CCodeWriter (stream = File.open (source_file.get_csource_filename (), "w")); + writer = new CCodeWriter (filename = source_file.get_csource_filename ()); if (comment != null) { comment.write (writer); } diff --git a/vala/vala/valasemanticanalyzer.vala b/vala/vala/valasemanticanalyzer.vala index 1393676..3ff0cdd 100644 --- a/vala/vala/valasemanticanalyzer.vala +++ b/vala/vala/valasemanticanalyzer.vala @@ -272,7 +272,7 @@ namespace Vala { public override void visit_member_access (MemberAccess expr) { if (expr.inner.static_type == null) { - if (expr.inner.symbol_reference.node is Type_) { + if (expr.inner.symbol_reference.node is Namespace || expr.inner.symbol_reference.node is Type_) { expr.symbol_reference = expr.inner.symbol_reference.lookup (expr.member_name); } } diff --git a/vala/vapi/glib-2.0.vala b/vala/vapi/glib-2.0.vala index 44ecf0d..ac5e55f 100644 --- a/vala/vapi/glib-2.0.vala +++ b/vala/vapi/glib-2.0.vala @@ -207,6 +207,8 @@ namespace GLib { public struct File { [CCode (cname = "fopen")] public static ref File open (string path, string mode); + [CCode (cname = "fdopen")] + public static ref File fdopen (int fildes, string mode); [CCode (cname = "fprintf")] public void printf (string format, ...); [InstanceLast ()] @@ -219,6 +221,27 @@ namespace GLib { public void close (); public static bool test (string filename, FileTest test); + public static int open_tmp (string tmpl, out string name_used, out Error error); + + [CCode (cname = "g_rename")] + public static int rename (string oldfilename, string newfilename); + [CCode (cname = "g_unlink")] + public static int unlink (string filename); + } + + [ReferenceType ()] + public struct MappedFile { + public static ref MappedFile new (string filename, bool writable, out Error error); + public void free (); + public long get_length (); + public char[] get_contents (); + } + + [ReferenceType ()] + [CCode (cname = "char", cheader_filename = "string.h")] + public struct Memory { + [CCode (cname = "memcmp")] + public static int cmp (char[] s1, char[] s2, long n); } [CCode (cname = "stdout", cheader_filename = "stdio.h")] @@ -227,7 +250,6 @@ namespace GLib { [CCode (cname = "stderr", cheader_filename = "stdio.h")] public static File stderr; - [Unknown (reference_type = true)] [ReferenceType ()] public struct OptionContext { public static ref OptionContext new (string parameter_string); -- 2.7.4