Changeset 3087 for libpipi/trunk


Ignore:
Timestamp:
Oct 24, 2008, 5:16:59 PM (12 years ago)
Author:
nico
Message:
  • Change return value for function (success return (bool) true):

pipi_load, pipi_save, pipi_command, pipi_render_histogram,
pipi_get_image_histogram

  • Add pipi's php constants definitions
Location:
libpipi/trunk/pipi-php
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi-php/examples/example1.php

    r3079 r3087  
    11<?
    22//print_r(pipi_get_command_list());
     3echo PIPI_COLOR_Y;
    34
    45$img = pipi_load_stock("random:128x128");
  • libpipi/trunk/pipi-php/examples/pipi.php

    r3086 r3087  
    2323               
    2424                $cmd_argc = $list[$cmd_name];
    25                 if ($argi + $cmd_argc > $argc) {
    26                         die("too few arguments for $arg_name\n");
     25                if ($argi + $cmd_argc + 1 > $argc) {
     26                        die("too few arguments for $cmd_name\n");
    2727                }
    2828
     
    3737                                die();
    3838                }
    39                 if ($res != 0) {
     39                if (!$res) {
    4040                        die("command $cmd_name failed\n");
    4141                }
     
    4343        }
    4444        else {
    45                   if (pipi_command($ctx, "load", $arg) != 0)
     45                  if (!pipi_command($ctx, "load", $arg))
    4646                        die("could not load $arg\n");
    4747        }
  • libpipi/trunk/pipi-php/php_pipi.c

    r3086 r3087  
    143143        le_pipi_context = zend_register_list_destructors_ex(php_pipi_context_dtor, NULL, PHP_PIPI_CONTEXT_RES_NAME, module_number);
    144144        le_pipi_histogram = zend_register_list_destructors_ex(php_pipi_histogram_dtor, NULL, PHP_PIPI_HISTOGRAM_RES_NAME, module_number);
     145
     146        REGISTER_LONG_CONSTANT("PIPI_SCAN_RASTER", PIPI_SCAN_RASTER, CONST_CS | CONST_PERSISTENT);
     147        REGISTER_LONG_CONSTANT("PIPI_SCAN_SERPENTINE", PIPI_SCAN_SERPENTINE, CONST_CS | CONST_PERSISTENT);
     148        REGISTER_LONG_CONSTANT("PIPI_PIXELS_UNINITIALISED", PIPI_PIXELS_UNINITIALISED, CONST_CS | CONST_PERSISTENT);
     149        REGISTER_LONG_CONSTANT("PIPI_PIXELS_RGBA_C", PIPI_PIXELS_RGBA_C, CONST_CS | CONST_PERSISTENT);
     150        REGISTER_LONG_CONSTANT("PIPI_PIXELS_BGR_C", PIPI_PIXELS_BGR_C, CONST_CS | CONST_PERSISTENT);
     151        REGISTER_LONG_CONSTANT("PIPI_PIXELS_RGBA_F", PIPI_PIXELS_RGBA_F, CONST_CS | CONST_PERSISTENT);
     152        REGISTER_LONG_CONSTANT("PIPI_PIXELS_Y_F", PIPI_PIXELS_Y_F, CONST_CS | CONST_PERSISTENT);
     153        REGISTER_LONG_CONSTANT("PIPI_PIXELS_MASK_C", PIPI_PIXELS_MASK_C, CONST_CS | CONST_PERSISTENT);
     154        REGISTER_LONG_CONSTANT("PIPI_PIXELS_MAX", PIPI_PIXELS_MAX, CONST_CS | CONST_PERSISTENT);
     155        REGISTER_LONG_CONSTANT("PIPI_COLOR_R", PIPI_COLOR_R, CONST_CS | CONST_PERSISTENT);
     156        REGISTER_LONG_CONSTANT("PIPI_COLOR_G", PIPI_COLOR_G, CONST_CS | CONST_PERSISTENT);
     157        REGISTER_LONG_CONSTANT("PIPI_COLOR_B", PIPI_COLOR_B, CONST_CS | CONST_PERSISTENT);
     158        REGISTER_LONG_CONSTANT("PIPI_COLOR_A", PIPI_COLOR_A, CONST_CS | CONST_PERSISTENT);
     159        REGISTER_LONG_CONSTANT("PIPI_COLOR_Y", PIPI_COLOR_Y, CONST_CS | CONST_PERSISTENT);
     160
    145161        return SUCCESS;
    146162}
    147163
    148 //----------SOMEMACROS---------------//
     164//----------SOME USEFULL MACROS---------------//
    149165
    150166#define FETCH_STR(str) \
     
    167183
    168184#define FETCH_IMG_IMG(img1, img2) \
    169         zval *_zval1; \
    170         zval *_zval2; \
     185        zval *_zval1, *_zval2; \
    171186        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &_zval1, &_zval2) == FAILURE) { \
    172187                RETURN_FALSE; \
     
    193208
    194209PHP_FUNCTION(pipi_get_command_list) {
    195         pipi_command_t const *list;
    196         pipi_command_t const *cmd;
     210        pipi_command_t const *list, *cmd;
    197211        list = pipi_get_command_list();
    198212
     
    214228
    215229        if (arg2_len != 0) {
    216                 RETURN_LONG(pipi_command(ctxt, arg1, arg2));
    217         }
    218         RETURN_LONG(pipi_command(ctxt, arg1)); 
     230                RETURN_BOOL(pipi_command(ctxt, arg1, arg2) == 0);
     231        }
     232        RETURN_BOOL(pipi_command(ctxt, arg1) == 0);     
    219233}
    220234
     
    263277        ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image);
    264278
    265         RETURN_LONG(pipi_save(img, str));       
     279        RETURN_BOOL(pipi_save(img, str) == 0); 
    266280}
    267281
     
    762776        ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram);
    763777
    764         RETURN_LONG(pipi_get_image_histogram(image, histogram, flags));
     778        RETURN_BOOL(pipi_get_image_histogram(image, histogram, flags) == 0);
    765779}
    766780
     
    776790        ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram);
    777791
    778         RETURN_LONG(pipi_render_histogram(image, histogram, flags));
    779 }
    780 
    781 
     792        RETURN_BOOL(pipi_render_histogram(image, histogram, flags) == 0);
     793}
     794
     795
Note: See TracChangeset for help on using the changeset viewer.