GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
GlueEmitter.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * - Redistribution of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * - Redistribution in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * Neither the name of Sun Microsystems, Inc. or the names of
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21 * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22 * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
23 * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
24 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
25 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
26 * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
27 * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
28 * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
29 * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
30 * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31 *
32 * You acknowledge that this software is not designed or intended for use
33 * in the design, construction, operation or maintenance of any nuclear
34 * facility.
35 *
36 * Sun gratefully acknowledges that this software was originally authored
37 * and developed by Kenneth Bradley Russell and Christopher John Kline.
38 */
39
40package com.jogamp.gluegen;
41
42import java.util.*;
43
44import com.jogamp.gluegen.cgram.types.*;
45
46/** Specifies the interface by which GlueGen requests glue code to be
47 generated. Can be replaced to generate glue code for other
48 languages and foreign function interfaces. */
49
50public interface GlueEmitter {
51
52 public void readConfigurationFile(String filename) throws Exception;
54
55 /**
56 * Begin the emission of glue code. This might include opening files,
57 * emitting class headers, etc.
58 */
59 public void beginEmission(GlueEmitterControls controls) throws Exception;
60
61 /**
62 * Finish the emission of glue code. This might include closing files,
63 * closing open class definitions, etc.
64 */
65 public void endEmission() throws Exception;
66
67 public void beginDefines() throws Exception;
68 /**
69 * @param optionalComment If optionalComment is non-null, the emitter can
70 * emit that string as a comment providing extra information about the
71 * define.
72 */
73 public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception;
74 public void endDefines() throws Exception;
75
76 public void beginFunctions(TypeDictionary typedefDictionary,
77 TypeDictionary structDictionary,
78 Map<Type, Type> canonMap,
79 List<FunctionSymbol> cFunctions) throws Exception;
80
81 /** Emit glue code for the list of FunctionSymbols. */
82 public Iterator<FunctionSymbol> emitFunctions(List<FunctionSymbol> cFunctions) throws Exception;
83 public void endFunctions() throws Exception;
84
85 /** Begins the process of computing field offsets and type sizes for
86 the structs to be emitted. */
87 public void beginStructLayout() throws Exception;
88 /** Lays out one struct which will be emitted later. */
89 public void layoutStruct(CompoundType t) throws Exception;
90 /** Finishes the struct layout process. */
91 public void endStructLayout() throws Exception;
92
93 public void beginStructs(TypeDictionary typedefDictionary,
94 TypeDictionary structDictionary,
95 Map<Type, Type> canonMap) throws Exception;
96 /** Emit glue code for the given CompoundType. typedefType is
97 provided when the CompoundType (e.g. "struct foo_t") has not
98 been typedefed to anything but the type of "pointer to struct
99 foo_t" has (e.g. "typedef struct foo_t {} *Foo"); in this case
100 typedefType would be set to pointer type Foo. */
101 public void emitStruct(CompoundType t, Type typedefType) throws Exception;
102 public void endStructs() throws Exception;
103}
Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and...
Parses and provides access to the contents of .cfg files for the JavaEmitter.
Models all compound types, i.e., those containing fields: structs and unions.
Describes a function symbol, which includes the name and type.
Utility class for recording names of typedefs and structs.
Specifies the interface by which a GlueEmitter can request additional information from the glue gener...
Specifies the interface by which GlueGen requests glue code to be generated.
void endEmission()
Finish the emission of glue code.
void beginStructs(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap)
void beginStructLayout()
Begins the process of computing field offsets and type sizes for the structs to be emitted.
void endStructLayout()
Finishes the struct layout process.
JavaConfiguration getConfig()
void emitDefine(ConstantDefinition def, String optionalComment)
void beginFunctions(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap, List< FunctionSymbol > cFunctions)
void readConfigurationFile(String filename)
void layoutStruct(CompoundType t)
Lays out one struct which will be emitted later.
void emitStruct(CompoundType t, Type typedefType)
Emit glue code for the given CompoundType.
Iterator< FunctionSymbol > emitFunctions(List< FunctionSymbol > cFunctions)
Emit glue code for the list of FunctionSymbols.
void beginEmission(GlueEmitterControls controls)
Begin the emission of glue code.