| fb-doc 0.2 documentation tool for FreeBasic

- Main Page
- Tutorial
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Plugin.bas
Go to the documentation of this file.
1 /'*
2 \file Plugin.bas
3 \brief An example code for an external emitter
4
5 This file contains example source code for an external emitter. It
6 isn't used in the fb-doc source tree. See \ref extend for details.
7
8 '/
9
10 /'*
11
12 This emitter generates a list of the function names called via the
13 emitter interface. So when you input some source to fb-doc and use
14 this emitter, the output is a list of the functions called by the
15 parser for this input.
16
17 Before you can use this emitter, you have to compile it first, using
18 the command
19
20 \code fbc -dylib Plugin.bas \endcode
21
22 The result is a binary called
23
24 - libdll_emitter.so (LINUX)
25 - libdll_emitter.dll (windows)
26
27 There's no way to compile or use an external emitter on DOS since
28 DOS doesn't support dynamic linked libraries.
29
30 To use this emitter in fb-doc set its name (without the suffix .bas)
31 just as an internal name (,so don't name your customized emitter
32 similar to an internal emitter name).
33
34 Ie. the context of this file can get piped to fb-doc by the command
35
36 \code ./fb-doc --geany Plugin < Plugin.bas \endcode
37
38 (LINUX example) and will generate the following output:
39
40 \verbatim
41 DLL_INIT
42 DLL_INCLUDE
43 DLL_INCLUDE
44 DLL_FUNCTION
45 DLL_FUNCTION
46 DLL_FUNCTION
47 DLL_FUNCTION
48 DLL_FUNCTION
49 DLL_FUNCTION
50 DLL_FUNCTION
51 DLL_FUNCTION
52 DLL_FUNCTION
53 DLL_FUNCTION
54 DLL_FUNCTION
55 DLL_FUNCTION
56 DLL_EXIT
57 \endverbatim
58
59 '/
60
61
62 #INCLUDE ONCE "fb-doc_emitters.bi" ' declaration of the emitter interface
63 #INCLUDE ONCE "fb-doc_parser.bi" ' declaration of the Parser members (not used here)
64
65 '* \brief Emitter called when the Parser is at a variable declaration
66 SUB dll_declare CDECL(BYVAL P AS Parser PTR)
67 P->Code &= NL & __FUNCTION__
68 END SUB
69
70 '* \brief Emitter called when the Parser is on top of a function body
71 SUB dll_function CDECL(BYVAL P AS Parser PTR)
72 P->Code &= NL & __FUNCTION__
73 END SUB
74
75 '* \brief Emitter called when the Parser is at the start of a ENUM block
76 SUB dll_enum CDECL(BYVAL P AS Parser PTR)
77 P->Code &= NL & __FUNCTION__
78 END SUB
79
80 '* \brief Emitter called when the Parser is at the start of a UNION block
81 SUB dll_union CDECL(BYVAL P AS Parser PTR)
82 P->Code &= NL & __FUNCTION__
83 END SUB
84
85 '* \brief Emitter called when the Parser is at the start of a TYPE block
86 SUB dll_class CDECL(BYVAL P AS Parser PTR)
87 P->Code &= NL & __FUNCTION__
88 END SUB
89
90 '* \brief Emitter called when the Parser is at an \#DEFINE line or at the start of a \#MACRO
91 SUB dll_define CDECL(BYVAL P AS Parser PTR)
92 P->Code &= NL & __FUNCTION__
93 END SUB
94
95 '* \brief Emitter called when the Parser is at an \#INCLUDE line
96 SUB dll_include CDECL(BYVAL P AS Parser PTR)
97 P->Code &= NL & __FUNCTION__
98 END SUB
99
100 '* \brief Emitter called before the input gets parsed
101 SUB dll_init CDECL(BYVAL P AS Parser PTR)
102 P->Code &= NL & __FUNCTION__
103 END SUB
104
105 '* \brief Emitter called for an error
106 SUB dll_error CDECL(BYVAL P AS Parser PTR)
107 P->Code &= NL & __FUNCTION__
108 END SUB
109
110 '* \brief Emitter called for an empty block in --geany mode
111 SUB dll_empty CDECL(BYVAL P AS Parser PTR)
112 P->Code &= NL & __FUNCTION__
113 END SUB
114
115 '* \brief Emitter called after the input got parsed
116 SUB dll_exit CDECL(BYVAL P AS Parser PTR)
117 P->Code &= NL & __FUNCTION__ & NL
118 END SUB
119
120
121 ' Setting the EmitterIF pointer (delete un-needed rows)
122 WITH_NEW_EMITTER("dll_emitter")
123 .Decl_ = @dll_declare
124 .Func_ = @dll_function
125 .Enum_ = @dll_enum
126 .Unio_ = @dll_union
127 .Clas_ = @dll_class
128 .Defi_ = @dll_define
129 .Incl_ = @dll_include
130 ._Init_ = @dll_init
131 ._Error_ = @dll_error
132 ._Empty_ = @dll_empty
133 ._Exit_ = @dll_exit
134 END WITH
135
136
137 ' Function called by fb-doc to get the EmitterIF
138 FUNCTION EmitterInit CDECL() AS EmitterIF PTR EXPORT
139 RETURN Emitters(0)
140 END FUNCTION
141