/* vim: set ft=cpp: */ %% headers #include #include "ext/gtk+/php_gtk+.h" #include %% constants REGISTER_LONG_CONSTANT("GTK_TYPE_ITEM_ENTRY", GTK_TYPE_ITEM_ENTRY, CONST_CS | CONST_PERSISTENT); %% ignore-glob *_get_type %% override gtk_plot_add_data PHP_FUNCTION(gtk_plot_add_data) { zval *data; // comment NOT_STATIC_METHOD(); if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "O", &data, gtk_plotdata_ce)) return; gtk_plot_add_data(GTK_PLOT(PHP_GTK_GET(this_ptr)), GTK_PLOT_DATA(PHP_GTK_GET(data))); RETURN_NULL(); } %% override gtk_plot_data_set_points PHP_FUNCTION(gtk_plot_data_set_points) { gdouble *x; gdouble *y; gdouble *dx; gdouble *dy; zval ** temp; zval *php_x = NULL; zval *php_y = NULL; zval *php_dx = NULL; zval *php_dy = NULL; gint j; HashTable *hash; gint n_elems; NOT_STATIC_METHOD(); if( !php_gtk_parse_args(ZEND_NUM_ARGS(),"a/a/a/a/i", &php_x,&php_y,&php_dx,&php_dy,&n_elems )) return; // n_elems = zend_hash_num_elements( hash ); // n_elems = num_points; hash = HASH_OF(php_x); x = emalloc( n_elems * sizeof( gdouble )); j = 0; zend_hash_internal_pointer_reset( hash ); while( j < n_elems && zend_hash_get_current_data( hash, (void **)&temp) == SUCCESS ) { x[j++] = (gdouble) Z_DVAL_PP( temp ); zend_hash_move_forward(hash); } hash = HASH_OF(php_y); y = emalloc( n_elems * sizeof( gdouble )); j = 0; zend_hash_internal_pointer_reset( hash ); while( j < n_elems && zend_hash_get_current_data( hash, (void **)&temp) == SUCCESS ) { y[j++] = (gdouble) Z_DVAL_PP( temp ); zend_hash_move_forward(hash); } hash = HASH_OF(php_dx); dx = emalloc( n_elems * sizeof( gdouble )); j = 0; zend_hash_internal_pointer_reset( hash ); while( j < n_elems && zend_hash_get_current_data( hash, (void **)&temp) == SUCCESS ) { dx[j++] = (gdouble) Z_DVAL_PP( temp ); zend_hash_move_forward(hash); } hash = HASH_OF(php_dy); dy = emalloc( n_elems * sizeof( gdouble )); j = 0; zend_hash_internal_pointer_reset( hash ); while( j < n_elems && zend_hash_get_current_data( hash, (void **)&temp) == SUCCESS ) { dy[j++] = (gdouble) Z_DVAL_PP( temp ); zend_hash_move_forward(hash); } gtk_plot_data_set_points( GTK_PLOT_DATA(PHP_GTK_GET(this_ptr)),x, y, dx, dy, n_elems); /* efree( x ); efree( y ); efree( dx ); efree( dy ); */ RETURN_NULL(); } %% override gtk_plot_axis_set_title PHP_FUNCTION(gtk_plot_axis_set_title) { GtkPlotAxisPos pos; zval *php_pos = NULL; char *title; NOT_STATIC_METHOD(); if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "Vs", &php_pos, &title)) return; if (php_pos && !php_gtk_get_simple_enum_value(php_pos, (gint *)&pos)) { return; } gtk_plot_axis_set_title(GTK_PLOT(PHP_GTK_GET(this_ptr)), pos, title); RETURN_NULL(); } /*---------------------- Gtk Sheet Overrides --------------------------*/ %% override gtk_sheet_get_active_cell PHP_FUNCTION(gtk_sheet_get_active_cell) { gint row, column; NOT_STATIC_METHOD(); if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "")) return; gtk_sheet_get_active_cell(GTK_SHEET(PHP_GTK_GET(this_ptr)), &row, &column); array_init(return_value); add_next_index_double(return_value, (long)row); add_next_index_double(return_value, (long)column); }