nsgenbind
Loading...
Searching...
No Matches
Macros | Functions
duk-libdom-common.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include <errno.h>
#include <ctype.h>
#include "options.h"
#include "utils.h"
#include "nsgenbind-ast.h"
#include "webidl-ast.h"
#include "ir.h"
#include "output.h"
#include "duk-libdom.h"

Go to the source code of this file.

Macros

#define NSGENBIND_PREFACE
 

Functions

int output_tool_preface (struct opctx *outc)
 
int output_cdata (struct opctx *outc, struct genbind_node *node, enum genbind_node_type nodetype)
 
int output_ccode (struct opctx *outc, struct genbind_node *node)
 
int output_tool_prologue (struct opctx *outc)
 
int output_ctype (struct opctx *outc, struct genbind_node *node, bool identifier)
 
int output_method_cdata (struct opctx *outc, struct genbind_node *node, enum genbind_method_type sel_method_type)
 
char * gen_idl2c_name (const char *idlname)
 

Macro Definition Documentation

◆ NSGENBIND_PREFACE

#define NSGENBIND_PREFACE
Value:
"/* Generated by nsgenbind\n" \
" *\n" \
" * nsgenbind is published under the MIT Licence.\n" \
" * nsgenbind is similar to a compiler is a purely transformative tool which\n" \
" * explicitly makes no copyright claim on this generated output\n" \
" */\n"

Definition at line 26 of file duk-libdom-common.c.

Function Documentation

◆ gen_idl2c_name()

char * gen_idl2c_name ( const char *  idlname)

Generate a C name from an IDL name.

The IDL interface names are camelcase and not similar to libdom naming so it is necessary to convert them to a libdom compatible class name. This implementation is simple ASCII capable only and cannot cope with multibyte codepoints.

The algorithm is:

  • copy characters to output lowering their case
  • if the previous character in the input name was uppercase and the current one is lowercase insert an underscore before the previous character.

Definition at line 181 of file duk-libdom-common.c.

◆ output_ccode()

int output_ccode ( struct opctx outc,
struct genbind_node node 
)

output c code with line directives if possible.

used for any cdata sections

Parameters
outfThe file handle to write output.
nodeThe node to search.
nodetypethe type of child node to search for.
Returns
The number of nodes written or 0 for none.

Definition at line 62 of file duk-libdom-common.c.

◆ output_cdata()

int output_cdata ( struct opctx outc,
struct genbind_node node,
enum genbind_node_type  nodetype 
)

output character data of node of given type.

used for any cdata sections

Parameters
outfThe file handle to write output.
nodeThe node to search.
nodetypethe type of child node to search for.
Returns
The number of nodes written or 0 for none.

Definition at line 43 of file duk-libdom-common.c.

◆ output_ctype()

int output_ctype ( struct opctx outc,
struct genbind_node node,
bool  identifier 
)

output a C variable type

Used to output c type and optionlly identifier declarations for parameters and structure entries. If the optional identifier is output it is ensured the type is separated from the identifier with either a * or space.

Parameters
outfThe file handle to write output.
nodeThe node to generate content for.
identifierIf the indentifier should be output.
Returns
0 on success.

Definition at line 111 of file duk-libdom-common.c.

◆ output_method_cdata()

int output_method_cdata ( struct opctx outc,
struct genbind_node node,
enum genbind_method_type  sel_method_type 
)

output character data of method node of given type.

used for any cdata including pre/pro/epi/post sections

Parameters
outfThe file handle to write output.
nodeThe node to search.
nodetypethe type of child node to search for.
Returns
The number of nodes written or 0 for none.

Definition at line 149 of file duk-libdom-common.c.

◆ output_tool_preface()

int output_tool_preface ( struct opctx outc)

generate preface block for nsgenbind

Definition at line 35 of file duk-libdom-common.c.

◆ output_tool_prologue()

int output_tool_prologue ( struct opctx outc)

generate preface block for nsgenbind

Definition at line 90 of file duk-libdom-common.c.