GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jerch/node-tinycc

BranchesTags
Open more actions menu

Latest commit

 

History

55 Commits
55 Commits

Folders and files

NameName
Last commit message
Last commit date
demos
demos
 
 
doc
doc
 
 
src
src
 
 
test
test
 
 
win32
win32
 
 
win64
win64
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
binding.gyp
binding.gyp
 
 
index.js
index.js
 
 
install.js
install.js
 
 
install_tcc.sh
install_tcc.sh
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
preinstall.js
preinstall.js
 
 

Repository files navigation

Run inline C code on the fly.

Version 0.0.9 tested on:

  • Linux with nodejs 6.11 64 bit, (gcc 4.8 on x86, gcc 6.3 on ARM)
  • Windows 10 with nodejs 6.11 32 and 64 bit
  • OSX 10.10 with nodejs 6.10, llvm 3.5 (Cave! TCC is not fully ported to OSX, support is experimental!)

Version 0.1.0 tested on:

  • Linux with nodejs 22 & 24 (x86 only)

Features

  • inline C functions in JS
  • JS callbacks in C
  • wchar_t, struct and array support
  • async compilation support

Documentation

See the API documentation.

Usage

const tcc = require('node-tinycc');

// create a code generator
let gen = tcc.CodeGenerator();
// create a compile state
let state = tcc.DefaultTcc();

// declare a C function
let c_func = tcc.c_function(
    'int',                          // return type
    'add',                          // function name in C
    [['int', 'a'], ['int', 'b']],   // parameters as [type, name]
    'return a + b + js_func(a, b);' // actual code
);
gen.addDeclaration(c_func);

// add a JS function declaration to C
let js_func = tcc.c_callable(
    'int',                          // return type
    'js_func',                      // function name in C
    ['int', 'int'],                 // parameter types
    (a, b) => {return a * b;}       // function
);
gen.addDeclaration(js_func);

// compile code and relocate
state.compile(gen.code());
state.relocate();

// resolve symbols between C and JS
gen.bindState(state);

// now the C stuff is usable
console.log(c_func(23, 42));        // --> prints 1031

See demos and tests for more usage examples.

About

No description, website, or topics provided.

Resources

Readme
Activity

Stars

5 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.