Re: [Vala] Generated vapi file for a library not compilable.

2012-11-29 Thread PCMan
OK, I use a workaround and run a sed command to fix the incorrect generated
vapi file.
I use sed to prepend global:: to all wrong namespaced classes then it works.
Before the bug of vala gets handled, I have to use the workaround for now.
The problem is, how to integrate this fix with automake?
I need to run the command everytime after the vapi file is generated.
However, I cannot find a proper automake mechanism to do it automatically.
Any suggestions?


On Thu, Nov 29, 2012 at 1:40 PM, Axel FILMORE axel.film...@gmail.comwrote:

 On Thu, 29 Nov 2012 13:09:53 +0800
 PCMan pcman...@gmail.com wrote:

  Thanks for sharing.
  Manually editing the vapi file works for me too, but this is only a
  workaround.
  After regeneration of vapi files, the changes are gone and need to be
  done again.
  There must be something wrong in valac or my compiler settings.
  We need a way to generate correct vapi files from vala code directly.
  So, it seems that it's a bug in valac?

 I done like this in the library :

 http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/src/PanelApplet.vala

 http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/vapi/libspanel.vapi

 And like this in the application :

 http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel/view/head:/src/Applets/Weather/WeatherApplet.vala

 I don't use any namespace for Applets :)

 I don't have the technical explanation however.

 :P

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-29 Thread Jürg Billeter
On Thu, 2012-11-29 at 10:13 +0800, PCMan wrote:
 All of the errors I got are like these:
   VALAC  lxpanel2_vala.stamp
 lxpanel-applet.vapi:10.27-10.49: error: The type name `Lxpanel.AppletInfo'
 could not be found

In lxpanel2.vala you have a class `Lxpanel' in the namespace `Lxpanel'.
This means that the symbol `Lxpanel' will be resolved to the class
`Lxpanel.Lxpanel' instead of the global namespace `Lxpanel' - when
referenced from within the namespace `Lxpanel'.

valac typically detects such conflicts and prefixes the name with
`global::' in the generated .vapi file. However, as the conflict is not
in the lxpanel-applet library, it's impossible for valac to detect that
conflict when generating the .vapi file.

I recommend you to rename the class `Lxpanel.Lxpanel' to something else
such as `Lxpanel.Panel'.

Regards,
Jürg

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-29 Thread PCMan
Thank you for the prompt reply.
I just fixed it with using a sed command to add the global:: prefix in a
all-local target of Makefile.am, which is very dirty!
I'll try what you said. I did not noticed that it can be the cause of the
problem.
Thank you very much!!!


On Thu, Nov 29, 2012 at 5:11 PM, Jürg Billeter j...@bitron.ch wrote:

 On Thu, 2012-11-29 at 10:13 +0800, PCMan wrote:
  All of the errors I got are like these:
VALAC  lxpanel2_vala.stamp
  lxpanel-applet.vapi:10.27-10.49: error: The type name
 `Lxpanel.AppletInfo'
  could not be found

 In lxpanel2.vala you have a class `Lxpanel' in the namespace `Lxpanel'.
 This means that the symbol `Lxpanel' will be resolved to the class
 `Lxpanel.Lxpanel' instead of the global namespace `Lxpanel' - when
 referenced from within the namespace `Lxpanel'.

 valac typically detects such conflicts and prefixes the name with
 `global::' in the generated .vapi file. However, as the conflict is not
 in the lxpanel-applet library, it's impossible for valac to detect that
 conflict when generating the .vapi file.

 I recommend you to rename the class `Lxpanel.Lxpanel' to something else
 such as `Lxpanel.Panel'.

 Regards,
 Jürg


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-29 Thread PCMan
Really thank you , Jürg Billeter.
My problem is solved by renaming that class to avoid conflicts.
Mailing list is good.
I spent hours and hours trying to workaround this and did not find any clue.
I should have came here earlier.
Thanks!


