如何重命名从 C 结构创建的 SWIG 生成的代理 Java 类 [英] How to Rename SWIG Generated Proxy Java classes created from C Structures

查看:30
本文介绍了如何重命名从 C 结构创建的 SWIG 生成的代理 Java 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些像下面这样的 C 结构,它们由 SWIG 生成到 sample_struct_t.java 中,因为 C 函数将其声明为 sample_struct_t.我需要在 SWIG 接口文件中添加什么才能将 sample_struct_t 结构生成为 Sample.java?

I have a few C structures like below that are generated by SWIG into sample_struct_t.java since the C function declares it as sample_struct_t. What would I need to add to the SWIG interface file to generate the sample_struct_t structure as Sample.java?

typedef struct sample_struct_t_ {
    char                               *sample;
    uint8_t                             example;
    ios_boolean                         remove;
} sample_struct_t;

推荐答案

您需要将 %rename 与非 typedef'd(即原始)名称一起使用,在第一次看到之前:

You need to use %rename with the non-typedef'd (i.e. original) name, before this is first seen:

%module test

%rename (Sample) sample_struct_t_;

typedef struct sample_struct_t_ {
    char                               *sample;
    uint8_t                             example;
    ios_boolean                         remove;
} sample_struct_t;

这篇关于如何重命名从 C 结构创建的 SWIG 生成的代理 Java 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