您的位置:首页 > 其它

使用Understand for Mac编写您的第一个API脚本

2019-11-04 16:09 585 查看

Understand具有广泛的API,可让您查询所捕获的有关代码的数据。它具有三种风格:Perl,Python和C。PerlAPI比其他两种更强大,因为它允许与Understand GUI交互,并且不需要其他设置。这三个API都是只读的,它们不会修改Understand项目。在创建Understanding Eclipse Plugin的过程中还编写了Java API 。但是,它更轻巧,没有其他API的全部功能。


打开一个理解项目

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

sample.pl

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

第一行告诉Perl解释器您想使用Understand API库。然后,它将打开一个Understand项目文件(c:\ projectstest.udb),并遍历该项目中每个文件实体的列表,并在单独的行上打印每个文件的名称。
要自己运行它,请更改路径以指向您自己的项目之一。请注意,对于Windows路径,您需要通过将斜杠加倍来对其进行转义。
Uperl是bin \ system目录中的Understand随附的perl解释器。要运行此脚本,请打开命令行/终端并运行:
cd“ c:\ program files \ scitools \ bin \ pc-win64”或系统上的适当路径uperl.exe myscript.pl
这是Python 3 API的相同脚本。需要在系统上安装Python,并且正确理解Python库。
sample.py

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

同样,C API也是如此。
样本

#include 
#include 
#include“ C:\ Program Files \ SciTools \ src \ udb \ udb.h”
静态字符* dbFilename =“ c:\ projects \ test.udb”;
main(int argc,char * argv []){
UdbStatus status = udbDbOpen(dbFilename);
UdbEntity * ents;
int entsSize;

udbListEntity(“ file”,&ents,&entsSize);
对于(i = 0; i printf(“%s \ n”,udbEntityNameLong(ents [i]));
}
udbListEntityFree(ents);
udbDbClos??e();
}

生成文件

sample.exe:sample.obj

由于C API示例的大小,这些教程的其余部分将仅显示Perl和Python中的示例。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