c_builder 1.1.0
c_builder: ^1.1.0

Dart native js
Flutter Android iOS web

An API for generating C code in Dart. Especially helpful for compiler development. Supports generating every possible unit of C code.

c_builder #

Pub

An API for generating C code in Dart. Especially helpful for compiler development. Supports generating every possible unit of C code.

Example #

import 'package:c_builder/c_builder.dart';
import 'package:code_buffer/code_buffer.dart';

/// Generates a simple "Hello, world"
main() {
  var unit = new CompilationUnit()
    ..body.addAll([
      new Include.system('stdio.h'),
      new CFunction(new FunctionSignature(CType.int, 'main')
        ..parameters.addAll([
          new Parameter(CType.int, 'argc'),
          new Parameter(CType.char.pointer().pointer(), 'argv'),
        ]))
        ..comments.addAll([
          'This is the entry point.',
          'The system calls this function when starting the program.'
        ])
        ..body.addAll([
          new Expression.value(0).asReturn(),
        ]),
    ]);
  var buf = new CodeBuffer();
  unit.generate(buf);
  print(buf);
}
1
likes
90
pub points
17%
popularity

An API for generating C code in Dart. Especially helpful for compiler development. Supports generating every possible unit of C code.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

thosakwe@gmail.com

License

MIT (LICENSE)

Dependencies

code_buffer, meta

More

Packages that depend on c_builder