我正在为一些基于 gob2 的旧小部件生成 GLib 自省,但我无法让 g-ir-scanner 获取我的任何 GtkDoc 注释,并且 gir 文件仅包含自省注释。
这就是我所做的。
这是 gob2 文件 tut-gob-greeter.gob
/* Make a tut greeter in gob */
requires 2.0.0
%headertop{
#include <glib.h>
#include <glib-object.h>
%}
%{
#include <stdio.h>
%}
class Tut:Gob:Greeter from G:Object
{
/**
* new:
*
* Allocates a new #TutGreeter.
*
* Return value: a new #TutGreeter.
*/
public TutGobGreeter *
new (void)
{
TutGobGreeter *greeter;
greeter = g_object_new (TUT_TYPE_GOB_GREETER, NULL);
return greeter;
}
/**
* greet:
* @greeter: a #TutGreeter
*
* Prints a friendly greeting.
*
* Return value: nothing.
*/
public void
greet (self)
{
g_return_if_fail (self != NULL);
printf("Hello from gob!\n");
}
}
这是我运行以从 gob 文件和共享库生成 h 和 c 文件的命令
gob2 --gtk3 -o . tut-gob-greeter.gob
gcc -o tut-gob-greeter.os -c -pthread -fPIC -Wall -g -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include tut-gob-greeter.c
gcc -o libtutgob.so -pthread -shared tut-gob-greeter.os -lgobject-2.0 -lglib-2.0
这是g-ir-scanner
命令:
env LD_LIBRARY_PATH=`pwd` GI_SCANNER_DEBUG=save-temps \
g-ir-scanner tut-gob-greeter.c tut-gob-greeter.h --output TutGob-0.1.gir \
--library tutgob \
`pkg-config --cflags gobject-2.0` \
--include GObject-2.0 --namespace=TutGob --nsversion=0.1
即使我看到 gob2 将我的 GtkDoc 注释转移到 c 文件中,这些都没有被 g-ir-scanner 拾取!这是c文件的摘录:
/**
* tut_gob_greeter_greet:
* @greeter: a #TutGreeter
*
* Prints a friendly greeting.
*
* Return value: nothing.
**/
#line 40 "tut-gob-greeter.gob"
void
tut_gob_greeter_greet (TutGobGreeter * self)
{
#line 141 "tut-gob-greeter.c"
#define __GOB_FUNCTION__ "Tut:Gob:Greeter::greet"
#line 40 "tut-gob-greeter.gob"
g_return_if_fail (self != NULL);
#line 40 "tut-gob-greeter.gob"
g_return_if_fail (TUT_IS_GOB_GREETER (self));
#line 147 "tut-gob-greeter.c"
{
#line 42 "tut-gob-greeter.gob"
g_return_if_fail (self != NULL);
printf("Hello from gob!\n");
}}
生成的 gir 文件不包含source-position
源自 c 文件的任何引用。我缺少什么以及如何调试解析器?