/tags/Root-branch-php-utl/SWIG/TODO

# · #! · 395 lines · 277 code · 118 blank · 0 comment · 0 complexity · 5b24b31639df0fa8d6e50cdaab024ecf MD5 · raw file

  1. SWIG TO-DO
  2. Release: SWIG-1.3.29
  3. $Header$
  4. -----------------------------------------------------------------------------
  5. **** = High Priority
  6. *** = Implement if possible.
  7. ** = Will implement if time.
  8. * = Implement if bored (or deemed necessary).
  9. defer = Implement in next version
  10. CORE:
  11. **** Add support for nested classes. The type system should be
  12. defer ready to go. The primary obstacle lies in the target language
  13. modules (which were never programmed with nested classes in
  14. mind). There are also issues with nested C structures. For
  15. example:
  16. struct Foo {
  17. struct {
  18. int x,y;
  19. } z;
  20. };
  21. This is one of the last remaining "hard" problems in the SWIG
  22. core, but it is important that we solve it.
  23. *** "Nested" typemaps. The basic idea is similar to allowing one to
  24. use $descriptor(T) for any T, rather than just $descriptor
  25. for the type currently being typemapped.
  26. In short (ha!), given a previously defined typemap:
  27. %typemap(in) Foo {
  28. // whatever it takes to initialize $1 from $input
  29. }
  30. it would be possible to inline its code inside another typemap.
  31. While the syntax is still to be defined, the use would be
  32. along the lines of:
  33. template <class T> class vector {
  34. %typemap(in) vector<T> {
  35. ...
  36. for (int i=0; i<N; i++) {
  37. PyObject* x = ... // i-th element
  38. $typemap(in, T, x, $1[i]);
  39. }
  40. ...
  41. }
  42. ...
  43. }
  44. i.e., when $typemap(in,Foo,x,y) is encountered, it will
  45. be replaced by the code for %typemap(in) Foo; in the latter,
  46. x will be replaced for $input and y will be replaced for $1.
  47. As in the case above, x and y themselves might need to be
  48. expanded before or after being substituted in the typemap code.
  49. Also, $typemap(what,Foo,x,y,z,...) will be used in case of
  50. multi-arguments typemaps. The same will hold for "out" typemaps
  51. and all the others.
  52. Comment by mkoeppe:
  53. I think we need to be careful to keep the syntax readable.
  54. I would like to get a syntax that is close to that of
  55. typemap definitions. So consider this typemap:
  56. %typemap(in) int { ... }
  57. I would like to refer to this typemap like this:
  58. $typemap(in, input=x) int = foo;
  59. Here $input would be replaced by the given keyword argument
  60. x, and $1 would be replaced by foo.
  61. This syntax would extend easily to multi-typemaps:
  62. %typemap(in) ( int FIRST, double SECOND ) { ... }
  63. -> $typemap(in, input=x)
  64. ( int FIRST = foo, double SECOND = bar );
  65. The advantage of this syntax would be that the formal
  66. arguments (int FIRST, double SECOND) are close to the
  67. actual arguments (foo, bar).
  68. Comment by beazley
  69. $typemap(in, input=x) int = foo;
  70. is a little bit hard to parse in terms of variable substitution.
  71. I'm considering something like this:
  72. $typemap(in,1=int foo, input=x)
  73. Note: This is partially implemented in the new Unified Typemap
  74. Library(python,tcl,ruby and perl) via %fragments and the
  75. SWIG_From/SWIG_AsVal methdos.
  76. *** Implement $fail special variable substitution in wrappers. Used
  77. to properly transfer control out of a wrapper function while
  78. reclaiming resources.
  79. Note: Implemented in languages that uses the UTL via the
  80. 'SWIG_fail' macro.
  81. [done] Better targeting of output typemaps. For example:
  82. It is not possible to target an output typemap for function
  83. Foo::func() and not Bar::func(). Output typemaps need to support
  84. syntax something along the lines of:
  85. %typemap(out) int *Foo::func { ... }
  86. Currently only globals functions can be targeted, like so:
  87. %typemap(out) int *func { ... }
  88. *** Rewrite declaration annotation to better unify %rename and related
  89. directives. Add a selector mechanism that allows specific parse tree
  90. nodes to be identified. For example:
  91. %feature("foo", nodetype="class") Foo { ... some code ... };
  92. Consider use of wildcards. Namespace/nested scope support in
  93. %feature is currently weak. It works, but is fragile. Consider
  94. an implementation that is better integrated with symbol table
  95. management. Continue to consolidate SWIG directives to %feature.
  96. Note: Initial implementation in the %rename directive.
  97. [done] Bring Aquinas' contract/assertion checking code online.
  98. *** Add more intelligent information related to object ownership.
  99. SWIG should be able to automatically strip ownership from
  100. objects when they are assigned to pointer variables and structure
  101. members as well as stored in a container (i.e., an array of pointers).
  102. [ Partially finished for Ruby/Perl/Tcl/Python. ]
  103. ** Restoration of the documentation system.
  104. [ Partially done for Python. ]
  105. ** Restoration of Objective-C support.
  106. ** Unification of symbol tables and type system scopes. In a sense
  107. they capture the same information so it is not necessary to have
  108. both. The existence of two symbol management systems is mostly
  109. historical.
  110. Build
  111. -----
  112. Library
  113. -------
  114. **** Add more support for the C++ standard library. std::complex and other
  115. core datatypes. Refine support for STL vector. Add more STL objects.
  116. [ Partially finished for Python. ]
  117. **** Continue to expand the set of recognized typemaps.
  118. Windows
  119. -------
  120. All language modules
  121. --------------------
  122. Python
  123. ------
  124. *** Ability to wrap certain classes as Python built-in types.
  125. Perl
  126. ----
  127. **** Rewrite runtime pointer type checking to better integrate
  128. shadow classes. Creation of shadow classes should be done
  129. in C instead of Perl. This will fix a number of problems
  130. related to typemaps and reduce the amount of Perl wrapper code.
  131. **** Create tests for existing support for operator overloading
  132. Tcl
  133. ---
  134. Ruby
  135. ----
  136. **** The "Resource Management in Proxies" section of the "SWIG and C++"
  137. chapter discusses how proxies' ownership of their associated C++
  138. object can change, and the use of the special disown() and
  139. acquire() methods to change this ownership status. Need to
  140. address this for Ruby as well.
  141. *** Add support for keyword arguments (by collecting them in a hash?).
  142. * Add some special directives to automatically rename declarations to
  143. or from CamelCase.
  144. Java
  145. ----
  146. C#
  147. --
  148. *** Implement director support for C# so that virtual methods work seemlessly
  149. when mixing C# and C++ code.
  150. PHP
  151. ---
  152. ** When returning wrapped objects via alternate constructors if that
  153. pointer value already exists "out there" as a resource we should
  154. use the same resource, we can't have multiple ref-counted resources
  155. mapping to the same object in case it gets twice destroyed. And check
  156. if ref count destroying is even working, see smart_pointer_rename
  157. * Work out how classes without even inherited constructors should
  158. interact with the php "new <class>" notation.
  159. See: abstract_inherit_wrap.cpptest
  160. ** Look at pass by point and passby ref,
  161. Make sometype** to be auto allocated
  162. Make sometype& and sometype* to be autoallocated IF THEY ARE NOT
  163. ALREADY swigtype wrapped.
  164. * Overloading, callbacks, really review to see what else is missed
  165. Guile
  166. -----
  167. ** Maybe rename slot setters from CLASS-SLOT-set to CLASS-SLOT-set!
  168. to match Scheme convention for naming of mutators.
  169. ** Support keyword args.
  170. ** Director Support!
  171. ** Cleaner handling of multiple values.
  172. Use a typemap keyword argument "numoutputs" of "out" and
  173. "argout" to indicate how many values are returned.
  174. ** Make SWIG's types first-class by using a separate smob type for
  175. SWIG type descriptors; enable reflection on types. (Maybe
  176. GOOPS metaclasses?)
  177. ** Provide a clean way to construct type predicates.
  178. ** In GOOPS mode, maybe make overloaded functions methods.
  179. ** Increase the safety of destructor functions. John Lenz suggests:
  180. I think the best way of doing this would be to use %feature to mark
  181. which classes allow for "normal" <swig> smobs to be deleted explicitly.
  182. We separate pointers into two classes, those that can be deleted from
  183. scheme and those that can't. The pointers that can be deleted use the
  184. <collectable-swig> smob and those that can not be deleted use the
  185. <swig> smob. A user can specify which type of each object they want
  186. with %newobject and the CONSUMED typemap.
  187. By default, the exported destructor will only accept <collectable-swig>
  188. smobs, because by definition, collectable-swig smobs are those that can
  189. be deleted from scheme. This allows for the user to implement
  190. protection. In the interface file, the user has complete control over
  191. which objects can and can not be deleted, and can guarantee that
  192. objects that should not be deleted can not be deleted, and that objects
  193. that should eventually be deleted will be garbage collected.
  194. This protection can then be overridden with a %feature directive,
  195. something like
  196. %feature("guile_allow_destroy_all","1") Foo::~Foo;
  197. I don't know what word we want to use, guile_allow_destroy_all is kinda
  198. bad. This feature would then allow for a <swig Foo *> smob to be
  199. deleted by passing it to the destructor. This would allow users to
  200. maintain the protection on other classes, only manually overriding the
  201. protection on the classes that need it.
  202. Mzscheme
  203. --------
  204. ** Port list-vector.i and pointer-in-out.i from Guile.
  205. ** Add shadow class support for the Swindle system.
  206. Pike
  207. ----
  208. * Decide how to handle global variables (probably using something
  209. like the Python module's cvar). Affects Examples/pike/simple.
  210. * Decide how to handle static class member functions and member
  211. variables.
  212. * Should investigate the possibility of generating .cmod files
  213. in addition to straight C/C++ code for extensions.
  214. Common Lisp
  215. -----------
  216. * Random thoughts by mkoeppe on supporting Common Lisp implementations:
  217. There are many different Foreign Function Interfaces (FFI) for
  218. the various CL implementations. Probably SWIG should interface
  219. to UFFI, a least-common-denominator FFI that supports many
  220. implementations.
  221. Via the s-expression SWIG module we can export SWIG's parse
  222. tree and import it into CL. It remains to check if all
  223. relevant information is dumped (for instance, the type
  224. information). Experimental code is available to generate
  225. low-level UFFI declarations from this parse tree.
  226. However, for wrapping C++, we also need to create C wrappers
  227. because most FFIs cannot directly import C++. A CL SWIG module
  228. could be exporting both these wrappers and UFFI declarations.
  229. I have experimental code (not checked in yet) that does this.
  230. This is fine for generating low-level wrappers. But how do we
  231. support user typemaps (like converting lists and vectors to C
  232. arrays on input)? We have to generate Lisp code that does the
  233. conversion and then calls the low-level wrapper. If we
  234. generate Lisp code, it should be beautiful and readable.
  235. Therefore, we need at least a Lisp pretty printer. A Lisp
  236. pretty printer works best when the Lisp program is represented
  237. not as text but as Lisp data. Moreover, typemap writers will
  238. feel very much constrained by SWIG's capabilities for
  239. generating wrapper code, when compared to writing Lisp macros.
  240. Thus we would need half a re-implementation of Lisp in SWIG to
  241. make users happy.
  242. The solution could be the following:
  243. ** Build a SWIG library (again) and load it into a Common Lisp
  244. implementation.
  245. The FFI declarations could be written manually, or this could
  246. be bootstrapped via the s-expression module or the primitive
  247. UFFI wrappers. This should be easy because SWIG's API is quite
  248. simple.
  249. The embedded SWIG would be driven by a CL program. High-level
  250. typemaps would be written as Lisp programs that generate Lisp
  251. code.
  252. Ocaml
  253. -----
  254. ** I've been working with my camlp4 module and type information
  255. from the compiler. When I'm done, the user will have access
  256. to type inference when writing code, when the inference is
  257. unambiguous. This allows the user to write x = _foo 1.0
  258. instead of x = get_float (_foo (C_float 1.0)). It's not as
  259. easy as it sounds, because O'caml doesn't keep type information
  260. at run time, and doesn't really have a mechanism for doing what
  261. I need. However, it's possible to write a preprocessor that
  262. inserts correct type info at compile time.
  263. That having been said, the program must compile for type info
  264. to be available, so I need to attend to a lot of details; The
  265. program must compile both with and without type augmentation.
  266. Xml
  267. ---
  268. Documentation
  269. -------------
  270. **** Extending SWIG (and internals).
  271. *** Perl, Python, Tcl modules.
  272. *** add section for Perl module support for operator overloading
  273. ** Add section on WAD.
  274. Other
  275. -----
  276. ***** Learn more wicked Jazz chords.
  277. (in progress)