Skip to main content

Python api (IDL) Transpiler Source-to-source compiler C/C++ to YAML Description based on clang

Project description

PDIC Open Source Love svg1

PDIC: (IDL) Transpiler Source-to-source compiler C/C++ to YAML Portable Data Interface Description

Project related to PDI Linux

GitHub license Build Github Status

PyPI version PyPI implementation

Doc made-with-Markdown

GitHub release Docker

From C/C++ to Yaml Description

Simple binary Python library
static binary Python 3
./pdic file.c import pdic; result:str = pdic.files_to_pdi()

Instalation

Binary

cmake -S . -DBINARY:BOOL=ON -B build && cmake --build build -- -j `nproc`

Google Test

cmake -S . -DTEST:BOOL=ON -B build && cmake --build build -- -j `nproc`
cd build && ctest

Python

python setup.py build -G "Unix Makefiles"
python3 setup.py bdist_wheel -G "Unix Makefiles" -j `nproc`
python setup.py build_ext  -G "Unix Makefiles" --inplace -j `nproc`
pytest

Usage

#pragma pdi on

typedef struct Var8
{
#pragma pdi type : int64
    int my_int;
    char char_tab[20];
    char my_char;
} var;

#pragma pdi size:[42]
int **array_of_pointer_of_array[21];

var my_var;

#pragma pdi off

Will be see and describe as follow

structs:
 Var8:
  type: record
  name: Var8
  alias: [var]
  fieldsize: 3
  buffersize: 28
  packed: false
  members:
   char_tab: { type: array, subtype: char, size: 20 }
   my_char:
    offset: 24   
    type: char
   my_int:
    type: int64
data:
 array_of_pointer_of_array: { type: array, subtype:  { type: pointer, subtype:  { type: array, subtype: int, size: 42 } }, size: 21 }
 my_var:
  type: record
  name: Var8
  alias: [var]
  fieldsize: 3
  buffersize: 28
  packed: false
  members:
   char_tab: { type: array, subtype: char, size: 20 }
   my_char:
    offset: 24   
    type: char
   my_int:
    type: int64

Python Usage

import os
import pathlib
import yaml
import pdic

here = pathlib.Path(__file__).parent.resolve()
# pip show -f pdic
if __name__ == "__main__":
    pdi_yml_description: str = pdic.files_to_pdi([os.path.join(here, "level_1.c"),
                                                  os.path.join(here, "level_2.c")])
    print(pdi_yml_description)
    print(yaml.dump(yaml.load(pdi_yml_description)))

Index

  1. Abstract
  2. Usage
    1. Binary
    2. Python
  3. Developpement
    • Code
    • Documentation
    • Test
    • Deploy
  4. Links
  5. Extra
    • Clang LLVM
    • Mind Map
    • Graph
    • UML
  6. Contact / Credits

Credits

Barre Kevin neudinger (Software Scientist)

CEA pdi team

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page