From 02a0d954704796b52b72b4aa157f56a633f6b10d Mon Sep 17 00:00:00 2001 From: Tak Date: Mon, 13 Jun 2011 17:22:14 +0200 Subject: [Vala] Move to vala 0.12. *: Move to vala 0.12. License: MIT/X11 --- extras/ValaBinding/Gui/ParameterDataProvider.cs | 3 +- extras/ValaBinding/Gui/ValaTextEditorExtension.cs | 2 +- .../ValaBinding/MonoDevelop.ValaBinding.dll.config | 5 +- extras/ValaBinding/Parser/Afrodite.cs | 74 +++++++++++++--------- extras/ValaBinding/Parser/ProjectInformation.cs | 4 +- extras/ValaBinding/configure.in | 6 +- 6 files changed, 55 insertions(+), 39 deletions(-) (limited to 'extras/ValaBinding') diff --git a/extras/ValaBinding/Gui/ParameterDataProvider.cs b/extras/ValaBinding/Gui/ParameterDataProvider.cs index d047bca3ef..26105ed851 100644 --- a/extras/ValaBinding/Gui/ParameterDataProvider.cs +++ b/extras/ValaBinding/Gui/ParameterDataProvider.cs @@ -138,6 +138,7 @@ namespace MonoDevelop.ValaBinding int len = function.FullyQualifiedName.LastIndexOf ("."); string prename = null; + string returnType = (function.ReturnType == null)? string.Empty: function.ReturnType.TypeName; if (len > 0) prename = function.FullyQualifiedName.Substring (0, len + 1); @@ -149,7 +150,7 @@ namespace MonoDevelop.ValaBinding return string.Format ("{2} {3}{0}({1})", GLib.Markup.EscapeText (function.Name), paramTxt, - GLib.Markup.EscapeText (function.ReturnType.TypeName), + GLib.Markup.EscapeText (returnType), GLib.Markup.EscapeText (prename)); // return prename + "" + function.Name + "" + " (" + paramTxt + ")" + cons; } diff --git a/extras/ValaBinding/Gui/ValaTextEditorExtension.cs b/extras/ValaBinding/Gui/ValaTextEditorExtension.cs index a905ebd9e8..058c043e93 100644 --- a/extras/ValaBinding/Gui/ValaTextEditorExtension.cs +++ b/extras/ValaBinding/Gui/ValaTextEditorExtension.cs @@ -111,7 +111,7 @@ namespace MonoDevelop.ValaBinding string lineText = null; ProjectInformation parser = Parser; var loc = Editor.Document.OffsetToLocation (completionContext.TriggerOffset); - int line = loc.Line + 1, column = loc.Column + 1; + int line = loc.Line, column = loc.Column; switch (completionChar) { case '.': // foo.[complete] lineText = Editor.GetLineText (line); diff --git a/extras/ValaBinding/MonoDevelop.ValaBinding.dll.config b/extras/ValaBinding/MonoDevelop.ValaBinding.dll.config index 184cdd0306..c1544076d7 100644 --- a/extras/ValaBinding/MonoDevelop.ValaBinding.dll.config +++ b/extras/ValaBinding/MonoDevelop.ValaBinding.dll.config @@ -1,3 +1,4 @@ - - \ No newline at end of file + + + diff --git a/extras/ValaBinding/Parser/Afrodite.cs b/extras/ValaBinding/Parser/Afrodite.cs index e1dabf9d09..dd2b8d3a94 100644 --- a/extras/ValaBinding/Parser/Afrodite.cs +++ b/extras/ValaBinding/Parser/Afrodite.cs @@ -71,9 +71,8 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// public Ast TryAcquireAst () { - IntPtr astInstance = IntPtr.Zero; - bool success = afrodite_completion_engine_try_acquire_ast (instance, out astInstance, 10); - return (success)? new Ast (astInstance, this): null; + IntPtr ast = afrodite_completion_engine_get_ast (instance); + return (ast == IntPtr.Zero)? null: new Ast (ast, this); } /// @@ -81,7 +80,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// public void ReleaseAst (Ast ast) { - afrodite_completion_engine_release_ast (instance, ast.Instance); + // Obsolete } #region P/Invokes @@ -96,10 +95,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite bool is_vapi, bool is_glib); [DllImport("afrodite")] - static extern bool afrodite_completion_engine_try_acquire_ast (IntPtr instance, out IntPtr ast, int retry_count); - - [DllImport("afrodite")] - static extern bool afrodite_completion_engine_release_ast (IntPtr instance, IntPtr ast); + static extern IntPtr afrodite_completion_engine_get_ast (IntPtr instance); #endregion } @@ -123,7 +119,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite IntPtr children = afrodite_symbol_get_children (instance); if (IntPtr.Zero != children) { - list = new ValaList (children).ToTypedList (delegate (IntPtr item){ return new Symbol (item); }); + list = new ValaList (children).ToTypedList (item => new Symbol (item)); } return list; @@ -134,14 +130,20 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// The type of this symbol /// public DataType DataType { - get { return new DataType (afrodite_symbol_get_symbol_type (instance)); } + get { + IntPtr datatype = afrodite_symbol_get_symbol_data_type (instance); + return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_symbol_data_type (instance)); + } } /// /// The return type of this symbol, if applicable /// public DataType ReturnType { - get{ return new DataType (afrodite_symbol_get_return_type (instance)); } + get { + IntPtr datatype = afrodite_symbol_get_return_type (instance); + return (IntPtr.Zero == datatype)? null: new DataType (afrodite_symbol_get_symbol_data_type (instance)); + } } /// @@ -177,7 +179,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite IntPtr refs = afrodite_symbol_get_source_references (instance); if (IntPtr.Zero != refs) { - list = new ValaList (refs).ToTypedList (delegate (IntPtr item){ return new SourceReference (item); }); + list = new ValaList (refs).ToTypedList (item => new SourceReference (item)); } return list; @@ -188,7 +190,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// The symbol type (class, method, ...) of this symbol /// public string SymbolType { - get{ return Marshal.PtrToStringAuto (afrodite_symbol_get_type_name (instance)); } + get{ return Utils.GetSymbolType (afrodite_symbol_get_symbol_type (instance)); } } /// @@ -250,15 +252,15 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite { "class", Stock.Class }, { "struct", Stock.Struct }, { "enum", Stock.Enum }, - { "errordomain", Stock.Enum }, + { "error domain", Stock.Enum }, { "field", Stock.Field }, { "method", Stock.Method }, { "constructor", Stock.Method }, { "creationmethod", Stock.Method }, { "property", Stock.Property }, { "constant", Stock.Literal }, - { "enumvalue", Stock.Literal }, - { "errorcode", Stock.Literal }, + { "enum value", Stock.Literal }, + { "error code", Stock.Literal }, { "signal", Stock.Event }, { "delegate", Stock.Delegate }, { "interface", Stock.Interface }, @@ -270,15 +272,15 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite { "class", Stock.PrivateClass }, { "struct", Stock.PrivateStruct }, { "enum", Stock.PrivateEnum }, - { "errordomain", Stock.PrivateEnum }, + { "error domain", Stock.PrivateEnum }, { "field", Stock.PrivateField }, { "method", Stock.PrivateMethod }, { "constructor", Stock.PrivateMethod }, { "creationmethod", Stock.PrivateMethod }, { "property", Stock.PrivateProperty }, { "constant", Stock.Literal }, - { "enumvalue", Stock.Literal }, - { "errorcode", Stock.Literal }, + { "enum value", Stock.Literal }, + { "error code", Stock.Literal }, { "signal", Stock.PrivateEvent }, { "delegate", Stock.PrivateDelegate }, { "interface", Stock.PrivateInterface }, @@ -290,15 +292,15 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite { "class", Stock.ProtectedClass }, { "struct", Stock.ProtectedStruct }, { "enum", Stock.ProtectedEnum }, - { "errordomain", Stock.ProtectedEnum }, + { "error domain", Stock.ProtectedEnum }, { "field", Stock.ProtectedField }, { "method", Stock.ProtectedMethod }, { "constructor", Stock.ProtectedMethod }, { "creationmethod", Stock.ProtectedMethod }, { "property", Stock.ProtectedProperty }, { "constant", Stock.Literal }, - { "enumvalue", Stock.Literal }, - { "errorcode", Stock.Literal }, + { "enum value", Stock.Literal }, + { "error code", Stock.Literal }, { "signal", Stock.ProtectedEvent }, { "delegate", Stock.ProtectedDelegate }, { "interface", Stock.ProtectedInterface }, @@ -350,7 +352,10 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite static extern IntPtr afrodite_symbol_get_parameters (IntPtr instance); [DllImport("afrodite")] - static extern IntPtr afrodite_symbol_get_symbol_type (IntPtr instance); + static extern int afrodite_symbol_get_symbol_type (IntPtr instance); + + [DllImport("afrodite")] + static extern IntPtr afrodite_symbol_get_symbol_data_type (IntPtr instance); [DllImport("afrodite")] static extern IntPtr afrodite_symbol_get_return_type (IntPtr instance); @@ -874,13 +879,13 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite /// /// Using directives in this source file /// - public List UsingDirectives { + public List UsingDirectives { get { - List list = new List (); + List list = new List (); IntPtr symbols = afrodite_source_file_get_using_directives (instance); if (IntPtr.Zero != symbols) { - list = new ValaList (symbols).ToTypedList (delegate (IntPtr item){ return new Symbol (item); }); + list = new ValaList (symbols).ToTypedList (item => new DataType (item)); } return list; @@ -950,9 +955,11 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite if (IsGeneric) { text.Append ("<"); List parameters = GenericTypes; - text.Append (parameters[0].TypeName); - for (int i = 0; i < parameters.Count; i++) { - text.AppendFormat (",{0}", parameters[i].TypeName); + if (parameters != null && parameters.Count > 0) { + text.Append (parameters[0].TypeName); + for (int i = 0; i < parameters.Count; i++) { + text.AppendFormat (",{0}", parameters[i].TypeName); + } } text.Append (">"); } @@ -1026,7 +1033,7 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite IntPtr types = afrodite_data_type_get_generic_types (instance); if (IntPtr.Zero != types) { - list = new ValaList (types).ToTypedList (delegate (IntPtr item){ return new DataType (item); }); + list = new ValaList (types).ToTypedList (item => new DataType (item)); } return list; @@ -1154,9 +1161,16 @@ namespace MonoDevelop.ValaBinding.Parser.Afrodite return list; } + public static string GetSymbolType (int symbolType) + { + return Marshal.PtrToStringAuto (afrodite_utils_symbols_get_symbol_type_description (symbolType)); + } + [DllImport("afrodite")] static extern IntPtr afrodite_utils_get_package_paths (string package, IntPtr codeContext, string[] vapiDirs); + [DllImport("afrodite")] + static extern IntPtr afrodite_utils_symbols_get_symbol_type_description (int symbolType); } } diff --git a/extras/ValaBinding/Parser/ProjectInformation.cs b/extras/ValaBinding/Parser/ProjectInformation.cs index 596e416680..c5718aeb27 100644 --- a/extras/ValaBinding/Parser/ProjectInformation.cs +++ b/extras/ValaBinding/Parser/ProjectInformation.cs @@ -305,8 +305,8 @@ namespace MonoDevelop.ValaBinding.Parser Afrodite.SourceFile file = parseTree.LookupSourceFile (filename); if (null != file) { Afrodite.Symbol parent; - foreach (Afrodite.Symbol directive in file.UsingDirectives) { - Afrodite.Symbol ns = parseTree.Lookup (directive.FullyQualifiedName, out parent); + foreach (Afrodite.DataType directive in file.UsingDirectives) { + Afrodite.Symbol ns = parseTree.Lookup (directive.Symbol.FullyQualifiedName, out parent); if (null != ns) { containers = new List (); AddResults (new Afrodite.Symbol[]{ ns }, results); diff --git a/extras/ValaBinding/configure.in b/extras/ValaBinding/configure.in index 14cbf1a4f8..f8ad490e8d 100644 --- a/extras/ValaBinding/configure.in +++ b/extras/ValaBinding/configure.in @@ -53,7 +53,7 @@ dnl hard dependencies MONOADDINS_REQUIRED_VERSION=0.3 GTKSHARP_REQUIRED_VERSION=2.12.8 MONODEVELOP_REQUIRED_VERSION=2.5.91 -LIBVALA_REQUIRED_VERSION=0.10.0 +LIBVALA_REQUIRED_VERSION=0.12.0 PKG_CHECK_MODULES(MONO_ADDINS, mono-addins >= $MONOADDINS_REQUIRED_VERSION) AC_SUBST(MONO_ADDINS_LIBS) @@ -82,10 +82,10 @@ AM_CONDITIONAL(HAVE_GNOME_VFS_SHARP, test x$gnome_vfs_sharp = xyes) PKG_CHECK_MODULES(GCONF_SHARP, gconf-sharp-2.0 >= $GTKSHARP_REQUIRED_VERSION, [gconf_sharp=yes], [gconf_sharp=no]) AC_SUBST(GCONF_SHARP_LIBS) AM_CONDITIONAL(HAVE_GCONF_SHARP, test x$gconf_sharp = xyes) -PKG_CHECK_MODULES(LIBVALA, vala-0.10 >= $LIBVALA_REQUIRED_VERSION) +PKG_CHECK_MODULES(LIBVALA, libvala-0.12 >= $LIBVALA_REQUIRED_VERSION) AC_SUBST(LIBVALA_LIBS) -AC_SEARCH_LIBS(afrodite_utils_get_package_paths, afrodite, [], [ +AC_SEARCH_LIBS(afrodite_utils_get_package_paths, afrodite-0.12, [], [ echo "" echo "libafrodite is required for Vala code completion." echo "libafrodite is part of the VTG package, available from: " -- cgit v1.2.3