dox/Common/vtkRubyUtil.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkRubyUtil.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 #ifndef __vtkRubyUtil_h
00016 #define __vtkRubyUtil_h
00017 
00018 #include "vtkRuby.h"
00019 #include "vtkCommand.h"
00020 
00021 #if defined(WIN32)
00022 # if defined(vtkCommonRubyD_EXPORTS)
00023 #  define VTK_RUBY_EXPORT __declspec(dllexport)
00024 # else
00025 #  define VTK_RUBY_EXPORT __declspec(dllimport)
00026 # endif
00027 #else
00028 # define VTK_RUBY_EXPORT
00029 #endif
00030 
00031 // This is the VTK/Ruby 'class,' it contains the method list and a pointer
00032 // to the superclass
00033 typedef vtkObjectBase *(*vtknewfunc)();
00034 
00035 typedef struct {
00036   vtkObjectBase *vtk_ptr;
00037   int ref_count;
00038   VALUE mark;
00039 } rbVTKObject;
00040 
00041 // This for objects not derived from vtkObjectBase
00042 typedef struct {
00043   void *ptr;
00044   int ref_count;
00045   VALUE mark;
00046 } rbVTKSpecialObject;
00047 
00048 
00049 extern VTK_RUBY_EXPORT
00050 VALUE rb_VTKClass(const char*);
00051 
00052 extern VTK_RUBY_EXPORT
00053 VALUE rb_vtkObjectBaseClass(void);
00054 
00055 extern VTK_RUBY_EXPORT
00056 VALUE rb_vtk_define_class_under(VALUE module, const char* name, VALUE super);
00057 
00058 // Standard methods for all vtk/ruby objects
00059 extern VTK_RUBY_EXPORT
00060 VALUE rb_VTKObject_New(VALUE vtkclass, vtkObjectBase *ptr);
00061 
00062 extern VTK_RUBY_EXPORT
00063 void rb_VTKObject_PushMark(VALUE self, VALUE other);
00064 
00065 
00066 
00067 // Extract the vtkObjectBase from a rbVTKObject.  If the VALUE is not a 
00068 // rbVTKObject, or is not a rbVTKObject of the specified type, the ruby
00069 // error indicator will be set.
00070 // Special behaviour: Qnil is converted to NULL without no error.
00071 extern VTK_RUBY_EXPORT
00072 vtkObjectBase *vtkRubyGetPointerFromObject(VALUE obj);
00073 
00074 // Convert a vtkObjectBase to a rbVTKObject.  This will first check to see if
00075 // the rbVTKObject already exists, and create a new rbVTKObject if necessary.
00076 // This function also passes ownership of the reference to the VALUE.
00077 // Special behaviour: NULL is converted to Qnil.
00078 extern VTK_RUBY_EXPORT
00079 VALUE vtkRubyGetObjectFromPointer(vtkObjectBase *ptr);
00080 extern VTK_RUBY_EXPORT
00081 VALUE vtkRubyGetObjectFromPointer(vtkObjectBase *ptr, VALUE klass);
00082 extern VTK_RUBY_EXPORT
00083 VALUE vtkRubyGetObjectFromObject(VALUE arg, const char *type, VALUE klass);
00084 
00085 extern VTK_RUBY_EXPORT
00086 void vtkRubyUnRegister(rbVTKObject *obj);
00087 extern VTK_RUBY_EXPORT
00088 void vtkRubyUnRegister(VALUE self);
00089 
00090 extern VTK_RUBY_EXPORT
00091 char *vtkRubyManglePointer(void *ptr, const char *type);
00092 extern VTK_RUBY_EXPORT
00093 void *vtkRubyUnmanglePointer(char *ptrText, int *len, const char *type);
00094 
00095 
00096 // check array arguments sent through the wrappers to see if the underlying
00097 // C++ method changed the values, and attempt to modify the original ruby
00098 // sequence (list or tuple) if so.
00099 extern VTK_RUBY_EXPORT
00100 int vtkRubyCheckArray(VALUE *args, int i, char *a, int n);
00101 extern VTK_RUBY_EXPORT
00102 int vtkRubyCheckArray(VALUE *args, int i, signed char *a, int n);
00103 extern VTK_RUBY_EXPORT
00104 int vtkRubyCheckArray(VALUE *args, int i, unsigned char *a, int n);
00105 extern VTK_RUBY_EXPORT
00106 int vtkRubyCheckArray(VALUE *args, int i, short *a, int n);
00107 extern VTK_RUBY_EXPORT
00108 int vtkRubyCheckArray(VALUE *args, int i, unsigned short *a, int n);
00109 extern VTK_RUBY_EXPORT
00110 int vtkRubyCheckArray(VALUE *args, int i, int *a, int n);
00111 extern VTK_RUBY_EXPORT
00112 int vtkRubyCheckArray(VALUE *args, int i, unsigned int *a, int n);
00113 extern VTK_RUBY_EXPORT
00114 int vtkRubyCheckArray(VALUE *args, int i, long *a, int n);
00115 extern VTK_RUBY_EXPORT
00116 int vtkRubyCheckArray(VALUE *args, int i, unsigned long *a, int n);
00117 extern VTK_RUBY_EXPORT
00118 int vtkRubyCheckArray(VALUE *args, int i, float *a, int n);
00119 extern VTK_RUBY_EXPORT
00120 int vtkRubyCheckArray(VALUE *args, int i, double *a, int n);
00121 #if defined(VTK_TYPE_USE_LONG_LONG)
00122 extern VTK_RUBY_EXPORT
00123 int vtkRubyCheckArray(VALUE *args, int i, long long *a, int n);
00124 extern VTK_RUBY_EXPORT
00125 int vtkRubyCheckArray(VALUE *args, int i, unsigned long long *a, int n);
00126 #endif
00127 #if defined(VTK_TYPE_USE___INT64)
00128 extern VTK_RUBY_EXPORT
00129 int vtkRubyCheckArray(VALUE *args, int i, __int64 *a, int n);
00130 extern VTK_RUBY_EXPORT
00131 int vtkRubyCheckArray(VALUE *args, int i, unsigned __int64 *a, int n);
00132 #endif
00133 
00134 // For use by SetXXMethod() , SetXXMethodArgDelete()
00135 extern VTK_RUBY_EXPORT void vtkRubyVoidFunc(void *);
00136 extern VTK_RUBY_EXPORT void vtkRubyVoidFuncArgDelete(void *);
00137 
00138 // To allow Ruby to use the vtkCommand features
00139 class vtkRubyCommand : public vtkCommand
00140 {
00141 public:
00142   static vtkRubyCommand *New() { return new vtkRubyCommand; };
00143 
00144   void SetObject(VALUE o);
00145   void Execute(vtkObject *ptr, unsigned long eventtype, void *CallData);
00146  
00147   VALUE obj;
00148 protected:
00149   vtkRubyCommand();
00150   ~vtkRubyCommand(); 
00151 };
00152 
00153 #endif

Generated on Mon Mar 10 13:05:47 2008 for VTK by  doxygen 1.5.1