zoukankan      html  css  js  c++  java
  • 生成跨语言的类型声明和接口绑定的工具(Djinni )

    Djinni 是一个用来生成跨语言的类型声明和接口绑定的工具,主要用于 C++ 和 Java 以及 Objective-C 间的互通。

    示例接口定义文件:

     1 # Multi-line comments can be added here. This comment will be propagated
     2 # to each generated definition.
     3 my_enum = enum {
     4     option1;
     5     option2;
     6     option3;
     7 }
     8  
     9 my_record = record {
    10     id: i32;
    11     info: string;
    12     store: set<string>;
    13     hash: map<string, i32>;
    14  
    15     values: list<another_record>;
    16  
    17     # Comments can also be put here
    18  
    19     # Constants can be included
    20     const string_const: string = "Constants can be put here";
    21     const min_value: another_record = {
    22         key1 = 0,
    23         key2 = ""
    24     };
    25 }
    26  
    27 another_record = record {
    28     key1: i32;
    29     key2: string;
    30 } deriving (eq, ord)
    31  
    32 # This interface will be implemented in C++ and can be called from any language.
    33 my_cpp_interface = interface +c {
    34     method_returning_nothing(value: i32);
    35     method_returning_some_type(key: string): another_record;
    36     static get_version(): i32;
    37  
    38     # Interfaces can also have constants
    39     const version: i32 = 1;
    40 }
    41  
    42 # This interface will be implemented in Java and ObjC and can be called from C++.
    43 my_client_interface = interface +j +o {
    44     log_string(str: string): bool;
    45 }

    使用方法:

    1 @import "relative/path/to/filename.djinni"

    github地址:https://github.com/dropbox/djinni

  • 相关阅读:
    javascript DOM操作
    DirectX编译出现link错误
    PPT快捷键
    Windows GDI笔记
    VC++键盘消息
    VC++6.0快捷键
    C#值类型和引用类型
    C#转义字符
    关于C#里“浅表副本”的解释
    C#中override和overload的区别
  • 原文地址:https://www.cnblogs.com/CharlesGrant/p/4724794.html
Copyright © 2011-2022 走看看