GlueGen: src/java/com/jogamp/gluegen/GlueEmitter.java Source File

GlueGen v2.6.0-rc-20250706 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
50 public interface GlueEmitter {
51
52 public void readConfigurationFile(String filename) throws Exception;
53 public JavaConfiguration getConfig();
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}
com.jogamp.gluegen.ConstantDefinition
Represents a [native] constant expression, comprises the [native] expression, see getNativeExpr() and...
Definition: ConstantDefinition.java:54
com.jogamp.gluegen.JavaConfiguration
Parses and provides access to the contents of .cfg files for the JavaEmitter.
Definition: JavaConfiguration.java:63
com.jogamp.gluegen.cgram.types.CompoundType
Models all compound types, i.e., those containing fields: structs and unions.
Definition: CompoundType.java:51
com.jogamp.gluegen.cgram.types.FunctionSymbol
Describes a function symbol, which includes the name and type.
Definition: FunctionSymbol.java:63
com.jogamp.gluegen.cgram.types.TypeDictionary
Utility class for recording names of typedefs and structs.
Definition: TypeDictionary.java:50
com.jogamp.gluegen.cgram.types.Type
Models a C type.
Definition: Type.java:54
com.jogamp.gluegen.GlueEmitterControls
Specifies the interface by which a GlueEmitter can request additional information from the glue gener...
Definition: GlueEmitterControls.java:45
com.jogamp.gluegen.GlueEmitter
Specifies the interface by which GlueGen requests glue code to be generated.
Definition: GlueEmitter.java:50
com.jogamp.gluegen.GlueEmitter.endEmission
void endEmission()
Finish the emission of glue code.
com.jogamp.gluegen.GlueEmitter.endStructs
void endStructs()
com.jogamp.gluegen.GlueEmitter.beginStructs
void beginStructs(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap)
com.jogamp.gluegen.GlueEmitter.beginStructLayout
void beginStructLayout()
Begins the process of computing field offsets and type sizes for the structs to be emitted.
com.jogamp.gluegen.GlueEmitter.endStructLayout
void endStructLayout()
Finishes the struct layout process.
com.jogamp.gluegen.GlueEmitter.getConfig
JavaConfiguration getConfig()
com.jogamp.gluegen.GlueEmitter.endFunctions
void endFunctions()
com.jogamp.gluegen.GlueEmitter.endDefines
void endDefines()
com.jogamp.gluegen.GlueEmitter.emitDefine
void emitDefine(ConstantDefinition def, String optionalComment)
com.jogamp.gluegen.GlueEmitter.beginDefines
void beginDefines()
com.jogamp.gluegen.GlueEmitter.beginFunctions
void beginFunctions(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map< Type, Type > canonMap, List< FunctionSymbol > cFunctions)
com.jogamp.gluegen.GlueEmitter.readConfigurationFile
void readConfigurationFile(String filename)
com.jogamp.gluegen.GlueEmitter.layoutStruct
void layoutStruct(CompoundType t)
Lays out one struct which will be emitted later.
com.jogamp.gluegen.GlueEmitter.emitStruct
void emitStruct(CompoundType t, Type typedefType)
Emit glue code for the given CompoundType.
com.jogamp.gluegen.GlueEmitter.emitFunctions
Iterator< FunctionSymbol > emitFunctions(List< FunctionSymbol > cFunctions)
Emit glue code for the list of FunctionSymbols.
com.jogamp.gluegen.GlueEmitter.beginEmission
void beginEmission(GlueEmitterControls controls)
Begin the emission of glue code.