Changeset e89ec48 for perlglue.xs


Ignore:
Timestamp:
Sep 30, 2011, 8:06:58 AM (10 years ago)
Author:
Jason Gross <jgross@mit.edu>
Branches:
master, release-1.9
Children:
7803326
Parents:
c737503
git-author:
Jason Gross <jgross@mit.edu> (07/10/11 17:58:20)
git-committer:
Jason Gross <jgross@mit.edu> (09/30/11 08:06:58)
Message:
Made BarnOwl::start_* wrappers around a new BarnOwl::start_edit

A new function, BarnOwl::start_edit, was created as the preferred
interface for starting the edit_win from perl.

The perl interface to the edit_win is backwards compatible.

This is mostly preparation for the next commit, which generalizes the
syntax of starting an edit_win to allow callbacks on cancel.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlglue.xs

    rc737503 re89ec48  
    167167        }
    168168
    169 void
    170 start_question(line, callback)
    171         const char *line
    172         SV *callback
    173         PREINIT:
    174                 owl_editwin *e;
    175         CODE:
    176         {
    177                 if(!SV_IS_CODEREF(callback))
    178                         croak("Callback must be a subref");
    179 
    180                 e = owl_function_start_question(line);
    181 
    182                 owl_editwin_set_cbdata(e,
    183                                        newSVsv(callback),
    184                                        owl_perlconfig_dec_refcnt);
    185                 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
    186         }
    187 
    188 void
    189 start_password(line, callback)
    190         const char *line
    191         SV *callback
    192         PREINIT:
    193                 owl_editwin *e;
    194         CODE:
    195         {
    196                 if(!SV_IS_CODEREF(callback))
    197                         croak("Callback must be a subref");
    198 
    199                 e = owl_function_start_password(line);
    200 
    201                 owl_editwin_set_cbdata(e,
    202                                        newSVsv(callback),
    203                                        owl_perlconfig_dec_refcnt);
    204                 owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
    205         }
    206 
    207 void
    208 start_edit_win(line, callback)
    209         const char *line
    210         SV *callback
    211         PREINIT:
    212                 owl_editwin *e;
    213         CODE:
    214         {
    215                 if(!SV_IS_CODEREF(callback))
    216                         croak("Callback must be a subref");
    217 
    218                 e = owl_function_start_edit_win(line);
    219                 owl_editwin_set_cbdata(e,
    220                                        newSVsv(callback),
    221                                        owl_perlconfig_dec_refcnt);
    222                 owl_editwin_set_callback(e, &owl_perlconfig_edit_callback);
    223         }
    224 
    225169
    226170const char *
     
    499443                                      ival);
    500444
     445void
     446start_edit(edit_type, line, callback)
     447        const char *edit_type
     448        const char *line
     449        SV *callback
     450        PREINIT:
     451                owl_editwin *e;
     452        CODE:
     453        {
     454                if (!SV_IS_CODEREF(callback))
     455                        croak("Callback must be a subref");
     456
     457                if (!strcmp(edit_type, "question"))
     458                        e = owl_function_start_question(line);
     459                else if (!strcmp(edit_type, "password"))
     460                        e = owl_function_start_password(line);
     461                else if (!strcmp(edit_type, "edit_win"))
     462                        e = owl_function_start_edit_win(line);
     463                else
     464                        croak("edit_type must be one of 'password', 'question', 'edit_win', not '%s'", edit_type);
     465
     466                owl_editwin_set_cbdata(e, newSVsv(callback), owl_perlconfig_dec_refcnt);
     467                owl_editwin_set_callback(e, owl_perlconfig_edit_callback);
     468        }
     469
    501470MODULE = BarnOwl                PACKAGE = BarnOwl::Editwin
    502471
Note: See TracChangeset for help on using the changeset viewer.