On Thu, Nov 29, 2012 at 5:26 PM, PCMan pcman...@gmail.com wrote:

 Thank you for the prompt reply.
 I just fixed it with using a sed command to add the global:: prefix in a 
 all-local target of Makefile.am, which is very dirty!
 I'll try what you said. I did not noticed that it can be the cause of the 
 problem.
 Thank you very much!!!


 On Thu, Nov 29, 2012 at 5:11 PM, Jürg Billeter j...@bitron.ch wrote:

 On Thu, 2012-11-29 at 10:13 +0800, PCMan wrote:
  All of the errors I got are like these:
VALAC  lxpanel2_vala.stamp
  lxpanel-applet.vapi:10.27-10.49: error: The type name `Lxpanel.AppletInfo'
  could not be found

 In lxpanel2.vala you have a class `Lxpanel' in the namespace `Lxpanel'.
 This means that the symbol `Lxpanel' will be resolved to the class
 `Lxpanel.Lxpanel' instead of the global namespace `Lxpanel' - when
 referenced from within the namespace `Lxpanel'.

 valac typically detects such conflicts and prefixes the name with
 `global::' in the generated .vapi file. However, as the conflict is not
 in the lxpanel-applet library, it's impossible for valac to detect that
 conflict when generating the .vapi file.

 I recommend you to rename the class `Lxpanel.Lxpanel' to something else
 such as `Lxpanel.Panel'.

 Regards,
 Jürg


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread PCMan
Sorry that I forgot to paste the complete vapi file generated
It's here:
http://pastebin.com/v2j6CnXq

Thanks a lot!

