コード例 #1
0
ファイル: _OSAmodule.c プロジェクト: RDWang/python
                          AEDesc_Convert, &contextName,
                          &parentContext))
        return NULL;
    _err = OSAMakeContext(_self->ob_itself,
                          &contextName,
                          parentContext,
                          &resultingContextID);
    if (_err != noErr) return PyMac_Error(_err);
    _res = Py_BuildValue("l",
                         resultingContextID);
    return _res;
}

static PyMethodDef OSAObj_methods[] = {
    {"OSALoad", (PyCFunction)OSAObj_OSALoad, 1,
     PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")},
    {"OSAStore", (PyCFunction)OSAObj_OSAStore, 1,
     PyDoc_STR("(OSAID scriptID, DescType desiredType, long modeFlags) -> (AEDesc resultingScriptData)")},
    {"OSAExecute", (PyCFunction)OSAObj_OSAExecute, 1,
     PyDoc_STR("(OSAID compiledScriptID, OSAID contextID, long modeFlags) -> (OSAID resultingScriptValueID)")},
    {"OSADisplay", (PyCFunction)OSAObj_OSADisplay, 1,
     PyDoc_STR("(OSAID scriptValueID, DescType desiredType, long modeFlags) -> (AEDesc resultingText)")},
    {"OSAScriptError", (PyCFunction)OSAObj_OSAScriptError, 1,
     PyDoc_STR("(OSType selector, DescType desiredType) -> (AEDesc resultingErrorDescription)")},
    {"OSADispose", (PyCFunction)OSAObj_OSADispose, 1,
     PyDoc_STR("(OSAID scriptID) -> None")},
    {"OSASetScriptInfo", (PyCFunction)OSAObj_OSASetScriptInfo, 1,
     PyDoc_STR("(OSAID scriptID, OSType selector, long value) -> None")},
    {"OSAGetScriptInfo", (PyCFunction)OSAObj_OSAGetScriptInfo, 1,
     PyDoc_STR("(OSAID scriptID, OSType selector) -> (long result)")},
    {"OSAScriptingComponentName", (PyCFunction)OSAObj_OSAScriptingComponentName, 1,
コード例 #2
0
ファイル: _Foldermodule.c プロジェクト: 1310701102/sl4a
	if (!PyArg_ParseTuple(_args, "hl",
	                      &vRefNum,
	                      &dirID))
		return NULL;
	_err = IdentifyFolder(vRefNum,
	                      dirID,
	                      &foldType);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     PyMac_BuildOSType, foldType);
	return _res;
}

static PyMethodDef Folder_methods[] = {
	{"FindFolder", (PyCFunction)Folder_FindFolder, 1,
	 PyDoc_STR("(short vRefNum, OSType folderType, Boolean createFolder) -> (short foundVRefNum, long foundDirID)")},
	{"ReleaseFolder", (PyCFunction)Folder_ReleaseFolder, 1,
	 PyDoc_STR("(short vRefNum, OSType folderType) -> None")},
	{"FSFindFolder", (PyCFunction)Folder_FSFindFolder, 1,
	 PyDoc_STR("(short vRefNum, OSType folderType, Boolean createFolder) -> (FSRef foundRef)")},
	{"AddFolderDescriptor", (PyCFunction)Folder_AddFolderDescriptor, 1,
	 PyDoc_STR("(FolderType foldType, FolderDescFlags flags, FolderClass foldClass, FolderLocation foldLocation, OSType badgeSignature, OSType badgeType, Str255 name, Boolean replaceFlag) -> None")},
	{"GetFolderTypes", (PyCFunction)Folder_GetFolderTypes, 1,
	 PyDoc_STR("(UInt32 requestedTypeCount) -> (UInt32 totalTypeCount, FolderType theTypes)")},
	{"RemoveFolderDescriptor", (PyCFunction)Folder_RemoveFolderDescriptor, 1,
	 PyDoc_STR("(FolderType foldType) -> None")},
#ifndef __LP64__
	{"GetFolderName", (PyCFunction)Folder_GetFolderName, 1,
	 PyDoc_STR("(short vRefNum, OSType foldType, Str255 name) -> (short foundVRefNum)")},
	{"AddFolderRouting", (PyCFunction)Folder_AddFolderRouting, 1,
	 PyDoc_STR("(OSType fileType, FolderType routeFromFolder, FolderType routeToFolder, RoutingFlags flags, Boolean replaceFlag) -> None")},
コード例 #3
0
ファイル: _Evtmodule.c プロジェクト: 0xcc/python-read
                          OptResObj_Convert, &mouseregion))
        return NULL;
    _rv = WaitNextEvent(eventMask,
                        &theEvent,
                        sleep,
                        (RgnHandle)mouseregion);
    _res = Py_BuildValue("bO&",
                         _rv,
                         PyMac_BuildEventRecord, &theEvent);
    return _res;

}

static PyMethodDef Evt_methods[] = {
    {"GetMouse", (PyCFunction)Evt_GetMouse, 1,
     PyDoc_STR("() -> (Point mouseLoc)")},
    {"Button", (PyCFunction)Evt_Button, 1,
     PyDoc_STR("() -> (Boolean _rv)")},
    {"StillDown", (PyCFunction)Evt_StillDown, 1,
     PyDoc_STR("() -> (Boolean _rv)")},
    {"WaitMouseUp", (PyCFunction)Evt_WaitMouseUp, 1,
     PyDoc_STR("() -> (Boolean _rv)")},
    {"GetCaretTime", (PyCFunction)Evt_GetCaretTime, 1,
     PyDoc_STR("() -> (UInt32 _rv)")},
    {"GetKeys", (PyCFunction)Evt_GetKeys, 1,
     PyDoc_STR("() -> (KeyMap theKeys)")},
    {"GetDblTime", (PyCFunction)Evt_GetDblTime, 1,
     PyDoc_STR("() -> (UInt32 _rv)")},
    {"SetEventMask", (PyCFunction)Evt_SetEventMask, 1,
     PyDoc_STR("(EventMask value) -> None")},
    {"GetNextEvent", (PyCFunction)Evt_GetNextEvent, 1,
コード例 #4
0
ファイル: symbolset.c プロジェクト: 13122310958/ZBar
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser Public License
 *  along with the ZBar Bar Code Reader; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 *  Boston, MA  02110-1301  USA
 *
 *  http://sourceforge.net/projects/zbar
 *------------------------------------------------------------------------*/

#include "zbarmodule.h"

static char symbolset_doc[] = PyDoc_STR(
    "symbol result container.\n"
    "\n"
    "collection of symbols.");

static int
symbolset_clear (zbarSymbolSet *self)
{
    if(self->zsyms) {
        zbar_symbol_set_t *zsyms = (zbar_symbol_set_t*)self->zsyms;
        self->zsyms = NULL;
        zbar_symbol_set_ref(zsyms, -1);
    }
    return(0);
}

static void
symbolset_dealloc (zbarSymbolSet *self)
コード例 #5
0
    Py_INCREF(Py_None);
    return Py_None;
}

void converters_init(PyObject* dict)
{
    converters = PyDict_New();
    if (!converters) {
        return;
    }

    PyDict_SetItemString(dict, "converters", converters);
}

static PyMethodDef module_methods[] = {
    {"connect",  (PyCFunction)module_connect,  METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Creates a connection.")},
    {"complete_statement",  (PyCFunction)module_complete,  METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Checks if a string contains a complete SQL statement. Non-standard.")},
#ifdef HAVE_SHARED_CACHE
    {"enable_shared_cache",  (PyCFunction)module_enable_shared_cache,  METH_VARARGS|METH_KEYWORDS, PyDoc_STR("Enable or disable shared cache mode for the calling thread. Experimental/Non-standard.")},
#endif
    {"register_adapter", (PyCFunction)module_register_adapter, METH_VARARGS, PyDoc_STR("Registers an adapter with pysqlite's adapter registry. Non-standard.")},
    {"register_converter", (PyCFunction)module_register_converter, METH_VARARGS, PyDoc_STR("Registers a converter with pysqlite. Non-standard.")},
    {"adapt",  (PyCFunction)psyco_microprotocols_adapt, METH_VARARGS, psyco_microprotocols_adapt_doc},
    {"enable_callback_tracebacks",  (PyCFunction)enable_callback_tracebacks, METH_VARARGS, PyDoc_STR("Enable or disable callback functions throwing errors to stderr.")},
    {NULL, NULL}
};

struct _IntConstantPair {
    char* constant_name;
    int constant_value;
};
コード例 #6
0
ファイル: Generator.c プロジェクト: Aeternam/server_status
static int
__Pyx_Generator_set_qualname(__pyx_GeneratorObject *self, PyObject *value)
{
    PyObject *tmp;

#if PY_MAJOR_VERSION >= 3
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
#else
    if (unlikely(value == NULL || !PyString_Check(value))) {
#endif
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = self->gi_qualname;
    Py_INCREF(value);
    self->gi_qualname = value;
    Py_XDECREF(tmp);
    return 0;
}

static PyGetSetDef __pyx_Generator_getsets[] = {
    {(char *) "__name__", (getter)__Pyx_Generator_get_name, (setter)__Pyx_Generator_set_name,
     (char*) PyDoc_STR("name of the generator"), 0},
    {(char *) "__qualname__", (getter)__Pyx_Generator_get_qualname, (setter)__Pyx_Generator_set_qualname,
     (char*) PyDoc_STR("qualified name of the generator"), 0},
    {0, 0, 0, 0, 0}
};

static PyMemberDef __pyx_Generator_memberlist[] = {
    {(char *) "gi_running", T_BOOL, offsetof(__pyx_GeneratorObject, is_running), READONLY, NULL},
    {0, 0, 0, 0, 0}
};

static PyMethodDef __pyx_Generator_methods[] = {
    {"send", (PyCFunction) __Pyx_Generator_Send, METH_O, 0},
    {"throw", (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0},
    {"close", (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
    {0, 0, 0, 0}
};

static PyTypeObject __pyx_GeneratorType_type = {
    PyVarObject_HEAD_INIT(0, 0)
    "generator",                        /*tp_name*/
    sizeof(__pyx_GeneratorObject),      /*tp_basicsize*/
    0,                                  /*tp_itemsize*/
    (destructor) __Pyx_Generator_dealloc,/*tp_dealloc*/
    0,                                  /*tp_print*/
    0,                                  /*tp_getattr*/
    0,                                  /*tp_setattr*/
#if PY_MAJOR_VERSION < 3
    0,                                  /*tp_compare*/
#else
    0,                                  /*reserved*/
#endif
    0,                                  /*tp_repr*/
    0,                                  /*tp_as_number*/
    0,                                  /*tp_as_sequence*/
    0,                                  /*tp_as_mapping*/
    0,                                  /*tp_hash*/
    0,                                  /*tp_call*/
    0,                                  /*tp_str*/
    0,                                  /*tp_getattro*/
    0,                                  /*tp_setattro*/
    0,                                  /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE, /*tp_flags*/
    0,                                  /*tp_doc*/
    (traverseproc) __Pyx_Generator_traverse,   /*tp_traverse*/
    0,                                  /*tp_clear*/
    0,                                  /*tp_richcompare*/
    offsetof(__pyx_GeneratorObject, gi_weakreflist), /*tp_weaklistoffset*/
    0,                                  /*tp_iter*/
    (iternextfunc) __Pyx_Generator_Next, /*tp_iternext*/
    __pyx_Generator_methods,            /*tp_methods*/
    __pyx_Generator_memberlist,         /*tp_members*/
    __pyx_Generator_getsets,            /*tp_getset*/
    0,                                  /*tp_base*/
    0,                                  /*tp_dict*/
    0,                                  /*tp_descr_get*/
    0,                                  /*tp_descr_set*/
    0,                                  /*tp_dictoffset*/
    0,                                  /*tp_init*/
    0,                                  /*tp_alloc*/
    0,                                  /*tp_new*/
    0,                                  /*tp_free*/
    0,                                  /*tp_is_gc*/
    0,                                  /*tp_bases*/
    0,                                  /*tp_mro*/
    0,                                  /*tp_cache*/
    0,                                  /*tp_subclasses*/
    0,                                  /*tp_weaklist*/
#if PY_VERSION_HEX >= 0x030400a1
    0,                                  /*tp_del*/
#else
    __Pyx_Generator_del,                /*tp_del*/
#endif
    0,                                  /*tp_version_tag*/
#if PY_VERSION_HEX >= 0x030400a1
    __Pyx_Generator_del,                /*tp_finalize*/
#endif
};

static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
                                                  PyObject *closure, PyObject *name, PyObject *qualname) {
    __pyx_GeneratorObject *gen =
        PyObject_GC_New(__pyx_GeneratorObject, &__pyx_GeneratorType_type);

    if (gen == NULL)
        return NULL;

    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->exc_type = NULL;
    gen->exc_value = NULL;
    gen->exc_traceback = NULL;
    gen->gi_weakreflist = NULL;
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;

    PyObject_GC_Track(gen);
    return gen;
}
コード例 #7
0
ファイル: module.c プロジェクト: rlutz/geda-gaf
		    args, kwds, "O!:eval_string", kwlist,
		    &PyString_Type, &string_arg))
		return NULL;

	PyObject *result = scm_with_guile(
		(void *(*)(void *))eval_string_wrapper, string_arg);
	if (result == NULL && !PyErr_Occurred())
		PyErr_SetNone(guile_error);
	return result;
}

static PyMethodDef methods[] = {
	{ "lookup",
	  (PyCFunction)lookup, METH_KEYWORDS,
	  PyDoc_STR("lookup(name)\n\n"
		    "Return the variable bound to the symbol indicated by "
		    "name.  If there\nis no such binding or the symbol is not "
		    "bound to a variable, signal\nan error.") },
	{ "define",
	  (PyCFunction)define, METH_KEYWORDS,
	  PyDoc_STR("define(name, value)\n\n"
		    "Create a top level variable.  If the named variable "
		    "already exists,\njust change its value.") },
	{ "load",
	  (PyCFunction)load, METH_KEYWORDS,
	  PyDoc_STR("load(name)\n\n"
		    "Load a file and evaluate its contents "
		    "in the top-level environment.") },
	{ "eval_string",
	  (PyCFunction)eval_string, METH_KEYWORDS,
	  PyDoc_STR("eval_string(string)\n\n"
		    "Parse string as Scheme, and evaluate the expressions it "
コード例 #8
0
        else {
            const char *name = PyModule_GetName(self);
            if (name)
                PyErr_Format(PyExc_TypeError,
                             "%.200s.__dict__ is not a dictionary",
                             name);
        }
    }

    Py_XDECREF(dict);
    return result;
}

static PyMethodDef module_methods[] = {
    {"__dir__", module_dir, METH_NOARGS,
     PyDoc_STR("__dir__() -> list\nspecialized dir() implementation")},
    {0}
};


PyDoc_STRVAR(module_doc,
"module(name[, doc])\n\
\n\
Create a module object.\n\
The name must be a string; the optional doc argument can have any type.");

PyTypeObject PyModule_Type = {
    PyVarObject_HEAD_INIT(&PyType_Type, 0)
    "module",                                   /* tp_name */
    sizeof(PyModuleObject),                     /* tp_size */
    0,                                          /* tp_itemsize */
コード例 #9
0
ファイル: data_fillattr.c プロジェクト: rlutz/geda-gaf
	self->data.angle0 = angle0_arg;
	self->data.pitch0 = pitch0_arg;
	self->data.angle1 = angle1_arg;
	self->data.pitch1 = pitch1_arg;

	return 0;
}

static void FillAttr_dealloc(FillAttr *self)
{
	self->ob_type->tp_free((PyObject *)self);
}

static PyMemberDef FillAttr_members[] = {
	{ "type", T_INT, offsetof(FillAttr, data.type), 0,
	  PyDoc_STR("") },
	{ "width", T_DOUBLE, offsetof(FillAttr, data.width), 0,
	  PyDoc_STR("") },
	{ "angle0", T_INT, offsetof(FillAttr, data.angle0), 0,
	  PyDoc_STR("") },
	{ "pitch0", T_DOUBLE, offsetof(FillAttr, data.pitch0), 0,
	  PyDoc_STR("") },
	{ "angle1", T_INT, offsetof(FillAttr, data.angle1), 0,
	  PyDoc_STR("") },
	{ "pitch1", T_DOUBLE, offsetof(FillAttr, data.pitch1), 0,
	  PyDoc_STR("") },
	{ NULL }  /* Sentinel */
};

PyTypeObject FillAttrType = {
	PyObject_HEAD_INIT(NULL)
コード例 #10
0
ファイル: _tnetstring.c プロジェクト: pombredanne/tnetstring
error:
  if(ops != &_tnetstring_ops_bytes) {
      free(ops);
      Py_DECREF(encoding);
  }
  Py_DECREF(object);
  return NULL;
}


static PyMethodDef _tnetstring_methods[] = {
    {"load",
     (PyCFunction)_tnetstring_load,
     METH_VARARGS,
     PyDoc_STR("load(file,encoding=None) -> object\n"
               "This function reads a tnetstring from a file and parses it\n"
               "into a python object.")},

    {"loads",
     (PyCFunction)_tnetstring_loads,
     METH_VARARGS,
     PyDoc_STR("loads(string,encoding=None) -> object\n"
               "This function parses a tnetstring into a python object.")},

    {"pop",
     (PyCFunction)_tnetstring_pop,
     METH_VARARGS,
     PyDoc_STR("pop(string,encoding=None) -> (object, remain)\n"
               "This function parses a tnetstring into a python object.\n"
               "It returns a tuple giving the parsed object and a string\n"
               "containing any unparsed data.")},
コード例 #11
0
ファイル: lru.c プロジェクト: pombredanne/lru-dict
static PyObject *
LRU_get_size(LRU *self)
{
    return Py_BuildValue("i", self->size);
}

static PyObject *
LRU_get_stats(LRU *self)
{
    return Py_BuildValue("nn", self->hits, self->misses);
}

static PyMethodDef LRU_methods[] = {
    {"keys", (PyCFunction)LRU_keys, METH_NOARGS,
                    PyDoc_STR("L.keys() -> list of L's keys in MRU order")},
    {"values", (PyCFunction)LRU_values, METH_NOARGS,
                    PyDoc_STR("L.values() -> list of L's values in MRU order")},
    {"items", (PyCFunction)LRU_items, METH_NOARGS,
                    PyDoc_STR("L.items() -> list of L's items (key,value) in MRU order")},
    {"has_key",	(PyCFunction)LRU_contains, METH_VARARGS,
                    PyDoc_STR("L.has_key(key) -> Check if key is there in L")},
    {"get",	(PyCFunction)LRU_get, METH_VARARGS,
                    PyDoc_STR("L.get(key, instead) -> If L has key return its value, otherwise instead")},
    {"set_size", (PyCFunction)LRU_set_size, METH_VARARGS,
                    PyDoc_STR("L.set_size() -> set size of LRU")},
    {"get_size", (PyCFunction)LRU_get_size, METH_NOARGS,
                    PyDoc_STR("L.get_size() -> get size of LRU")},
    {"clear", (PyCFunction)LRU_clear, METH_NOARGS,
                    PyDoc_STR("L.clear() -> clear LRU")},
    {"get_stats", (PyCFunction)LRU_get_stats, METH_NOARGS,
コード例 #12
0
ファイル: genobject.c プロジェクト: Alex9029/cpython
     * other than a string object. */
    if (value == NULL || !PyUnicode_Check(value)) {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    tmp = op->gi_qualname;
    Py_INCREF(value);
    op->gi_qualname = value;
    Py_DECREF(tmp);
    return 0;
}

static PyGetSetDef gen_getsetlist[] = {
    {"__name__", (getter)gen_get_name, (setter)gen_set_name,
     PyDoc_STR("name of the generator")},
    {"__qualname__", (getter)gen_get_qualname, (setter)gen_set_qualname,
     PyDoc_STR("qualified name of the generator")},
    {NULL} /* Sentinel */
};

static PyMemberDef gen_memberlist[] = {
    {"gi_frame",     T_OBJECT, offsetof(PyGenObject, gi_frame),    READONLY},
    {"gi_running",   T_BOOL,   offsetof(PyGenObject, gi_running),  READONLY},
    {"gi_code",      T_OBJECT, offsetof(PyGenObject, gi_code),     READONLY},
    {NULL}      /* Sentinel */
};

static PyMethodDef gen_methods[] = {
    {"send",(PyCFunction)_PyGen_Send, METH_O, send_doc},
    {"throw",(PyCFunction)gen_throw, METH_VARARGS, throw_doc},
コード例 #13
0
ファイル: _Cmmodule.c プロジェクト: JupiterSmalltalk/openqwaq
#ifndef ComponentSetTarget
	PyMac_PRECHECK(ComponentSetTarget);
#endif
	if (!PyArg_ParseTuple(_args, "O&",
	                      CmpInstObj_Convert, &target))
		return NULL;
	_rv = ComponentSetTarget(_self->ob_itself,
	                         target);
	_res = Py_BuildValue("l",
	                     _rv);
	return _res;
}

static PyMethodDef CmpInstObj_methods[] = {
	{"CloseComponent", (PyCFunction)CmpInstObj_CloseComponent, 1,
	 PyDoc_STR("() -> None")},
	{"GetComponentInstanceError", (PyCFunction)CmpInstObj_GetComponentInstanceError, 1,
	 PyDoc_STR("() -> None")},
	{"SetComponentInstanceError", (PyCFunction)CmpInstObj_SetComponentInstanceError, 1,
	 PyDoc_STR("(OSErr theError) -> None")},
	{"GetComponentInstanceStorage", (PyCFunction)CmpInstObj_GetComponentInstanceStorage, 1,
	 PyDoc_STR("() -> (Handle _rv)")},
	{"SetComponentInstanceStorage", (PyCFunction)CmpInstObj_SetComponentInstanceStorage, 1,
	 PyDoc_STR("(Handle theStorage) -> None")},
	{"ComponentFunctionImplemented", (PyCFunction)CmpInstObj_ComponentFunctionImplemented, 1,
	 PyDoc_STR("(short ftnNumber) -> (long _rv)")},
	{"GetComponentVersion", (PyCFunction)CmpInstObj_GetComponentVersion, 1,
	 PyDoc_STR("() -> (long _rv)")},
	{"ComponentSetTarget", (PyCFunction)CmpInstObj_ComponentSetTarget, 1,
	 PyDoc_STR("(ComponentInstance target) -> (long _rv)")},
	{NULL, NULL, 0}
コード例 #14
0
ファイル: codec.c プロジェクト: acg/python-percentcoding
  if (!(result = PyString_FromStringAndSize(NULL,size)))
    return NULL;

  /* Second pass: actually decode this time. */

  out = PyString_AsString(result);
  size = percent_decode(in, inlen, out);

  return result;
}


static PyMethodDef Codec_methods[] = {
  {"encode",  (PyCFunction)Codec_encode,  METH_VARARGS,
    PyDoc_STR("encode(str) -> str")},
  {"decode",  (PyCFunction)Codec_decode,  METH_VARARGS,
    PyDoc_STR("decode(str) -> str")},
  {NULL,    NULL}    /* sentinel */
};


PyTypeObject CodecType = {
  /* The ob_type field must be initialized in the module init function
   * to be portable to Windows without using C++. */
  PyObject_HEAD_INIT(NULL)
  0,                            /*ob_size*/
  "percentcoding.cext.Codec",   /*tp_name*/
  sizeof(Codec),                /*tp_basicsize*/
  0,                            /*tp_itemsize*/
  /* methods */
コード例 #15
0
ファイル: row.c プロジェクト: 321543223/kbengine
            Py_DECREF(res);
            return PyObject_RichCompare(self->data, other->data, opid);
        }
    }
    Py_RETURN_NOTIMPLEMENTED;
}

PyMappingMethods pysqlite_row_as_mapping = {
    /* mp_length        */ (lenfunc)pysqlite_row_length,
    /* mp_subscript     */ (binaryfunc)pysqlite_row_subscript,
    /* mp_ass_subscript */ (objobjargproc)0,
};

static PyMethodDef pysqlite_row_methods[] = {
    {"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS,
        PyDoc_STR("Returns the keys of the row.")},
    {NULL, NULL}
};


PyTypeObject pysqlite_RowType = {
        PyVarObject_HEAD_INIT(NULL, 0)
        MODULE_NAME ".Row",                             /* tp_name */
        sizeof(pysqlite_Row),                           /* tp_basicsize */
        0,                                              /* tp_itemsize */
        (destructor)pysqlite_row_dealloc,               /* tp_dealloc */
        (printfunc)pysqlite_row_print,                  /* tp_print */
        0,                                              /* tp_getattr */
        0,                                              /* tp_setattr */
        0,                                              /* tp_reserved */
        0,                                              /* tp_repr */
コード例 #16
0
ファイル: decoder.c プロジェクト: AleksandrRasskazov/zbar
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser Public License
 *  along with the ZBar Bar Code Reader; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 *  Boston, MA  02110-1301  USA
 *
 *  http://sourceforge.net/projects/zbar
 *------------------------------------------------------------------------*/

#include "zbarmodule.h"

static char decoder_doc[] = PyDoc_STR(
    "low level decode of measured bar/space widths.\n"
    "\n"
    "FIXME.");

static zbarDecoder*
decoder_new (PyTypeObject *type,
             PyObject *args,
             PyObject *kwds)
{
    static char *kwlist[] = { NULL };
    if(!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist))
        return(NULL);

    zbarDecoder *self = (zbarDecoder*)type->tp_alloc(type, 0);
    if(!self)
        return(NULL);
コード例 #17
0
ファイル: tupledesc.c プロジェクト: fdr/pg-python
static PyObj
tupd_get_column_types(PyObj self, void *unused)
{
	return(PyPgTupleDesc_GetTypes(self));
}

static PyObj
tupd_get_pg_column_types(PyObj self, void *unused)
{
	return(PyPgTupleDesc_GetTypeOids(self));
}

static PyGetSetDef PyPgTupleDesc_GetSet[] = {
	{"column_types", tupd_get_column_types, NULL,
		PyDoc_STR("the descriptor's attribute types that have not been dropped")},
	{"pg_column_types", tupd_get_pg_column_types, NULL,
		PyDoc_STR("the descriptor's attribute type Oids that have not been dropped")},
	{NULL}
};

static PyMemberDef PyPgTupleDesc_Members[] = {
	{"column_names", T_OBJECT, offsetof(struct PyPgTupleDesc, td_names), READONLY,
		PyDoc_STR("the descriptor's attribute names that have not been dropped")},
	{"column_count", T_INT, offsetof(struct PyPgTupleDesc, td_natts), READONLY,
		PyDoc_STR("the count of the descriptor's attributes that have not been dropped ")},
	{NULL}
};

static Py_ssize_t
tupd_length(PyObj self)
コード例 #18
0
        }
        cur = Py_BuildValue("HKK", LCB_MUTATION_TOKEN_VB(mt),
            LCB_MUTATION_TOKEN_ID(mt), LCB_MUTATION_TOKEN_SEQ(mt));
        PyList_Append(ll, cur);
        Py_DECREF(cur);
    }

    return ll;
}


static PyGetSetDef Bucket_TABLE_getset[] = {
        { "default_format",
                (getter)Bucket_get_format,
                (setter)Bucket_set_format,
                PyDoc_STR("The default format to use for encoding values "
                "(passed to transcoder)")
        },
        { "server_nodes",
                (getter)Bucket_server_nodes,
                NULL,
                PyDoc_STR("Get a list of the current nodes in the cluster")
        },
        { "configured_replica_count",
                (getter)Bucket_get_configured_replica_count,
                NULL,
                PyDoc_STR("Get the number of configured replicas for the bucket")
        },

        { "transcoder",
                (getter)Bucket_get_transcoder,
                (setter)Bucket_set_transcoder,
コード例 #19
0
ファイル: xxmodule.c プロジェクト: AbnerChang/edk2-staging
    Py_XDECREF(self->x_attr);
    PyObject_Del(self);
}

static PyObject *
Xxo_demo(XxoObject *self, PyObject *args)
{
    if (!PyArg_ParseTuple(args, ":demo"))
        return NULL;
    Py_INCREF(Py_None);
    return Py_None;
}

static PyMethodDef Xxo_methods[] = {
    {"demo",            (PyCFunction)Xxo_demo,  METH_VARARGS,
        PyDoc_STR("demo() -> None")},
    {NULL,              NULL}           /* sentinel */
};

static PyObject *
Xxo_getattr(XxoObject *self, char *name)
{
    if (self->x_attr != NULL) {
        PyObject *v = PyDict_GetItemString(self->x_attr, name);
        if (v != NULL) {
            Py_INCREF(v);
            return v;
        }
    }
    return Py_FindMethod(Xxo_methods, (PyObject *)self, name);
}
コード例 #20
0
ファイル: genobject.c プロジェクト: DinoV/gilectomy
    Py_XSETREF(op->gi_qualname, value);
    return 0;
}

static PyObject *
gen_getyieldfrom(PyGenObject *gen)
{
    PyObject *yf = _PyGen_yf(gen);
    if (yf == NULL)
        Py_RETURN_NONE;
    return yf;
}

static PyGetSetDef gen_getsetlist[] = {
    {"__name__", (getter)gen_get_name, (setter)gen_set_name,
     PyDoc_STR("name of the generator")},
    {"__qualname__", (getter)gen_get_qualname, (setter)gen_set_qualname,
     PyDoc_STR("qualified name of the generator")},
    {"gi_yieldfrom", (getter)gen_getyieldfrom, NULL,
     PyDoc_STR("object being iterated by yield from, or None")},
    {NULL} /* Sentinel */
};

static PyMemberDef gen_memberlist[] = {
    {"gi_frame",     T_OBJECT, offsetof(PyGenObject, gi_frame),    READONLY},
    {"gi_running",   T_BOOL,   offsetof(PyGenObject, gi_running),  READONLY},
    {"gi_code",      T_OBJECT, offsetof(PyGenObject, gi_code),     READONLY},
    {NULL}      /* Sentinel */
};

static PyMethodDef gen_methods[] = {
コード例 #21
0
ファイル: _TEmodule.c プロジェクト: 0xcc/python-read
    PyObject *_res = NULL;
    Handle _rv;
#ifndef as_Resource
    PyMac_PRECHECK(as_Resource);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = as_Resource(_self->ob_itself);
    _res = Py_BuildValue("O&",
                         ResObj_New, _rv);
    return _res;
}

static PyMethodDef TEObj_methods[] = {
    {"TESetText", (PyCFunction)TEObj_TESetText, 1,
     PyDoc_STR("(Buffer text) -> None")},
    {"TEGetText", (PyCFunction)TEObj_TEGetText, 1,
     PyDoc_STR("() -> (CharsHandle _rv)")},
    {"TEIdle", (PyCFunction)TEObj_TEIdle, 1,
     PyDoc_STR("() -> None")},
    {"TESetSelect", (PyCFunction)TEObj_TESetSelect, 1,
     PyDoc_STR("(long selStart, long selEnd) -> None")},
    {"TEActivate", (PyCFunction)TEObj_TEActivate, 1,
     PyDoc_STR("() -> None")},
    {"TEDeactivate", (PyCFunction)TEObj_TEDeactivate, 1,
     PyDoc_STR("() -> None")},
    {"TEKey", (PyCFunction)TEObj_TEKey, 1,
     PyDoc_STR("(CharParameter key) -> None")},
    {"TECut", (PyCFunction)TEObj_TECut, 1,
     PyDoc_STR("() -> None")},
    {"TECopy", (PyCFunction)TEObj_TECopy, 1,
コード例 #22
0
ファイル: tesserpy.cpp プロジェクト: gpjt/tesserpy
// BoundingBox
typedef struct {
	PyObject_HEAD
	int left;
	int right;
	int top;
	int bottom;
} PyBoundingBox;

extern "C" {
	static int PyBoundingBox_init(PyBoundingBox *self, PyObject *args, PyObject *kwargs);
	static PyObject* PyBoundingBox_offset(PyBoundingBox *self, PyObject *args);
}

static PyMemberDef PyBoundingBox_members[] = {
	{ "left", T_INT, offsetof(PyBoundingBox, left), 0, PyDoc_STR("Left edge of the bounding box") },
	{ "right", T_INT, offsetof(PyBoundingBox, right), 0, PyDoc_STR("Right edge of the bounding box") },
	{ "top", T_INT, offsetof(PyBoundingBox, top), 0, PyDoc_STR("Top edge of the bounding box") },
	{ "bottom", T_INT, offsetof(PyBoundingBox, bottom), 0, PyDoc_STR("Bottom edge of the bounding box") },
	{ NULL }, // sentinel
};

static PyMethodDef PyBoundingBox_methods[] = {
	{ "offset", (PyCFunction)PyBoundingBox_offset, METH_VARARGS, PyDoc_STR("offset(left_offset, top_offset)\n\nAdds a fixed offset to the coordinates in the bounding box") },
	{ NULL, NULL } // sentinel
};

static PyTypeObject PyBoundingBox_Type = {
	PyVarObject_HEAD_INIT(NULL, 0)
	"tesserpy.BoundingBox", // tp_name
	sizeof(PyBoundingBox), // tp_basicsize
コード例 #23
0
ファイル: array.c プロジェクト: python-postgres/be
	PyPgTypeInfo typinfo = PyPgTypeInfo(Py_TYPE(self));

	rob = typinfo->array.x_yes.typelem_Type;

	/*
	 * The array type shouldn't exist without having an element type.
	 */
	Assert(rob != NULL);
	Py_INCREF(rob);

	return(rob);
}

static PyGetSetDef array_getset[] = {
	{"Element", array_get_Element_type, NULL,
	PyDoc_STR("The array's element type")},
	{"dimensions", array_get_dimensions, NULL,
	PyDoc_STR("The array's dimensions")},
	{"has_null", array_has_null, NULL,
	PyDoc_STR("Whether the array has a NULL inside of it")},
	{"lowerbounds", array_get_lowerbounds, NULL,
	PyDoc_STR("The array's lower bounds")},
	{"ndim", array_get_ndim, NULL,
	PyDoc_STR("The number of array dimensions")},
	{"nelements", array_get_nelements, NULL,
	PyDoc_STR("The number of elements in the array")},
	{NULL}
};

/*
 * Array.get_element(indexes) - Get an element from the array.
コード例 #24
0
ファイル: _msi.c プロジェクト: Victor-Savu/cpython
    int data;

    if (!PyArg_ParseTuple(args, "ii:SetInteger", &field, &data))
        return NULL;

    if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS)
        return msierror(status);

    Py_RETURN_NONE;
}



static PyMethodDef record_methods[] = {
    { "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS,
        PyDoc_STR("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount")},
    { "GetInteger", (PyCFunction)record_getinteger, METH_VARARGS,
    PyDoc_STR("GetInteger(field) -> int\nWraps MsiRecordGetInteger")},
    { "GetString", (PyCFunction)record_getstring, METH_VARARGS,
    PyDoc_STR("GetString(field) -> string\nWraps MsiRecordGetString")},
    { "SetString", (PyCFunction)record_setstring, METH_VARARGS,
        PyDoc_STR("SetString(field,str) -> None\nWraps MsiRecordSetString")},
    { "SetStream", (PyCFunction)record_setstream, METH_VARARGS,
        PyDoc_STR("SetStream(field,filename) -> None\nWraps MsiRecordSetInteger")},
    { "SetInteger", (PyCFunction)record_setinteger, METH_VARARGS,
        PyDoc_STR("SetInteger(field,int) -> None\nWraps MsiRecordSetInteger")},
    { "ClearData", (PyCFunction)record_cleardata, METH_NOARGS,
        PyDoc_STR("ClearData() -> int\nWraps MsiRecordGClearData")},
    { NULL, NULL }
};
コード例 #25
0
ファイル: ae.c プロジェクト: AdminCNP/appscript
	Py_BEGIN_ALLOW_THREADS
	_err = AE_SendMessageThreadSafe(&_self->ob_itself,
									&reply,
									sendMode,
									timeOutInTicks);
	Py_END_ALLOW_THREADS
	if (_err != noErr) return AE_MacOSError(_err);
	_res = Py_BuildValue("O&",
						 AE_AEDesc_New, &reply);
	return _res;
}

static PyMethodDef AEDesc_methods[] = {
	
	{"flatten", (PyCFunction)AEDesc_AEFlattenDesc, 1, PyDoc_STR(
		"D.flatten() -> (Ptr buffer)\n"
		"Flattens the specified descriptor and stores the data in the\n"
		"supplied buffer.")},
	
	{"coerce", (PyCFunction)AEDesc_AECoerceDesc, 1, PyDoc_STR(
		"D.coerce(DescType toType) -> (AEDesc result)\n"
		"Coerces the data in a descriptor to another descriptor type and\n"
		"creates a descriptor containing the newly coerced data.")},
	
	{"duplicate", (PyCFunction)AEDesc_AEDuplicateDesc, 1, PyDoc_STR(
		"D.duplicate() -> (AEDesc result)\n"
		"Creates a copy of a descriptor.")},
	
	{"count", (PyCFunction)AEDesc_AECountItems, 1, PyDoc_STR(
		"D.count() -> (long theCount)\n"
		"Counts the number of descriptors in a descriptor list.")},
	
コード例 #26
0
ファイル: xxsubtype.c プロジェクト: 0xcc/pyston
            self = Py_None;
        if (kw == NULL)
            kw = Py_None;
        Py_INCREF(self);
        PyTuple_SET_ITEM(result, 0, self);
        Py_INCREF(args);
        PyTuple_SET_ITEM(result, 1, args);
        Py_INCREF(kw);
        PyTuple_SET_ITEM(result, 2, kw);
    }
    return result;
}

static PyMethodDef spamlist_methods[] = {
    {"getstate", (PyCFunction)spamlist_getstate, METH_VARARGS,
        PyDoc_STR("getstate() -> state")},
    {"setstate", (PyCFunction)spamlist_setstate, METH_VARARGS,
        PyDoc_STR("setstate(state)")},
    /* These entries differ only in the flags; they are used by the tests
       in test.test_descr. */
    {"classmeth", (PyCFunction)spamlist_specialmeth,
        METH_VARARGS | METH_KEYWORDS | METH_CLASS,
        PyDoc_STR("classmeth(*args, **kw)")},
    {"staticmeth", (PyCFunction)spamlist_specialmeth,
        METH_VARARGS | METH_KEYWORDS | METH_STATIC,
        PyDoc_STR("staticmeth(*args, **kw)")},
    {NULL,      NULL},
};

static int
spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
コード例 #27
0
ファイル: _Launchmodule.c プロジェクト: 0xcc/python-read
    CFURLRef inURL;
    CFURLRef outLaunchedURL;
    if (!PyArg_ParseTuple(_args, "O&",
                          CFURLRefObj_Convert, &inURL))
        return NULL;
    _err = LSOpenCFURLRef(inURL,
                          &outLaunchedURL);
    if (_err != noErr) return PyMac_Error(_err);
    _res = Py_BuildValue("O&",
                         CFURLRefObj_New, outLaunchedURL);
    return _res;
}

static PyMethodDef Launch_methods[] = {
    {"LSCopyItemInfoForRef", (PyCFunction)Launch_LSCopyItemInfoForRef, 1,
     PyDoc_STR("(FSRef inItemRef, LSRequestedInfo inWhichInfo) -> (LSItemInfoRecord outItemInfo)")},
    {"LSCopyItemInfoForURL", (PyCFunction)Launch_LSCopyItemInfoForURL, 1,
     PyDoc_STR("(CFURLRef inURL, LSRequestedInfo inWhichInfo) -> (LSItemInfoRecord outItemInfo)")},
    {"LSGetExtensionInfo", (PyCFunction)Launch_LSGetExtensionInfo, 1,
     PyDoc_STR("(Buffer inNameLen) -> (UniCharCount outExtStartIndex)")},
    {"LSCopyDisplayNameForRef", (PyCFunction)Launch_LSCopyDisplayNameForRef, 1,
     PyDoc_STR("(FSRef inRef) -> (CFStringRef outDisplayName)")},
    {"LSCopyDisplayNameForURL", (PyCFunction)Launch_LSCopyDisplayNameForURL, 1,
     PyDoc_STR("(CFURLRef inURL) -> (CFStringRef outDisplayName)")},
    {"LSSetExtensionHiddenForRef", (PyCFunction)Launch_LSSetExtensionHiddenForRef, 1,
     PyDoc_STR("(FSRef inRef, Boolean inHide) -> None")},
    {"LSSetExtensionHiddenForURL", (PyCFunction)Launch_LSSetExtensionHiddenForURL, 1,
     PyDoc_STR("(CFURLRef inURL, Boolean inHide) -> None")},
    {"LSCopyKindStringForRef", (PyCFunction)Launch_LSCopyKindStringForRef, 1,
     PyDoc_STR("(FSRef inFSRef) -> (CFStringRef outKindString)")},
    {"LSCopyKindStringForURL", (PyCFunction)Launch_LSCopyKindStringForURL, 1,
コード例 #28
0
		   "symtable() arg 3 must be 'exec' or 'eval' or 'single'");
		return NULL;
	}
	st = Py_SymtableString(str, filename, start);
	if (st == NULL)
		return NULL;
	t = st->st_symbols;
	Py_INCREF(t);
	PyMem_Free((void *)st->st_future);
	PySymtable_Free(st);
	return t;
}

static PyMethodDef symtable_methods[] = {
	{"symtable",	symtable_symtable,	METH_VARARGS,
	 PyDoc_STR("Return symbol and scope dictionaries"
	 	   " used internally by compiler.")},
	{NULL,		NULL}		/* sentinel */
};

PyMODINIT_FUNC
init_symtable(void)
{
	PyObject *m;

	m = Py_InitModule("_symtable", symtable_methods);
	if (m == NULL)
		return;
	PyModule_AddIntConstant(m, "USE", USE);
	PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL);
	PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL);
	PyModule_AddIntConstant(m, "DEF_PARAM", DEF_PARAM);
コード例 #29
0
ファイル: symbol.c プロジェクト: AleksandrRasskazov/zbar
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser Public License
 *  along with the ZBar Bar Code Reader; if not, write to the Free
 *  Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 *  Boston, MA  02110-1301  USA
 *
 *  http://sourceforge.net/projects/zbar
 *------------------------------------------------------------------------*/

#include "zbarmodule.h"

static char symbol_doc[] = PyDoc_STR(
    "symbol result object.\n"
    "\n"
    "data and associated information about a successful decode.");

static int
symbol_traverse (zbarSymbol *self,
                 visitproc visit,
                 void *arg)
{
    return(0);
}

static int
symbol_clear (zbarSymbol *self)
{
    if(self->zsym) {
        zbar_symbol_t *zsym = (zbar_symbol_t*)self->zsym;
コード例 #30
0
        varAssign = malloc(strlen(varName) + strlen(varValue) + 2);
        sprintf(varAssign, "%s=%s", varName, varValue);
        if (putenv(varAssign) == 0) {
            Py_INCREF(Py_None);
            returnObj = Py_None;
        }
        else
            PyErr_SetString(PyExc_SystemError, "Error calling putenv");
    }
    return returnObj;
}

/* registration table */
static PyMethodDef cenviron_methods[] = {
    {"getenv",          (PyCFunction)wrap_getenv,  METH_VARARGS,
        PyDoc_STR("getenv -> displays the value of an enviroment variable.")},
    {"putenv",          (PyCFunction)wrap_putenv,  METH_VARARGS,
        PyDoc_STR("putenv -> sets a value of an enviroment variable.")},
    {NULL, NULL, 0, NULL}           /* sentinel */
};

PyDoc_STRVAR(cenviron_doc,
"cenviron documentation.");


//  static PyTypeObject cenviron_CenvironType = {
//      PyVarObject_HEAD_INIT(NULL, 0)
//      "cenviron",                   /*tp_name*/
//      sizeof(cenviron_CenvironObject),               /*tp_basicsize*/
//      0,                                  /*tp_itemsize*/
//      /* methods */