如何使用understand mac特别版编写您的第一个API脚本?!

时间:2018-08-31 浏览次数:109 编辑:user07

Understand mac特别版有一个广泛的API,可以让您查询它捕获的有关您的代码的数据。它有三种风格:Perl,Python和C. Perl API比其他两种更健壮,因为它允许与Understanding GUI进行交互,不需要额外的设置。所有三个API都是只读的,它们不会修改理解项目。如果您需要以编程方式执行此操作,请查看“ und ”。还有一个Java API是作为创建Understanding Eclipse插件的一部分编写的。然而,它更轻,它没有其他API的全部功能

开启理解项目

让我们首先看一个非常简单的Perl API脚本。

sample.pl

使用理解;
$ db =了解:: open(“c:\\ projects \\ test.udb”);
foreach $ file($ db-> ents(“file”)){
print $ file-> longname(),“\ n”;
}

第一行告诉Perl解释器您要使用Understandingnd API库。然后它打开一个理解项目文件(c:\ projectstest.udb)并遍历该项目中每个文件实体的列表,并在单独的行上打印每个文件的名称。

要自己运行,请将路径更改为指向您自己的项目之一。请注意,对于Windows路径,您需要通过加倍来转义斜杠。

Uperl是一个perl解释器,它包含在bin \ system目录中的Understanding中。要运行此脚本,请打开命令行/终端并运行:

cd“c:\ program files \ sciTools \ bin \ pc-win64”或系统上的相应路径uperl.exe myscript.pl

这是Python 3 API的相同脚本。需要在您的系统上安装Python并正确设置理解Python库。
sample.py

导入明白
db = Understand.open(“c:\\ projects \\ test.udb”)
对于db.ents(“file”)中的文件:
打印(file.longname())

而且,C API中完全相同的事情。

sample.c文件

#include <stdio.h>
#include <stdlib.h>
#include“C:\\ program Files \\ SciTools \\ src \\ udb \\ udb.h”
static char * dbFilename =“c:\\ projects \\ test.udb”;
main(int argc,char * argv []){
UdbStatus status = udbDbOpen(dbFilename);
UdbEntity * ents;
int entsSize;
int i;
udbListEntity(&ents,&entsSize);
udbListEntityFilter(ents,udbKindParse(“file”),
&ents,&entsSize);
for(i = 0; i <entsSize; i ++){
printf(“%s \ n”,udbEntityNameLong(ents [i]));
}
udbListEntityFree(已废除);
udbDbClose();
}

Makefile文件

sample.exe:sample.obj

推荐软件

客服QQ:

客服微信

返回顶部