Changeset 3129


Ignore:
Timestamp:
Oct 28, 2008, 2:45:39 PM (15 years ago)
Author:
nico
Message:
  • Add php binding for caca_load_font, caca_get_font_blocks, caca_put_figchar
  • Add a working sample file examples/figfont.php
  • Rename sample programs:

examples1.php > cacapig.php
drivers.php > cacainfo.php

Location:
libcaca/trunk/caca-php
Files:
1 added
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca-php/php_caca.c

    r3128 r3129  
    112112        PHP_FE(caca_get_font_width, NULL)
    113113        PHP_FE(caca_get_font_height, NULL)
    114         PHP_FE(caca_get_font_bloc, NULL)
     114        PHP_FE(caca_get_font_blocks, NULL)
    115115        PHP_FE(caca_render_canvas, NULL)
    116116        PHP_FE(caca_canvas_set_figfont, NULL)
     
    12051205
    12061206PHP_FUNCTION(caca_load_font) {
     1207        char *str;
     1208        long str_len;
     1209        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
     1210                RETURN_FALSE;
     1211        }
     1212        caca_font_t *font = caca_load_font(str, str_len);
     1213        ZEND_REGISTER_RESOURCE(return_value, font, le_caca_font);
    12071214}
    12081215
     
    12351242}
    12361243
    1237 PHP_FUNCTION(caca_get_font_bloc) {
     1244PHP_FUNCTION(caca_get_font_blocks) {
     1245        zval *_zval;
     1246        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) {
     1247                RETURN_FALSE;
     1248        }
     1249        caca_font_t *font;
     1250        ZEND_FETCH_RESOURCE(font, caca_font_t*, &_zval, -1, PHP_CACA_FONT_RES_NAME, le_caca_font);
     1251
     1252        uint32_t const *list = caca_get_font_blocks(font);
     1253
     1254        int i;
     1255        array_init(return_value);       
     1256        for(i = 0; list[i]; i += 1)
     1257                add_next_index_long(return_value, list[i]);
    12381258}
    12391259
     
    12541274
    12551275PHP_FUNCTION(caca_put_figchar) {
     1276        zval *_zval;
     1277        long c;
     1278        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &_zval, &c) == FAILURE) {
     1279                RETURN_FALSE;
     1280        }
     1281        caca_canvas_t *canvas;
     1282        ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas);
     1283
     1284        //TODO: get a string instead of a long
     1285        caca_put_figchar(canvas, c);
    12561286}
    12571287
  • libcaca/trunk/caca-php/php_caca.h

    r3127 r3129  
    129129PHP_FUNCTION(caca_get_font_width);
    130130PHP_FUNCTION(caca_get_font_height);
    131 PHP_FUNCTION(caca_get_font_bloc);
     131PHP_FUNCTION(caca_get_font_blocks);
    132132PHP_FUNCTION(caca_render_canvas);
    133133PHP_FUNCTION(caca_canvas_set_figfont);
Note: See TracChangeset for help on using the changeset viewer.