Show
Ignore:
Timestamp:
11/27/07 17:21:31 (14 months ago)
Author:
gyuque
Message:

lang/ruby/RubyESRIShape: added Ruby class 'Polyline'

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/RubyESRIShape/RubyESRIShape.c

    r2057 r2059  
    44static VALUE rb_cShape       = 0; 
    55static VALUE rb_cPolygon     = 0; 
     6static VALUE rb_cPolyline    = 0; 
    67static VALUE rb_cPoint       = 0; 
    78static VALUE rb_cBoundingBox = 0; 
     
    1011{ 
    1112        return rb_cPolygon; 
     13} 
     14 
     15VALUE getRubyESRIShapePolylineClass() 
     16{ 
     17        return rb_cPolyline; 
    1218} 
    1319 
     
    3137static void  rb_polygon_free(void *ptr); 
    3238static void  rb_polygon_mark(void *ptr); 
     39 
     40static VALUE rb_polyline_allocate(VALUE klass); 
     41static void  rb_polyline_free(void *ptr); 
    3342 
    3443static void  rb_point_free(void *ptr); 
     
    185194 
    186195        return c_Polygon_getBoundingBox(indata->pThis); 
     196} 
     197 
     198// Polyline 
     199 
     200static VALUE rb_polyline_allocate(VALUE klass) 
     201{ 
     202        RPolylineData* indata = ALLOC(RPolylineData); 
     203        indata->pThis = NULL; 
     204 
     205        return Data_Wrap_Struct(klass, 0, rb_polyline_free, indata); 
     206} 
     207 
     208static void rb_polyline_free(void *ptr) 
     209{ 
     210        if (ptr) 
     211        { 
     212                if (((RPolylineData*)ptr)->pThis) 
     213                        c_Polyline_delete(((RPolylineData*)ptr)->pThis); 
     214                free(ptr); 
     215        } 
    187216} 
    188217 
     
    311340        rb_define_method(rb_cPolygon, "each"  , rb_polygon_each  , 0); 
    312341        rb_define_method(rb_cPolygon, "bounding_box", rb_polygon_bounding_box, 0); 
     342 
     343        // class 
     344        rb_cPolyline = rb_define_class_under (rb_mRubyESRIShape, "Polyline", rb_cObject); 
     345        rb_define_alloc_func(rb_cPolyline, rb_polyline_allocate); 
    313346 
    314347        // class