On Thu, Nov 29, 2012 at 10:13 AM, PCMan pcman...@gmail.com wrote:

 Hello,
 I got another issue with vala.
 I moved the core part of my program to a separate library, and let the
 main program call that library.
 The library itself compiles correctly.
 However, the genrated vapi file is not usable by the main program.
 Both parts are written in vala.
 The generated vapi file looks like this.

 When compiling the main program with --pkg my_vapi_file, I got errors.
 The generated vapi file seems to have duplicated nested namespace for
 static methods like this.

 namespace Lxpanel {

 class Applet : Object {
 static Lxpanel.Applet? from_file(string...);
 }
 }

 If I remove Lxpanel.Applet manually and just use Applet, it works.
 I like vala a lot and want to continue use it for my project, so I hope
 that someone knows how to fix it. Otherwise I may have to rewrite the
 program in plain C/GObject, which is a pain. :-(

 All of the errors I got are like these:
   VALAC  lxpanel2_vala.stamp
 lxpanel-applet.vapi:10.27-10.49: error: The type name `Lxpanel.AppletInfo'
 could not be found
 public static GLib.Listweak Lxpanel.AppletInfo get_all_types ();
 ^^^
 lxpanel-applet.vapi:13.10-13.35: error: The type name
 `Lxpanel.AppletInfo' could not be found
 public unowned Lxpanel.AppletInfo get_info ();
^^
 lxpanel-applet.vapi:18.17-18.30: error: The type name `Lxpanel.Applet'
 could not be found
 public static Lxpanel.Applet? new_from_type_name (string type_name);
   ^^
 lxpanel-applet.vapi:19.44-19.61: error: The type name `Lxpanel.AppletInfo'
 could not be found
 public static void register_applet_info (Lxpanel.AppletInfo info);
  ^^
 lxpanel-applet.vapi:34.10-34.29: error: The type name
 `Lxpanel.AppletModule' could not be found
  public Lxpanel.AppletModule? module;

 lxpanel-applet.vapi:40.10-40.23: error: The type name `Lxpanel.Applet'
 could not be found
  public Lxpanel.Applet? create_new ();
^^
 lxpanel-applet.vapi:41.17-41.34: error: The type name `Lxpanel.AppletInfo'
 could not be found
  public static Lxpanel.AppletInfo? from_file (string applet_id, string
 info_path);
   ^^
 lxpanel-applet.vapi:74.24-74.37: error: The type name `Lxpanel.Button'
 could not be found
 public class Drawer : Lxpanel.Button {
   ^^
 lxpanel-applet.vapi:75.13-75.25: error: The type name `Lxpanel.Popup'
 could not be found
 protected Lxpanel.Popup? popup;
   ^
 lxpanel-applet.vapi:80.28-80.41: error: The type name `Lxpanel.Button'
 could not be found
 public class MenuButton : Lxpanel.Button {
   ^^
 Compilation failed: 10 error(s), 0 warning(s)

 Thank you guys!


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread Axel FILMORE
On Thu, 29 Nov 2012 10:13:40 +0800
PCMan pcman...@gmail.com wrote:

 Hello,
 I got another issue with vala.
 I moved the core part of my program to a separate library, and let
 the main program call that library.
 The library itself compiles correctly.
 However, the genrated vapi file is not usable by the main program.
 Both parts are written in vala.
 The generated vapi file looks like this.
 
 When compiling the main program with --pkg my_vapi_file, I got
 errors. The generated vapi file seems to have duplicated nested
 namespace for static methods like this.

I had a similar problem doing this :

namespace Panel {
public class MenuApplet {
}
}

public static AppletType register () {

applet_type.id = typeof (MenuApplet); //  it's PanelMenuApplet
return applet_type;
}

I found that the type *is not* MenuApplet but PanelMenuApplet,
I just removed the namespaces for Panel Applet that fixed the problem :

public class MenuApplet {
}


public static AppletType register () {

applet_type.id = typeof (MenuApplet);
return applet_type;
}

:)

___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread PCMan
Thanks for sharing.
Manually editing the vapi file works for me too, but this is only a
workaround.
After regeneration of vapi files, the changes are gone and need to be done
again.
There must be something wrong in valac or my compiler settings.
We need a way to generate correct vapi files from vala code directly.
So, it seems that it's a bug in valac?


On Thu, Nov 29, 2012 at 12:07 PM, Axel FILMORE axel.film...@gmail.comwrote:

 On Thu, 29 Nov 2012 10:13:40 +0800
 PCMan pcman...@gmail.com wrote:

  Hello,
  I got another issue with vala.
  I moved the core part of my program to a separate library, and let
  the main program call that library.
  The library itself compiles correctly.
  However, the genrated vapi file is not usable by the main program.
  Both parts are written in vala.
  The generated vapi file looks like this.
 
  When compiling the main program with --pkg my_vapi_file, I got
  errors. The generated vapi file seems to have duplicated nested
  namespace for static methods like this.

 I had a similar problem doing this :

 namespace Panel {
 public class MenuApplet {
 }
 }

 public static AppletType register () {

 applet_type.id = typeof (MenuApplet); //  it's PanelMenuApplet
 return applet_type;
 }

 I found that the type *is not* MenuApplet but PanelMenuApplet,
 I just removed the namespaces for Panel Applet that fixed the problem :

 public class MenuApplet {
 }


 public static AppletType register () {

 applet_type.id = typeof (MenuApplet);
 return applet_type;
 }

 :)


___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] Generated vapi file for a library not compilable.

2012-11-28 Thread Axel FILMORE
On Thu, 29 Nov 2012 13:09:53 +0800
PCMan pcman...@gmail.com wrote:

 Thanks for sharing.
 Manually editing the vapi file works for me too, but this is only a
 workaround.
 After regeneration of vapi files, the changes are gone and need to be
 done again.
 There must be something wrong in valac or my compiler settings.
 We need a way to generate correct vapi files from vala code directly.
 So, it seems that it's a bug in valac?

I done like this in the library :
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/src/PanelApplet.vala
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel-lib/view/head:/vapi/libspanel.vapi

And like this in the application :
http://bazaar.launchpad.net/~axel-filmore/valadesktop/spanel/view/head:/src/Applets/Weather/WeatherApplet.vala

I don't use any namespace for Applets :)

I don't have the technical explanation however.

:P
___
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list