你有什么办法吗?我对任何代码解析器都不熟悉,但我知道使用clang是可行的。在
我要解析的代码:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "InventoryItem.h"
#include "ItemView.h"
#include "InventoryScreen.generated.h"
class UGUIBase;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FInventoryScreenEvent, UInventoryItem*, item);
UCLASS()
class FLYING_API UInventoryScreen : public UGUIBase
{
GENERATED_BODY()
public:
virtual void NativeConstruct() override;
virtual TSharedRef<SWidget> RebuildWidget() override;
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Update event")
void UpdateItemView(const TArray<UInventoryItem*>& Items);
virtual void UpdateItemView_Implementation(const TArray<UInventoryItem*>& Items);
UFUNCTION()
void OnItemClicked(UInventoryItem* item);
UPROPERTY(BlueprintAssignable, Category = "Button|Event")
FInventoryScreenEvent OnClickedBy;
public:
TWeakObjectPtr<UItemView> ItemView;
};
看看像UCLASS和UFUNCTION这样的宏。使用此宏可能会导致错误的解析。但我需要用UFUNCTION宏(函数名和参数)修饰所有函数。在
我无用的代码(Python):
^{pr2}$由于解析错误,我删除了UCLASS()和FLYING\u API宏。以下代码可避免这种情况:
#define UCLASS(...)
#define FLYING_API
python代码的输出:
Translation unit: InventoryScreen.h
['DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam()', 'UGUIBase', 'UInventoryScreen', 'UGUIBase']
[]
[]
[]
[]
[]
我在谷歌上快速搜索“libclang parse c++”。在
其中一个有趣的链接是:
http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang
它应该给你足够的信息去做你想做的事。在
抱歉,我不能自己发布代码-我从来没有必要这么做。在
相关问题 更多 >
编程相关推荐