summaryrefslogtreecommitdiff
path: root/src/duk-libdom.h
blob: 51d43278d74bad7b06f02072ad827e1418e7072a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* DukTape binding generation
 *
 * This file is part of nsgenbind.
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 * Copyright 2015 Vincent Sanders <vince@netsurf-browser.org>
 */

#ifndef nsgenbind_duk_libdom_h
#define nsgenbind_duk_libdom_h

/**
 * Generate output for duktape and libdom bindings.
 */
int duk_libdom_output(struct ir *ir);

/**
 * generate a source file to implement an interface using duk and libdom.
 */
int output_interface(struct ir *ir, struct ir_entry *interfacee);

/**
 * generate a declaration to implement a dictionary using duk and libdom.
 */
int output_interface_declaration(FILE* outf, struct ir_entry *interfacee);

/**
 * generate a source file to implement a dictionary using duk and libdom.
 */
int output_dictionary(struct ir *ir, struct ir_entry *dictionarye);

/**
 * generate a declaration to implement a dictionary using duk and libdom.
 */
int output_dictionary_declaration(FILE* outf, struct ir_entry *dictionarye);

/**
 * generate preface block for nsgenbind
 */
int output_tool_preface(FILE* outf);

/**
 * generate preface block for nsgenbind
 */
int output_tool_prologue(FILE* outf);

/**
 * output character data of node of given type.
 *
 * used for any cdata sections
 *
 * \param outf The file handle to write output.
 * \param node The node to search.
 * \param nodetype the type of child node to search for.
 * \return The number of nodes written or 0 for none.
 */
int output_cdata(FILE* outf, struct genbind_node *node, enum genbind_node_type nodetype);


/**
 * output c code with line directives if possible.
 *
 * used for any cdata sections
 *
 * \param outf The file handle to write output.
 * \param node The node to search.
 * \param nodetype the type of child node to search for.
 * \return The number of nodes written or 0 for none.
 */
int output_ccode(FILE* outf, struct genbind_node *node);

/**
 * output character data of method node of given type.
 *
 * used for any cdata including pre/pro/epi/post sections
 *
 * \param outf The file handle to write output.
 * \param node The node to search.
 * \param nodetype the type of child node to search for.
 * \return The number of nodes written or 0 for none.
 */
int output_method_cdata(FILE* outf, struct genbind_node *node, enum genbind_method_type sel_method_type);

/**
 * 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.
 *
 * \param outf The file handle to write output.
 * \param node The node to generate content for.
 * \param identifier If the indentifier should be output.
 * \return 0 on success.
 */
int output_ctype(FILE *outf, struct genbind_node *node, bool identifier);

/**
 * 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.
 */
char *gen_idl2c_name(const char *idlname);

/**
 * Generate class property setter for a single attribute.
 */
int output_generated_attribute_setter(FILE* outf, struct ir_entry *interfacee, struct ir_attribute_entry *atributee);

/**
 * Generate class property getter for a single attribute.
 */
int output_generated_attribute_getter(FILE* outf, struct ir_entry *interfacee, struct ir_attribute_entry *atributee);


#endif