1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Make functions using (int argc, char** argv) usable as (sys.argv) from python
7 %typemap(in) (int argc, char **argv) {
9 if (!PyList_Check($input)) {
10 PyErr_SetString(PyExc_ValueError, "Expecting a list");
13 $1 = PyList_Size($input);
14 $2 = (char **) malloc(($1+1)*sizeof(char *));
15 for (i = 0; i < $1; i++) {
16 PyObject *s = PyList_GetItem($input,i);
17 if (!PyString_Check(s)) {
19 PyErr_SetString(PyExc_ValueError, "List items must be strings");
22 $2[i] = PyString_AsString(s);
27 %typemap(freearg) (int argc, char **argv) {