about summary refs log blame commit diff stats
path: root/archive/0.vm.arc/factorial.mu
blob: 96a28fd3e6da197438589eaa95ecdfbfde5900a2 (plain) (tree)
1
2
3
4
5
6
7
8
9
                     
                                                               
                           
         
                     


                                                
   




                                                          

  
                
                                    
                                 
                                                
                           
  
(function factorial [
  (default-space:space-address <- new space:literal 30:literal)
  (n:integer <- next-input)
  { begin
    ; if n=0 return 1
    (zero?:boolean <- equal n:integer 0:literal)
    (break-unless zero?:boolean)
    (reply 1:literal)
  }
  ; return n*factorial(n-1)
  (x:integer <- subtract n:integer 1:literal)
  (subresult:integer <- factorial x:integer)
  (result:integer <- multiply subresult:integer n:integer)
  (reply result:integer)
])

(function main [
  (1:integer <- factorial 5:literal)
  ($print (("result: " literal)))
  (print-integer nil:literal/terminal 1:integer)
  ($print (("\n" literal)))
])
d4a816c607a6a7d74'>d157e9bf ^
0fc0b3ee ^
d157e9bf ^
0fc0b3ee ^









d157e9bf ^
0fc0b3ee ^
d157e9bf ^
0fc0b3ee ^






21f6e88c ^


d157e9bf ^
21f6e88c ^
d157e9bf ^
21f6e88c ^






0fc0b3ee ^






d157e9bf ^
0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^









d157e9bf ^

0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^









d157e9bf ^

0fc0b3ee ^
d157e9bf ^
0fc0b3ee ^









d157e9bf ^
0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^










d157e9bf ^




a4e6d50a ^
0fc0b3ee ^
a4e6d50a ^
0fc0b3ee ^













d157e9bf ^
9850e041 ^
d157e9bf ^
0fc0b3ee ^













d157e9bf ^
0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^












d157e9bf ^
0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^















d157e9bf ^
0fc0b3ee ^
d157e9bf ^

0fc0b3ee ^


4c913aa0 ^




a4e6d50a ^
4c913aa0 ^





a4e6d50a ^
4c913aa0 ^
a4e6d50a ^












4c913aa0 ^
a4e6d50a ^































4c913aa0 ^

e2b02733 ^







































ce9b0836 ^



































0fc0b3ee ^






































































d6e85e5c ^
0fc0b3ee ^






21f6e88c ^
0fc0b3ee ^








4c913aa0 ^
a4e6d50a ^

e2b02733 ^

ce9b0836 ^

0fc0b3ee ^







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677














































                                                                                
                           
                     

                             
                             
 








                                                    
                           
                           

                             












                                                                        
                           
                                                   

                             



                             





                                                             
                           
                                

                             



                             

























































                                                                                
                               

                                                                                       
                                 















                                                                        
                               
                                                                                
                                 

























                                                      
                           
                                     

                             













                                                                           
                           
                                              
                             











                                                    
                           
                        
                             






                                                                
                           
                                                  
                             









                                                          
                           
                                       
                             






                                        


                                                                 
                           
                                           
                             






                                            






                                                    
                           
                           

                             









                                                   

                           
                          

                             









                                                      

                           
                             
                             









                                                    
                           
                           

                             










                                                     




                                          
                                           
            
                                            













                                                           
                               
                                                                      
                                 













                                                    
                           
                       

                             












                                                     
                           
                            

                             















                                                                            
                           
                                                    

                             


                             




                                                      
                                            





                                      
                                           
            












                                                                               
     































                                                                               

 







































                                                              



































                                                             






































































                                                                                                            
                                                                                                                     






                                                                                                                                          
                                                                                                                                        








                                                                                                       
                                                                                    

                                                                                                       

                                                                                                    

                                                                                               







                                      
/*
 * python_api.c
 *
 * Copyright (C) 2012 - 2016 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Profanity is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Profanity.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give permission to
 * link the code of portions of this program with the OpenSSL library under
 * certain conditions as described in each individual source file, and
 * distribute linked combinations including the two.
 *
 * You must obey the GNU General Public License in all respects for all of the
 * code used other than OpenSSL. If you modify file(s) with this exception, you
 * may extend this exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this exception
 * statement from your version. If you delete this exception statement from all
 * source files in the program, then also delete it here.
 *
 */

