Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@schleifner/asc-to-header

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@schleifner/asc-to-header

This tool is used for translate an AssemblyScript type definiton file to C++ header file.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

AssemblyScript C Header Translator

This tool is used for translate an AssemblyScript type definiton file to C++ header file.

build

npm install
npm run bundle

run

node --experimental-modules bin/Cli.js -f [input assemblyscript file] -o [target header file]
output:
C Header file

Example

example.ts:

enum Status{
    OK=0x1,
    FAIL=0x2
}

export declare function printStatus(Status:Status);

output:
example.h:


#ifndef __types_wasm_example_H__
#define __types_wasm_example_H__
extern "C" {
enum class Status {
  OK = 0x1,
  FAIL = 0x2,
};
__attribute__((import_module("example"))) void printStatus(Status Status);

}
#endif


cuation

Function pointer type

For function type declaration, when use it in the function parameter, should use the same name.
for example:
ASC

export type mycallback = (data: i32) => void;
export function callService(mycallback: i32):void;

then we can translate to:

using mycallback = void (*) (int data);
 __attribute__((import_module("test"))) void callService(mycallback mycallback);

but if we got asc like:
ASC

export type mycallback = (data: i32) => void;
export function callService(my_callback: i32):void;

then we can translate to:

using mycallback = void (*) (int data);
 __attribute__((import_module("test"))) void callService(int my_callback);

UserData Type

Some user data type, which is often used as C like API context, is usually a pointer type. Type UserDataType is designed as a reserved type. This type will be translated to uintptr_t in C++.

FAQs

Package last updated on 06 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc