Auto Generate Reflection Information for C++
https://www.reddit.com/r/gamedev/comments/3lh0ba/using_clang_to_generate_c_reflection_data/
https://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/
代码
https://github.com/chakaz/reflang
https://shaharmike.com/cpp/libclang/
文档
https://clang.llvm.org/doxygen/group__CINDEX.html
Windows上安装libclang的方法
在官网https://llvm.org/下载LLVM Win Installer。安装完成后,在安装目录下找libclang.dll。
Mac上安装libclang的python绑定的方法
pip install clang
Mac上libclang的位置
With the latest (appstore) XCode 4.3.2, the location changed, it can now be found in
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
The /Developer directory, among others, no longer exists by default. Everything is now packaged inside the XCode application, so that delta updates from the appstore work.
找不到Cursor_ref方法的问题
AttributeError: module 'clang.cindex' has no attribute 'Cursor_ref'
您需要将ref_node = clang.cindex.Cursor_ref(node)更改为ref_node = node.get_definition(),以避免获得AttributeError,因为Cursor_ref不再是clang.cindex模块的属性。
Python代码find_ref.py
#!/usr/bin/env python
""" Usage: call with <filename> <typename>
""" import sys
import clang.cindex def find_typerefs(node, typename):
""" Find all references to the type named 'typename'
"""
if node.kind.is_reference():
ref_node = node.get_definition()
if ref_node.spelling == typename:
print('Found %s [line=%s, col=%s]' % (typename, node.location.line, node.location.column)) # Recurse for children of this node
for c in node.get_children():
find_typerefs(c, typename) index = clang.cindex.Index.create()
tu = index.parse(sys.argv[1])
print('Translation unit:', tu.spelling)
find_typerefs(tu.cursor, sys.argv[2])
C++代码person.cpp
class Person {
};
class Room {
public:
void add_person(Person person)
{
// do stuff
}
private:
Person* people_in_room;
};
template <class T, int N>
class Bag<T, N> {
};
int main()
{
Person* p = new Person();
Bag<Person, 42> bagofpersons;
return 0;
}
运行
python3 find_ref.py person.cpp Person
Auto Generate Reflection Information for C++的更多相关文章
- shell script auto generate the relevant header information
first : add follow context in /etc/vim/vimrc set ignorecaseset cursorlineset autoindentautocmd Buf ...
- SQLAutoCode - error when attempting to generate schema
I'm trying to auto generate a schema for use in SQLalchemy, I'm using sqlautocode to do this, I use ...
- Auto Layout Guide----(三)-----Anatomy of a Constraint
Anatomy of a Constraint 剖析约束 The layout of your view hierarchy is defined as a series of linear equa ...
- Android Lint Checks
Android Lint Checks Here are the current list of checks that lint performs as of Android Studio 2.3 ...
- 1Z0-050
QUESTION 13 View the Exhibit.Examine the following command that is executed for the TRANSPORT table ...
- linux显示git commit id,同时解决insmod模块时版本不一致导致无法加载问题
linux内核默认会包含git的commit ID. 而linux的内核在insmod模块时,会对模块和内核本身的版本做严格的校验.在开发产品时,改动内核后,由于commit ID变更,会导致linu ...
- SubSonic指南中文版
翻译:王鹏程张原 王伟策划:毛凌志2009年1月北京工业大学软件学院PS:有问题反馈至http://lexus.cnblogs.comGetting Started with SubSonicBy S ...
- linux根文件系统制作
在嵌入式中移植的内核下载到开发板上,是没有办法真正的启动Linux操作系统的,会出现无法加载文件系统的错误. 那么根文件系统在系统启动中到底是什么时候挂载的呢?先将/dev/ram0挂载,而后执行/l ...
- Allegro16.3约束设置 (转载)
原文地址:http://blog.chinaunix.net/uid-21198646-id-3212383.html 差分对的约束设置 第一步,差分对的设置 差分对的设置有很多方法,下面介绍两种最常 ...
随机推荐
- ABP使用Nginx代理导致租户ID(Abp.TenantId)丢失
描述:ABP使用Nginx代理导致租户ID(Abp.TenantId)丢失,自定义header无效无法传递,导致租户选择认证失败.原因是因为 Nginx 过滤是“.”这符号. 解决: 1,先从代码人手 ...
- maven项目的运行方式,maven私服的上传下载
一.maven项目父子工程的运行方式 1.通过父项目的plugin下集成的tomacat run启动 2.通过自身项目的tomcat plugin启动,但前提是所依赖的项目必须全部都install(将 ...
- 全程干货,requests模块与selenium框架详解
requests模块 前言: 通常我们利用Python写一些WEB程序.webAPI部署在服务端,让客户端request,我们作为服务器端response数据: 但也可以反主为客利用Python的re ...
- 如何利用NLog输出结构化日志,并在Kibana优雅分析日志?
上文我们演示了使用NLog向ElasticSearch写日志的基本过程(输出的是普通文本日志),今天我们来看下如何向ES输出结构化日志.并利用Kibana中分析日志. NLog输出结构化日志 Elas ...
- Spring Cloud 之分布式配置基础应用
分布式配置基础应用 配置中心服务 spring-config-server pom.xml <?xml version="1.0" encoding="UTF-8& ...
- PB级大规模Elasticsearch集群运维与调优实践
导语 | 腾讯云Elasticsearch 被广泛应用于日志实时分析.结构化数据分析.全文检索等场景中,本文将以情景植入的方式,向大家介绍与腾讯云客户合作过程中遇到的各种典型问题,以及相应的解决思路与 ...
- java_数据类型转换、运算符
数据类型转换 Java程序中要求参与计算的数据,必须要保证数据类型一致,如果数据类型不一致将发生类型的转换. 1.1 自动转换 一个 int 类型变量和一个 byte 类型变量进行加法运算,运算结果, ...
- 尝试Access数据库注入实验
靶场环境:https://www.mozhe.cn/bug/detail/82 首先http://219.153.49.228:49543/new_list.asp?id=1 order by 4 到 ...
- Go语言入门系列(五)之指针和结构体的使用
Go语言入门系列前面的文章: Go语言入门系列(二)之基础语法总结 Go语言入门系列(三)之数组和切片 Go语言入门系列(四)之map的使用 1. 指针 如果你使用过C或C++,那你肯定对指针这个概念 ...
- AutoUpdater迁移到Github
一. 摘要 最近一两年在做跨平台的解决方案,使应用程序能支持Android, iOS, Windows, MacOs. Linux等操作系统,在Android, iOS上可以使用Google Play ...