interrogate.1 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. .TH INTERROGATE 1 "27 December 2014" "" Panda3D
  2. .SH NAME
  3. interrogate \- generate scripting language bindings for C/C++ APIs
  4. .SH SYNOPSIS
  5. .B interrogate
  6. [
  7. .I opts
  8. ]
  9. .I file.C
  10. [
  11. .I file.C ...
  12. ]
  13. .SH DESCRIPTION
  14. Interrogate is a program to parse a body of C++ code and build up a table
  15. of classes, methods, functions, and symbols found, for the purposes of
  16. calling into the codebase via a non-C++ scripting language like Scheme,
  17. Smalltalk, or Python.
  18. .PP
  19. In addition to identifying all the classes and their relationships,
  20. interrogate will generate a wrapper function for each callable function.
  21. The wrapper functions will be callable directly from the scripting language,
  22. with no understanding of C++ necessary; these wrapper functions will in turn
  23. call the actual C++ functions or methods.
  24. .PP
  25. Most exportable features of C++ are supported, including templates, default
  26. parameters, and function overloading.
  27. .SH OPTIONS
  28. .TP
  29. .BI "\-oc " output.C
  30. Specify the name of the file to which generated code will be written.
  31. This includes all of the function wrappers, as well as those tables
  32. which must be compiled into the library.
  33. .TP
  34. .BI "\-od " output.in
  35. Specify the name of the file to which the non-compiled data tables
  36. will be written. This file describes the relationships between
  37. all the types and the functions, and associates the function wrappers
  38. above with this data. This file will be opened and read at runtime
  39. when the scripting language first calls some interrogate query
  40. function.
  41. .TP
  42. .BI "\-srcdir " directory
  43. Specify the name of the directory to which the source filenames are
  44. relative.
  45. .TP
  46. .BI "\-module " module_name
  47. Defines the name of the module this data is associated with. This
  48. is strictly a code-organizational tool. Conceptually, a module is
  49. the highest level of grouping for interrogate data; a module may
  50. contain several libraries. If this is omitted, no module name is
  51. specified.
  52. .PP
  53. Sometimes, depending on the type of wrappers being generated, there
  54. may be additional code that needs to be generated on the module
  55. level, above that which was already generated at the library level.
  56. Python, for instance, generates the table of python-callable function
  57. wrappers at the module level. Use the program
  58. .BR interrogate_module (1)
  59. to generate the appropriate code at the module level.
  60. .TP
  61. .BI "\-library " library_name
  62. Defines the name of the library this data is associated with. This
  63. is another code-organizational tool. Typically, there will be one
  64. invocation of interrogate for each library, and there will be
  65. multiple libraries per module. If this is omitted, no library name
  66. is specified.
  67. .TP
  68. .B \-do\-module
  69. Generate whatever module-level code should be generated immediately,
  70. rather than waiting for a special
  71. .BR interrogate_module (1)
  72. pass. This, of course, prohibits grouping several libraries together
  73. into a single module.
  74. .TP
  75. .B \-fptrs
  76. Make void* pointers to the function wrappers directly available. A
  77. scripting language will be able to call the interrogate functions
  78. directly by pointer.
  79. .TP
  80. .B \-fnames
  81. Make the names of the function wrappers public symbols so that the
  82. scripting language will be able to call the interrogate functions
  83. by name.
  84. .PP
  85. Either or both of \fB\-fptrs\fP and/or \fB\-fnames\fP may be specified.
  86. If both are omitted, the default is \fB\-fnames\fP.
  87. .TP
  88. .B \-string
  89. Treat char* and basic_string<char> as special cases, and map
  90. parameters of these types to type atomic string. The scripting
  91. language will see only functions that receive and return strings,
  92. not pointers to character or structures of basic_string<char>.
  93. If C calling convention wrappers are being generated, the atomic
  94. string type means type char*. In any other calling convention, the
  95. atomic string type is whatever the native string type is.
  96. .TP
  97. .B \-refcount
  98. Treat classes that inherit from a class called ReferenceCount as a
  99. special case. Any wrapper function that returns a pointer to
  100. one of these classes will automatically increment the reference
  101. count by calling ref() on the object first, and any destructors
  102. that are generated will call unref_delete() on the object instead of
  103. simply delete.
  104. .PP
  105. Furthermore, parameters of type PointerTo<N> or ConstPointerTo<N>
  106. will automatically be mapped to N * and const N *, respectively.
  107. .TP
  108. .B \-assert
  109. Generate code in each wrapper that will check the state of the assert
  110. flag and trigger an exception in the scripting language when a
  111. C++ assertion fails. Presently, this only has meaning to the Python
  112. wrappers.
  113. .TP
  114. .B \-true\-names
  115. Use the actual name of the function being wrapped as the name of
  116. the generated wrapper function, instead of an ugly hash name.
  117. This means the wrapper functions may be called directly using a
  118. meaningful name (especially if \fB\-fnames\fP is also given), but it
  119. also means that C++ function overloading (including default values
  120. for parameters) cannot be used, as it will lead to multiple wrapper
  121. functions with the same name.
  122. .TP
  123. .B \-c
  124. Generate function wrappers using the C calling convention. Any
  125. scripting language that can call a C function should be able to
  126. make advantage of the interrogate database.
  127. .TP
  128. .B \-python
  129. Generate function wrappers using the Python calling convention.
  130. The shared library will be directly loadable as a Python module
  131. (especially if the module definitions are made available either by
  132. running
  133. .BR interrogate_module (1)
  134. later, or by specifying \fB\-do\-module\fP on the command line now).
  135. However, C++ objects and methods will be converted into an object
  136. handle and a list of independent Python functions.
  137. .TP
  138. .B \-python\-obj
  139. Generate Python function wrappers that convert C++ objects to true
  140. python objects, with all methods converted to Python methods. This
  141. is currently experimental.
  142. .TP
  143. .B \-python\-native
  144. Generate Python function wrappers that convert C++ objects to true
  145. python objects, with all methods converted to Python methods. This
  146. is the recommended method for creating Python wrappers.
  147. .PP
  148. Any combination of \fB\-c\fP, \fB\-python\fP, or \fB\-python\-obj\fP
  149. may be specified. If all are omitted, the default is \fB\-c\fP.
  150. .TP
  151. .B \-track\-interpreter
  152. Generate code within each wrapper function to adjust the global
  153. variable "in_interpreter" to indicated whether code is running
  154. within the Panda C++ environment or within the high-level language.
  155. .TP
  156. .B \-unique\-names
  157. Compile a table into the library (i.e. generate code into the
  158. \fB\-oc\fP file) that defines a lookup of each function wrapper by
  159. its unique name. This makes it possible to consistently identify
  160. function wrappers between sessions, at the cost of having this
  161. additional table in memory.
  162. .TP
  163. .B \-nodb
  164. Do not build a full interrogate database, but just generate function
  165. wrappers. It is assumed that the user will know how to call the
  166. function wrappers already, from some external source. This is most
  167. useful in conjunction with \fB\-true\-names\fP.
  168. .TP
  169. .BI "\-longlong " typename
  170. Specify the name of the 64-bit integer type for the current compiler.
  171. By default, this is "long long".
  172. .TP
  173. .B \-promiscuous
  174. Export *all* public symbols, functions, and classes seen, even those
  175. not explicitly marked to be published.
  176. .TP
  177. .B \-spam
  178. Generate wrapper functions that report each invocation to Notify.
  179. This can sometimes be useful for tracking down bugs.
  180. .TP
  181. .B \-noangles
  182. Treat #include <file> the same as #include "file". This means
  183. \fB\-I\fP and \fB\-S\fP are equivalent.
  184. .SH "SEE ALSO"
  185. .BR interrogate_module (1),
  186. .BR test_interrogate (1)