Permalink
Browse files

Octave: cleanup/restructure library files

- Restructure runtime code into declarations, function/class definitions,
  and initialisation code
- Rename internal functions/types to follow SWIG_Octave... or SwigOct...
  naming styles
- Style/comment/whitespace cleanups
  • Loading branch information...
1 parent 2576681 commit c110e79e4693920c11a2271ddf0ce8c0e07cd867 @kwwette kwwette committed Jun 2, 2014
Showing with 4,187 additions and 3,601 deletions.
  1. +4 −0 Lib/octave/attribute.i
  2. +105 −78 Lib/octave/boost_shared_ptr.i
  3. +5 −1 Lib/octave/carrays.i
  4. +4 −0 Lib/octave/cdata.i
  5. +4 −0 Lib/octave/cmalloc.i
  6. +0 −132 Lib/octave/director.swg
  7. +5 −2 Lib/octave/exception.i
  8. +4 −0 Lib/octave/factory.i
  9. +4 −1 Lib/octave/implicit.i
  10. +13 −2 Lib/octave/octave.swg
  11. +60 −69 Lib/octave/octcomplex.swg
  12. +485 −500 Lib/octave/octcontainer.swg
  13. +19 −0 Lib/octave/octfragments.swg
  14. +285 −297 Lib/octave/octiterators.swg
  15. +8 −9 Lib/octave/octopers.swg
  16. +196 −169 Lib/octave/octprimtypes.swg
  17. +0 −1,389 Lib/octave/octrun.swg
  18. +1,203 −0 Lib/octave/octrunclass.swg
  19. +479 −0 Lib/octave/octrundecl.swg
  20. +187 −0 Lib/octave/octrunfunc.swg
  21. +422 −0 Lib/octave/octruninit.swg
  22. +15 −318 Lib/octave/octruntime.swg
  23. +220 −188 Lib/octave/octstdcommon.swg
  24. +16 −39 Lib/octave/octtypemaps.swg
  25. +57 −62 Lib/octave/octuserdir.swg
  26. +4 −0 Lib/octave/std_alloc.i
  27. +50 −46 Lib/octave/std_basic_string.i
  28. +3 −0 Lib/octave/std_carray.i
  29. +4 −0 Lib/octave/std_char_traits.i
  30. +65 −55 Lib/octave/std_common.i
  31. +7 −12 Lib/octave/std_complex.i
  32. +4 −0 Lib/octave/std_container.i
  33. +13 −6 Lib/octave/std_deque.i
  34. +4 −0 Lib/octave/std_except.i
  35. +13 −7 Lib/octave/std_list.i
  36. +59 −90 Lib/octave/std_map.i
  37. +115 −99 Lib/octave/std_pair.i
  38. +4 −0 Lib/octave/std_string.i
  39. +7 −6 Lib/octave/std_vector.i
  40. +4 −1 Lib/octave/stl.i
  41. +4 −0 Lib/octave/typemaps.i
  42. +27 −23 Source/Modules/octave.cxx
View
@@ -1 +1,5 @@
+//
+// attribute.i - Attribute support
+//
+
%include <typemaps/attribute.swg>

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,5 +1,9 @@
+//
+// carrays.i - Manipulate simple pointers as arrays
+//
+
%define %array_class(TYPE,NAME)
- %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
+%array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
%enddef
%include <typemaps/carrays.swg>
View
@@ -1 +1,5 @@
+//
+// cdata.i - Manipulate raw C data as strings
+//
+
%include <typemaps/cdata.swg>
View
@@ -1 +1,5 @@
+//
+// cmalloc.i - Object creation using C malloc()
+//
+
%include <typemaps/cmalloc.swg>
View
@@ -1,132 +0,0 @@
-/* -----------------------------------------------------------------------------
- * director.swg
- *
- * This file contains support for director classes so that D proxy
- * methods can be called from C++.
- * ----------------------------------------------------------------------------- */
-
-# define SWIG_DIRECTOR_CAST(ARG) dynamic_cast<Swig::Director *>(ARG)
-
-#include <exception>
-
-namespace Swig {
-
- class Director {
- octave_swig_type *self;
- bool swig_disowned;
-
- Director(const Director &x);
- Director &operator=(const Director &rhs);
- public:
-
- Director(void *vptr):self(0), swig_disowned(false) {
- set_rtdir(vptr, this);
- }
-
- ~Director() {
- swig_director_destroyed(self, this);
- if (swig_disowned)
- self->decref();
- }
-
- void swig_set_self(octave_swig_type *new_self) {
- assert(!swig_disowned);
- self = new_self;
- }
-
- octave_swig_type *swig_get_self() const {
- return self;
- }
-
- void swig_disown() {
- if (swig_disowned)
- return;
- swig_disowned = true;
- self->incref();
- }
- };
-
- struct DirectorTypeMismatchException {
- static void raise(const char *msg) {
- // ... todo
- throw(DirectorTypeMismatchException());
- }
-
- static void raise(const octave_value &ov, const char *msg) {
- // ... todo
- raise(msg);
- }
- };
-
- struct DirectorPureVirtualException {
- static void raise(const char *msg) {
- // ... todo
- throw(DirectorPureVirtualException());
- }
-
- static void raise(const octave_value &ov, const char *msg) {
- // ... todo
- raise(msg);
- }
- };
-
- SWIGINTERN rtdir_map *get_rtdir_map() {
- static swig_module_info *module = 0;
- if (!module)
- module = SWIG_GetModule(0);
- if (!module)
- return 0;
- if (!module->clientdata)
- module->clientdata = new rtdir_map;
- return (rtdir_map *) module->clientdata;
- }
-
- SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
- rtdir_map *rm = get_rtdir_map();
- if (rm)
- (*rm)[vptr] = d;
- }
-
- SWIGINTERNINLINE void erase_rtdir(void *vptr) {
- rtdir_map *rm = get_rtdir_map();
- if (rm)
- (*rm).erase(vptr);
- }
-
- SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
- rtdir_map *rm = get_rtdir_map();
- if (!rm)
- return 0;
- rtdir_map::const_iterator pos = rm->find(vptr);
- Director *rtdir = (pos != rm->end())? pos->second : 0;
- return rtdir;
- }
-
- SWIGRUNTIME void swig_director_destroyed(octave_swig_type *self, Director *d) {
- self->director_destroyed(d);
- }
-
- SWIGRUNTIME octave_swig_type *swig_director_get_self(Director *d) {
- return d->swig_get_self();
- }
-
- SWIGRUNTIME void swig_director_set_self(Director *d, octave_swig_type *self) {
- d->swig_set_self(self);
- }
-
-}
-
-SWIGRUNTIME void swig_acquire_ownership(void *vptr) {
- // assert(0);
- // ... todo
-}
-
-SWIGRUNTIME void swig_acquire_ownership_array(void *vptr) {
- // assert(0);
- // ... todo
-}
-
-SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own) {
- // assert(0);
- // ... todo
-}
View
@@ -1,6 +1,9 @@
-%include <typemaps/exception.swg>
+//
+// exception.i - C++ exception support
+//
+%include <typemaps/exception.swg>
%insert("runtime") {
- %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; ))
+%define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; ))
}
View
@@ -1 +1,5 @@
+//
+// factory.i - Factory method wrapping
+//
+
%include <typemaps/factory.swg>
View
@@ -1,7 +1,10 @@
+//
+// implicit.i - %implicit directive
+//
+
%include <std_common.i>
%include <typemaps/implicit.swg>
#warning "This file provides the %implicit directive, which is an old and fragile"
#warning "way to implement the C++ implicit conversion mechanism."
#warning "Try using the more robust '%implicitconv Type;' directive instead."
-
View
@@ -1,8 +1,19 @@
+//
+// octave.swg - Octave configuration module
+//
+
+// Include standard SWIG macros and fragments
%include <typemaps/swigmacros.swg>
%include <typemaps/fragments.swg>
+
+// Include Octave runtime code
%include <octruntime.swg>
-%include <octuserdir.swg>
+
+// Include Octave typemaps
%include <octtypemaps.swg>
+
+// Include Octave overloaded operator support
%include <octopers.swg>
-%define %docstring %feature("docstring") %enddef
+// Include Octave special user directives
+%include <octuserdir.swg>
View
@@ -1,92 +1,83 @@
-/*
- Defines the As/From conversors for double/float complex, you need to
- provide complex Type, the Name you want to use in the conversors,
- the complex Constructor method, and the Real and Imag complex
- accesor methods.
+//
+// octcomplex.swg - Octave complex number support
+//
- See the std_complex.i and ccomplex.i for concrete examples.
-*/
+// Defines the As/From conversors for double/float complex, you need to
+// provide complex Type, the Name you want to use in the conversors,
+// the complex Constructor method, and the Real and Imag complex accessor
+// methods. See the std_complex.i and ccomplex.i for concrete examples.
-/* the common from conversor */
+// Common 'from' conversor
%define %swig_fromcplx_conv(Type, OctConstructor, Real, Imag)
- %fragment(SWIG_From_frag(Type),"header")
+%fragment(SWIG_From_frag(Type), "header")
{
- SWIGINTERNINLINE octave_value
- SWIG_From(Type)(const Type& c)
- {
- return octave_value(OctConstructor(Real(c), Imag(c)));
- }
+ SWIGINTERNINLINE octave_value SWIG_From(Type)(const Type & c) {
+ return octave_value(OctConstructor(Real(c), Imag(c)));
+ }
}
%enddef
-// the double case
+// Double-precision 'as' conversor
%define %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
- %fragment(SWIG_AsVal_frag(Type),"header",
- fragment=SWIG_AsVal_frag(double))
+%fragment(SWIG_AsVal_frag(Type), "header", fragment = SWIG_AsVal_frag(double))
{
- SWIGINTERN int
- SWIG_AsVal(Type) (const octave_value& ov, Type* val)
- {
- if (ov.is_complex_scalar()) {
- if (val) {
- Complex c(ov.complex_value());
- *val=Constructor(c.real(),c.imag());
- }
- return SWIG_OK;
- } else {
- double d;
- int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d));
- if (SWIG_IsOK(res)) {
- if (val)
- *val = Constructor(d, 0.0);
- return res;
- }
+ SWIGINTERN int SWIG_AsVal(Type)(const octave_value & ov, Type * val) {
+ if (ov.is_complex_scalar()) {
+ if (val) {
+ Complex c(ov.complex_value());
+ *val = Constructor(c.real(), c.imag());
+ }
+ return SWIG_OK;
+ } else {
+ double d;
+ int res = SWIG_AddCast(SWIG_AsVal(double)(ov, &d));
+ if (SWIG_IsOK(res)) {
+ if (val) {
+ *val = Constructor(d, 0.0);
+ }
+ return res;
}
- return SWIG_TypeError;
}
+ return SWIG_TypeError;
+ }
}
%swig_fromcplx_conv(Type, Complex, Real, Imag);
%enddef
-// the float case
+// Single-precision 'as' conversor
%define %swig_cplxflt_conv(Type, Constructor, Real, Imag)
- %fragment(SWIG_AsVal_frag(Type),"header",
- fragment=SWIG_AsVal_frag(float)) {
- SWIGINTERN int
- SWIG_AsVal(Type) (const octave_value& ov, Type* val)
- {
- if (ov.is_complex_scalar()) {
- if (val) {
- Complex c(ov.complex_value());
- double re = c.real();
- double im = c.imag();
- if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
- if (val)
- *val = Constructor(%numeric_cast(re, float),
- %numeric_cast(im, float));
- return SWIG_OK;
- } else
- return SWIG_OverflowError;
- }
- } else {
- float d;
- int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
- if (SWIG_IsOK(res)) {
- if (val)
- *val = Constructor(d, 0.0);
- return res;
- }
+%fragment(SWIG_AsVal_frag(Type), "header", fragment = SWIG_AsVal_frag(float))
+{
+ SWIGINTERN int SWIG_AsVal(Type)(const octave_value & ov, Type * val) {
+ if (ov.is_complex_scalar()) {
+ if (val) {
+ Complex c(ov.complex_value());
+ double re = c.real();
+ double im = c.imag();
+ if ((-FLT_MAX <= re && re <= FLT_MAX) && (-FLT_MAX <= im && im <= FLT_MAX)) {
+ if (val)
+ *val = Constructor(%numeric_cast(re, float), %numeric_cast(im, float));
+ return SWIG_OK;
+ } else {
+ return SWIG_OverflowError;
+ }
+ }
+ } else {
+ float d;
+ int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
+ if (SWIG_IsOK(res)) {
+ if (val) {
+ *val = Constructor(d, 0.0);
+ }
+ return res;
}
- return SWIG_TypeError;
}
+ return SWIG_TypeError;
+ }
}
%swig_fromcplx_conv(Type, FloatComplex, Real, Imag);
%enddef
-#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) \
-%swig_cplxflt_conv(Type, Constructor, Real, Imag)
-
-
-#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) \
-%swig_cplxdbl_conv(Type, Constructor, Real, Imag)
+#define %swig_cplxflt_convn(Type, Constructor, Real, Imag) %swig_cplxflt_conv(Type, Constructor, Real, Imag)
+#define %swig_cplxdbl_convn(Type, Constructor, Real, Imag) %swig_cplxdbl_conv(Type, Constructor, Real, Imag)
Oops, something went wrong.

0 comments on commit c110e79

Please sign in to comment.