如何使用Python绑定C+绑定来获取C++标题中的方法列表?

2024-09-29 21:50:45 发布

您现在位置:Python中文网/ 问答频道 /正文

你有什么办法吗?我对任何代码解析器都不熟悉,但我知道使用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']
[]
[]
[]
[]
[]

Tags: 代码apiincludevirtualpublicclassdeclareflying

热门问题