/'*
\file Plugin.bas
\brief An example code for an external emitter

This file contains example source code for an external emitter. It 
isn't used in the fb-doc source tree. See \ref extend for details.

'/

/'*

This emitter generates a list of the function names called via the 
emitter interface. So when you input some source to fb-doc and use 
this emitter, the output is a list of the functions called by the 
parser for this input.

Before you can use this emitter, you have to compile it first, using 
the command

\code fbc -dylib Plugin.bas \endcode

The result is a binary called

  - libdll_emitter.so  (LINUX)
  - libdll_emitter.dll (windows)
  
There's no way to compile or use an external emitter on DOS since 
DOS doesn't support dynamic linked libraries.

To use this emitter in fb-doc set its name (without the suffix .bas) 
just as an internal name (,so don't name your customized emitter 
similar to an internal emitter name).

Ie. the context of this file can get piped to fb-doc by the command

\code ./fb-doc --geany Plugin < Plugin.bas \endcode

(LINUX example) and will generate the following output:

\verbatim
DLL_INIT
DLL_INCLUDE
DLL_INCLUDE
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_FUNCTION
DLL_EXIT
\endverbatim

'/


#INCLUDE ONCE "fb-doc_emitters.bi" ' declaration of the emitter interface
#INCLUDE ONCE "fb-doc_parser.bi"   ' declaration of the Parser members (not used here)

'* \brief Emitter called when the Parser is at a variable declaration
SUB dll_declare CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is on top of a function body
SUB dll_function CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is at the start of a ENUM block
SUB dll_enum CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is at the start of a UNION block
SUB dll_union CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is at the start of a TYPE block
SUB dll_class CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is at an \#DEFINE line or at the start of a \#MACRO
SUB dll_define CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called when the Parser is at an \#INCLUDE line
SUB dll_include CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called before the input gets parsed
SUB dll_init CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called for an error
SUB dll_error CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called for an empty block in --geany mode
SUB dll_empty CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__
END SUB

'* \brief Emitter called after the input got parsed
SUB dll_exit CDECL(BYVAL P AS Parser PTR)
  P->Code &= NL & __FUNCTION__ & NL
END SUB


' Setting the EmitterIF pointer (delete un-needed rows)
WITH_NEW_EMITTER("dll_emitter")
    .Decl_ = @dll_declare
    .Func_ = @dll_function
    .Enum_ = @dll_enum
    .Unio_ = @dll_union
    .Clas_ = @dll_class
    .Defi_ = @dll_define
    .Incl_ = @dll_include
   ._Init_ = @dll_init
  ._Error_ = @dll_error
  ._Empty_ = @dll_empty
   ._Exit_ = @dll_exit   
END WITH


' Function called by fb-doc to get the EmitterIF
FUNCTION EmitterInit CDECL() AS EmitterIF PTR EXPORT
  RETURN Emitters(0)
END FUNCTION