#include <Python.h>

#include <glib.h>

#include "plugins/api.h"
#include "plugins/python_api.h"
#include "plugins/python_plugins.h"
#include "plugins/callbacks.h"
#include "plugins/autocompleters.h"

static PyObject*
python_api_cons_alert(PyObject *self, PyObject *args)
{
    allow_python_threads();
    api_cons_alert();
    disable_python_threads();

    return Py_BuildValue("");

}

static PyObject*
python_api_cons_show(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "s", &message)) {
        return Py_BuildValue("");
    }
    allow_python_threads();
    api_cons_show(message);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_cons_show_themed(PyObject *self, PyObject *args)
{
    const char *group = NULL;
    const char *key = NULL;
    const char *def = NULL;
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "zzzs", &group, &key, &def, &message)) {
        return Py_BuildValue("");
    }
    allow_python_threads();
    api_cons_show_themed(group, key, def, message);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_cons_bad_cmd_usage(PyObject *self, PyObject *args)
{
    const char *cmd = NULL;
    if (!PyArg_ParseTuple(args, "s", &cmd)) {
        return Py_BuildValue("");
    }
    allow_python_threads();
    api_cons_bad_cmd_usage(cmd);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_register_command(PyObject *self, PyObject *args)
{
    const char *command_name = NULL;
    int min_args = 0;
    int max_args = 0;
    PyObject *synopsis = NULL;
    const char *description = NULL;
    PyObject *arguments = NULL;
    PyObject *examples = NULL;
    PyObject *p_callback = NULL;

    if (!PyArg_ParseTuple(args, "siiOsOOO", &command_name, &min_args, &max_args,
            &synopsis, &description, &arguments, &examples, &p_callback)) {
        return Py_BuildValue("");
    }

    if (p_callback && PyCallable_Check(p_callback)) {
        Py_ssize_t len = PyList_Size(synopsis);
        const char *c_synopsis[len == 0 ? 0 : len+1];
        Py_ssize_t i = 0;
        for (i = 0; i < len; i++) {
            PyObject *item = PyList_GetItem(synopsis, i);
            char *c_item = PyString_AsString(item);
            c_synopsis[i] = c_item;
        }
        c_synopsis[len] = NULL;

        Py_ssize_t args_len = PyList_Size(arguments);
        const char *c_arguments[args_len == 0 ? 0 : args_len+1][2];
        i = 0;
        for (i = 0; i < args_len; i++) {
            PyObject *item = PyList_GetItem(arguments, i);
            Py_ssize_t len2 = PyList_Size(item);
            if (len2 != 2) {
                return Py_BuildValue("");
            }
            PyObject *arg = PyList_GetItem(item, 0);
            char *c_arg = PyString_AsString(arg);
            PyObject *desc = PyList_GetItem(item, 1);
            char *c_desc = PyString_AsString(desc);

            c_arguments[i][0] = c_arg;
            c_arguments[i][1] = c_desc;
        }

        c_arguments[args_len][0] = NULL;
        c_arguments[args_len][1] = NULL;

        len = PyList_Size(examples);
        const char *c_examples[len == 0 ? 0 : len+1];
        i = 0;
        for (i = 0; i < len; i++) {
            PyObject *item = PyList_GetItem(examples, i);
            char *c_item = PyString_AsString(item);
            c_examples[i] = c_item;
        }
        c_examples[len] = NULL;

        allow_python_threads();
        api_register_command(command_name, min_args, max_args, c_synopsis,
            description, c_arguments, c_examples, p_callback, python_command_callback);
        disable_python_threads();
    }

    return Py_BuildValue("");
}

static PyObject *
python_api_register_timed(PyObject *self, PyObject *args)
{
    PyObject *p_callback = NULL;
    int interval_seconds = 0;

    if (!PyArg_ParseTuple(args, "Oi", &p_callback, &interval_seconds)) {
        return Py_BuildValue("");
    }

    if (p_callback && PyCallable_Check(p_callback)) {
        allow_python_threads();
        api_register_timed(p_callback, interval_seconds, python_timed_callback);
        disable_python_threads();
    }

    return Py_BuildValue("");
}

static PyObject *
python_api_register_ac(PyObject *self, PyObject *args)
{
    const char *key = NULL;
    PyObject *items = NULL;

    if (!PyArg_ParseTuple(args, "sO", &key, &items)) {
        return Py_BuildValue("");
    }

    Py_ssize_t len = PyList_Size(items);
    char *c_items[len];

    Py_ssize_t i = 0;
    for (i = 0; i < len; i++) {
        PyObject *item = PyList_GetItem(items, i);
        char *c_item = PyString_AsString(item);
        c_items[i] = c_item;
    }
    c_items[len] = NULL;

    allow_python_threads();
    autocompleters_add(key, c_items);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_notify(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    const char *category = NULL;
    int timeout_ms = 5000;

    if (!PyArg_ParseTuple(args, "sis", &message, &timeout_ms, &category)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_notify(message, category, timeout_ms);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_send_line(PyObject *self, PyObject *args)
{
    char *line = NULL;
    if (!PyArg_ParseTuple(args, "s", &line)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_send_line(line);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_get_current_recipient(PyObject *self, PyObject *args)
{
    allow_python_threads();
    char *recipient = api_get_current_recipient();
    disable_python_threads();
    if (recipient) {
        return Py_BuildValue("s", recipient);
    } else {
        return Py_BuildValue("");
    }
}

static PyObject *
python_api_get_current_muc(PyObject *self, PyObject *args)
{
    allow_python_threads();
    char *room = api_get_current_muc();
    disable_python_threads();
    if (room) {
        return Py_BuildValue("s", room);
    } else {
        return Py_BuildValue("");
    }
}

static PyObject*
python_api_current_win_is_console(PyObject *self, PyObject *args)
{
    allow_python_threads();
    int res = api_current_win_is_console();
    disable_python_threads();
    if (res) {
        return Py_BuildValue("O", Py_True);
    } else {
        return Py_BuildValue("O", Py_False);
    }
}

static PyObject *
python_api_log_debug(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "s", &message)) {
        return Py_BuildValue("");
    }
    allow_python_threads();
    api_log_debug(message);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_log_info(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "s", &message)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_log_info(message);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_log_warning(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "s", &message)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_log_warning(message);
    disable_python_threads();
    return Py_BuildValue("");
}

static PyObject *
python_api_log_error(PyObject *self, PyObject *args)
{
    const char *message = NULL;
    if (!PyArg_ParseTuple(args, "s", &message)) {
        return Py_BuildValue("");
    }
    allow_python_threads();
    api_log_error(message);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_win_exists(PyObject *self, PyObject *args)
{
    char *tag = NULL;
    if (!PyArg_ParseTuple(args, "s", &tag)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    gboolean exists = api_win_exists(tag);
    disable_python_threads();

    if (exists) {
        return Py_BuildValue("O", Py_True);
    } else {
        return Py_BuildValue("O", Py_False);
    }
}

static PyObject *
python_api_win_create(PyObject *self, PyObject *args)
{
    char *tag = NULL;
    PyObject *p_callback = NULL;

    if (!PyArg_ParseTuple(args, "sO", &tag, &p_callback)) {
        return Py_BuildValue("");
    }

    if (p_callback && PyCallable_Check(p_callback)) {
        allow_python_threads();
        api_win_create(tag, p_callback, NULL, python_window_callback);
        disable_python_threads();
    }

    return Py_BuildValue("");
}

static PyObject *
python_api_win_focus(PyObject *self, PyObject *args)
{
    char *tag = NULL;

    if (!PyArg_ParseTuple(args, "s", &tag)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_win_focus(tag);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_win_show(PyObject *self, PyObject *args)
{
    char *tag = NULL;
    char *line = NULL;

    if (!PyArg_ParseTuple(args, "ss", &tag, &line)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_win_show(tag, line);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject *
python_api_win_show_themed(PyObject *self, PyObject *args)
{
    char *tag = NULL;
    char *group = NULL;
    char *key = NULL;
    char *def = NULL;
    char *line = NULL;

    if (!PyArg_ParseTuple(args, "szzzs", &tag, &group, &key, &def, &line)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_win_show_themed(tag, group, key, def, line);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_send_stanza(PyObject *self, PyObject *args)
{
    const char *stanza = NULL;
    if (!PyArg_ParseTuple(args, "s", &stanza)) {
        return Py_BuildValue("O", Py_False);
    }

    allow_python_threads();
    int res = api_send_stanza(stanza);
    disable_python_threads();
    if (res) {
        return Py_BuildValue("O", Py_True);
    } else {
        return Py_BuildValue("O", Py_False);
    }
}

static PyObject*
python_api_settings_get_boolean(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    PyObject *defobj = NULL;

    if (!PyArg_ParseTuple(args, "ssO!", &group, &key, &PyBool_Type, &defobj)) {
        return Py_BuildValue("");
    }

    int def = PyObject_IsTrue(defobj);

    allow_python_threads();
    int res = api_settings_get_boolean(group, key, def);
    disable_python_threads();

    if (res) {
        return Py_BuildValue("O", Py_True);
    } else {
        return Py_BuildValue("O", Py_False);
    }
}

static PyObject*
python_api_settings_set_boolean(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    PyObject *valobj = NULL;

    if (!PyArg_ParseTuple(args, "ssO!", &group, &key, &PyBool_Type, &valobj)) {
        return Py_BuildValue("");
    }

    int val = PyObject_IsTrue(valobj);

    allow_python_threads();
    api_settings_set_boolean(group, key, val);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_settings_get_string(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    char *def = NULL;

    if (!PyArg_ParseTuple(args, "ssz", &group, &key, &def)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    char *res = api_settings_get_string(group, key, def);
    disable_python_threads();

    if (res) {
        return Py_BuildValue("s", res);
    } else {
        return Py_BuildValue("");
    }
}

static PyObject*
python_api_settings_set_string(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    char *val = NULL;

    if (!PyArg_ParseTuple(args, "sss", &group, &key, &val)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_settings_set_string(group, key, val);
    disable_python_threads();

    return Py_BuildValue("");
}

static PyObject*
python_api_settings_get_int(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    int def = 0;

    if (!PyArg_ParseTuple(args, "ssi", &group, &key, &def)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    int res = api_settings_get_int(group, key, def);
    disable_python_threads();

    return Py_BuildValue("i", res);
}

static PyObject*
python_api_settings_set_int(PyObject *self, PyObject *args)
{
    char *group = NULL;
    char *key = NULL;
    int val = 0;

    if (!PyArg_ParseTuple(args, "ssi", &group, &key, &val)) {
        return Py_BuildValue("");
    }

    allow_python_threads();
    api_settings_set_int(group, key, val);
    disable_python_threads();

    return Py_BuildValue("");
}

void
python_command_callback(PluginCommand *command, gchar **args)
{
    disable_python_threads();
    PyObject *p_args = NULL;
    int num_args = g_strv_length(args);
    if (num_args == 0) {
        if (command->max_args == 1) {
            p_args = Py_BuildValue("(O)", Py_BuildValue(""));
            PyObject_CallObject(command->callback, p_args);
            Py_XDECREF(p_args);
        } else {
            PyObject_CallObject(command->callback, p_args);
        }
    } else if (num_args == 1) {
        p_args = Py_BuildValue("(s)", args[0]);
        PyObject_CallObject(command->callback, p_args);
        Py_XDECREF(p_args);
    } else if (num_args == 2) {
        p_args = Py_BuildValue("ss", args[0], args[1]);
        PyObject_CallObject(command->callback, p_args);
        Py_XDECREF(p_args);
    } else if (num_args == 3) {
        p_args = Py_BuildValue("sss", args[0], args[1], args[2]);
        PyObject_CallObject(command->callback, p_args);
        Py_XDECREF(p_args);
    } else if (num_args == 4) {
        p_args = Py_BuildValue("ssss", args[0], args[1], args[2], args[3]);
        PyObject_CallObject(command->callback, p_args);
        Py_XDECREF(p_args);
    } else if (num_args == 5) {
        p_args = Py_BuildValue("sssss", args[0], args[1], args[2], args[3], args[4]);
        PyObject_CallObject(command->callback, p_args);
        Py_XDECREF(p_args);
    }

    if (PyErr_Occurred()) {
        PyErr_Print();
        PyErr_Clear();
    }
    allow_python_threads();
}

void
python_timed_callback(PluginTimedFunction *timed_function)
{
    disable_python_threads();
    PyObject_CallObject(timed_function->callback, NULL);
    allow_python_threads();
}

void
python_window_callback(PluginWindowCallback *window_callback, char *tag, char *line)
{
    disable_python_threads();
    PyObject *p_args = NULL;
    p_args = Py_BuildValue("ss", tag, line);
    PyObject_CallObject(window_callback->callback, p_args);
    Py_XDECREF(p_args);

    if (PyErr_Occurred()) {
        PyErr_Print();
        PyErr_Clear();
    }
    allow_python_threads();
}

static PyMethodDef apiMethods[] = {
    { "cons_alert", python_api_cons_alert, METH_NOARGS, "Highlight the console window in the status bar." },
    { "cons_show", python_api_cons_show, METH_VARARGS, "Print a line to the console." },
    { "cons_show_themed", python_api_cons_show_themed, METH_VARARGS, "Print a themed line to the console" },
    { "cons_bad_cmd_usage", python_api_cons_bad_cmd_usage, METH_VARARGS, "Show invalid command message in console" },
    { "register_command", python_api_register_command, METH_VARARGS, "Register a command." },
    { "register_timed", python_api_register_timed, METH_VARARGS, "Register a timed function." },
    { "register_ac", python_api_register_ac, METH_VARARGS, "Register an autocompleter." },
    { "send_line", python_api_send_line, METH_VARARGS, "Send a line of input." },
    { "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
    { "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
    { "get_current_muc", python_api_get_current_muc, METH_VARARGS, "Return the jid of the room of the current window." },
    { "current_win_is_console", python_api_current_win_is_console, METH_VARARGS, "Returns whether the current window is the console." },
    { "log_debug", python_api_log_debug, METH_VARARGS, "Log a debug message" },
    { "log_info", python_api_log_info, METH_VARARGS, "Log an info message" },
    { "log_warning", python_api_log_warning, METH_VARARGS, "Log a warning message" },
    { "log_error", python_api_log_error, METH_VARARGS, "Log an error message" },
    { "win_exists", python_api_win_exists, METH_VARARGS, "Determine whether a window exists." },
    { "win_create", python_api_win_create, METH_VARARGS, "Create a new window." },
    { "win_focus", python_api_win_focus, METH_VARARGS, "Focus a window." },
    { "win_show", python_api_win_show, METH_VARARGS, "Show text in the window." },
    { "win_show_themed", python_api_win_show_themed, METH_VARARGS, "Show themed text in the window." },
    { "send_stanza", python_api_send_stanza, METH_VARARGS, "Send an XMPP stanza." },
    { "settings_get_boolean", python_api_settings_get_boolean, METH_VARARGS, "Get a boolean setting" },
    { "settings_set_boolean", python_api_settings_set_boolean, METH_VARARGS, "Set a boolean setting" },
    { "settings_get_string", python_api_settings_get_string, METH_VARARGS, "Get a string setting" },
    { "settings_set_string", python_api_settings_set_string, METH_VARARGS, "Set a string setting" },
    { "settings_get_int", python_api_settings_get_int, METH_VARARGS, "Get a integer setting" },
    { "settings_set_int", python_api_settings_set_int, METH_VARARGS, "Set a integer setting" },
    { NULL, NULL, 0, NULL }
};

void
python_api_init(void)
{
    Py_InitModule("prof", apiMethods);
}