Exemple #1
0
static PyObject *
pickle___reduce__(PyObject *self)
{
  PyObject *args=NULL, *bargs=0, *state=NULL;
  int l, i;
  
  bargs = PyObject_CallMethodObjArgs(self, str__getnewargs__, NULL);
  if (bargs == NULL)
    return NULL;

  l = PyTuple_Size(bargs);
  if (l < 0)
    goto end;

  args = PyTuple_New(l+1);
  if (args == NULL)
    goto end;
  
  Py_INCREF(self->ob_type);
  PyTuple_SET_ITEM(args, 0, (PyObject*)(self->ob_type));
  for (i = 0; i < l; i++)
    {
      Py_INCREF(PyTuple_GET_ITEM(bargs, i));
      PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
    }
  
  state = PyObject_CallMethodObjArgs(self, str__getstate__, NULL);
  if (state == NULL)
    goto end;

  state = Py_BuildValue("(OON)", __newobj__, args, state);

 end:
  Py_XDECREF(bargs);
  Py_XDECREF(args);

  return state;
}
Exemple #2
0
static void rpy_MetricInfo(int c, const pGEcontext gc, 
                           double* ascent, double* descent, double *width,
                           pDevDesc dd)
{
  PyObject *result;

  /* Restore the Python handler */
  /* FIXME */
  /* PyOS_setsig(SIGINT, python_sighandler); */
  
  PyObject *self = (PyObject *)dd->deviceSpecific;
  /* FIXME optimize ? */
#ifdef RPY_DEBUG_GRDEV
  printf("FIXME: MetricInfo.\n");
#endif
#if (PY_VERSION_HEX < 0x03010000)
  PyObject *py_c = PyInt_FromLong((long)c);
#else
  PyObject *py_c = PyLong_FromLong((long)c);
#endif
  //PyObject *py_ascent = PyFloat_FromDouble(*ascent);
  //PyObject *py_descent = PyFloat_FromDouble(*descent);
  //PyObject *py_width = PyFloat_FromDouble(*width);
  /* FIXME pass gc ? */
  result = PyObject_CallMethodObjArgs(self, GrDev_metricinfo_name, 
                                      py_c,
                                      //py_ascent, py_descent, py_width,
                                      NULL);

  rpy_printandclear_error();


  if (! PyTuple_Check(result) ) {
    PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple.");
    rpy_printandclear_error();
  } else if (PyTuple_Size(result) != 3) {
    PyErr_Format(PyExc_ValueError, "Callback 'metricinfo' should return a tuple of length 3.");
    rpy_printandclear_error();    
  } else {
    *ascent = PyFloat_AsDouble(PyTuple_GetItem(result, 0));
    *descent = PyFloat_AsDouble(PyTuple_GetItem(result, 1));
    *width = PyFloat_AsDouble(PyTuple_GetItem(result, 2));
  }
  Py_DECREF(py_c);
  //Py_DECREF(py_ascent);
  //Py_DECREF(py_descent);
  //Py_DECREF(py_width);
  Py_DECREF(result);

}
Exemple #3
0
static PyObject *_prepareValue(t_set *self, PyObject *value)
{
    PyObject *item = PyObject_Call(self->itemvalue.owner, Empty_TUPLE, NULL);

    if (!item)
        return NULL;

    value = PyObject_CallMethodObjArgs((PyObject *) self, prepareValue_NAME,
                                        item, self->itemvalue.attribute, value,
                                        Py_False, NULL);
    Py_DECREF(item);

    return value;
}
Exemple #4
0
static PyObject* GetHash(PyObject* p)
{
    if (hashlib)
    {
        Object hash(PyObject_CallMethod(hashlib, "new", "s", "sha1"));
        if (!hash.IsValid())
            return 0;
        
        PyObject_CallMethodObjArgs(hash, update, p, 0);
        return PyObject_CallMethod(hash, "hexdigest", 0);
    }
    
    if (sha)
    {
        Object hash(PyObject_CallMethod(sha, "new", 0));
        if (!hash.IsValid())
            return 0;
        
        PyObject_CallMethodObjArgs(hash, update, p, 0);
        return PyObject_CallMethod(hash, "hexdigest", 0);
    }

    return 0;
}
Exemple #5
0
static PyObject *
iobase_iternext(PyObject *self)
{
    PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL);

    if (line == NULL)
        return NULL;

    if (PyObject_Size(line) == 0) {
        Py_DECREF(line);
        return NULL;
    }

    return line;
}
Exemple #6
0
/* evaluate a call to a Python callback for the device */
static inline void rpy_GrDev_CallBack(pDevDesc dd, PyObject *name)
{
  PyObject *result;

  /* Restore the Python handler */
  /* FIXME */
  /* PyOS_setsig(SIGINT, python_sighandler); */

  PyObject *self = (PyObject *)dd->deviceSpecific;
  result = PyObject_CallMethodObjArgs(self, name, NULL);

  rpy_printandclear_error();

  Py_XDECREF(result);  
}
Exemple #7
0
HostRef* PythonHostEnvironment::getCallableFrom(HostRef* ref, string& name)
{
	JPCleaner cleaner;

	PyObject* pname = JPyString::fromString(name.c_str());
	cleaner.add(new HostRef(pname, false));
	PyObject* mname = JPyString::fromString("getCallable");
	cleaner.add(new HostRef(mname, false));

	PyObject* call = PyObject_CallMethodObjArgs(UNWRAP(ref), mname, pname, NULL);

	JPyErr::check();
	return new HostRef(call, false);

}
Exemple #8
0
/* May be called with any object */
PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args)
{
    PyObject *res  = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
    if (res == NULL)
        return NULL;
    if (res != Py_True) {
        Py_CLEAR(res);
        iobase_unsupported("File or stream is not writable.");
        return NULL;
    }
    if (args == Py_True) {
        Py_DECREF(res);
    }
    return res;
}
Exemple #9
0
static PyObject *
iobase_close(PyObject *self, PyObject *args)
{
    PyObject *res;

    if (IS_CLOSED(self))
        Py_RETURN_NONE;

    res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
    PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
    if (res == NULL) {
        return NULL;
    }
    Py_XDECREF(res);
    Py_RETURN_NONE;
}
Exemple #10
0
    virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
    {
        PyObject *name = PyString_FromString("getGlyphAdvance");
        PyObject *g = PyInt_FromLong(LE_GET_GLYPH(glyph));
        PyObject *result =
            PyObject_CallMethodObjArgs((PyObject *) self, name, g, NULL);

        Py_DECREF(g);
        Py_DECREF(name);

        if (result != NULL)
        {
            PyArg_ParseTuple(result, "ff", &advance.fX, &advance.fY);
            Py_DECREF(result);
        }
    }
Exemple #11
0
static void rpy_NewPage(const pGEcontext gc, pDevDesc dd)
{
  PyObject *result;

  /* Restore the Python handler */
  /* FIXME */
  /* PyOS_setsig(SIGINT, python_sighandler); */

  /* FIXME give the callback access to gc */
  PyObject *self = (PyObject *)dd->deviceSpecific;
  result = PyObject_CallMethodObjArgs(self, GrDev_newpage_name, NULL);

  rpy_printandclear_error();

  Py_XDECREF(result);  
}
Exemple #12
0
/* May be called with any object */
PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args)
{
    PyObject *res  = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
    if (res == NULL)
        return NULL;
    if (res != Py_True) {
        Py_CLEAR(res);
        PyErr_SetString(PyExc_IOError, "File or stream is not writable.");
        return NULL;
    }
    if (args == Py_True) {
        Py_DECREF(res);
    }
    return res;
}
Exemple #13
0
static Rboolean rpy_Locator(double *x, double *y, pDevDesc dd)
{
  PyObject *result;

  /* Restore the Python handler */
  /* FIXME */
  /* PyOS_setsig(SIGINT, python_sighandler); */

  PyObject *self = (PyObject *)dd->deviceSpecific;
  /* FIXME optimize ? */
#ifdef RPY_DEBUG_GRDEV
  printf("FIXME: Locator.\n");
#endif
  //PyObject *py_x = PyList_New(0);
  //PyObject *py_y = PyList_New(0);

  /* FIXME: pass gc ? */
  /* FIXME: test !dd->dev->locator before proceed ? */
  result = PyObject_CallMethodObjArgs(self, GrDev_locator_name, 
                                      //py_x, py_y,
                                      NULL);

  rpy_printandclear_error();

  if (! PyTuple_Check(result) ) {
    PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple.");
    rpy_printandclear_error();
  } else if (PyTuple_Size(result) != 2) {
    PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple of length 2.");
    rpy_printandclear_error();    
  } else {
    x[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
    y[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
    //int i;
      //for (i = 0; i < n; i++) {
      //x[i] = PyFloat_AsDouble(PyList_GET_ITEM(py_x, (Py_ssize_t)i));
      //y[i] = PyFloat_AsDouble(PyList_GET_ITEM(py_y, (Py_ssize_t)i));
      //}
  }

  Rboolean res_r = TRUE;
  printf("FIXME: return TRUE or FALSE");
  //Py_DECREF(py_x);
  //Py_DECREF(py_y);
  Py_DECREF(result);
  return res_r;
}
static PyObject *
pickle___reduce__(PyObject *self)
{
    PyObject *args=NULL, *bargs=NULL, *state=NULL, *getnewargs=NULL;
    int l, i;

    getnewargs = PyObject_GetAttr(self, py___getnewargs__);
    if (getnewargs)
    {
        bargs = PyObject_CallFunctionObjArgs(getnewargs, NULL);
        Py_DECREF(getnewargs);
        if (!bargs)
            return NULL;
        l = PyTuple_Size(bargs);
        if (l < 0)
            goto end;
    }
    else
    {
        PyErr_Clear();
        l = 0;
    }

    args = PyTuple_New(l+1);
    if (args == NULL)
        goto end;

    Py_INCREF(Py_TYPE(self));
    PyTuple_SET_ITEM(args, 0, (PyObject*)(Py_TYPE(self)));
    for (i = 0; i < l; i++)
    {
        Py_INCREF(PyTuple_GET_ITEM(bargs, i));
        PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
    }

    state = PyObject_CallMethodObjArgs(self, py___getstate__, NULL);
    if (!state)
        goto end;

    state = Py_BuildValue("(OON)", __newobj__, args, state);

end:
    Py_XDECREF(bargs);
    Py_XDECREF(args);

    return state;
}
Exemple #15
0
static PyObject *
pickle___reduce__(PyObject *self)
{
  PyObject *args=NULL, *bargs=0, *state=NULL;
  int l, i;

  /* we no longer require '__getnewargs__' to be defined but use it if it is */
  PyObject *getnewargs=NULL;

  getnewargs = PyObject_GetAttr(self, str__getnewargs__);
  if (getnewargs)
    bargs = PyEval_CallObject(getnewargs, (PyObject *)NULL);
  else {
    PyErr_Clear();
    bargs = PyTuple_New(0);
  }

  l = PyTuple_Size(bargs);
  if (l < 0)
    goto end;

  args = PyTuple_New(l+1);
  if (args == NULL)
    goto end;
  
  Py_INCREF(self->ob_type);
  PyTuple_SET_ITEM(args, 0, (PyObject*)(self->ob_type));
  for (i = 0; i < l; i++)
    {
      Py_INCREF(PyTuple_GET_ITEM(bargs, i));
      PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
    }
  
  state = PyObject_CallMethodObjArgs(self, str__getstate__, NULL);
  if (state == NULL)
    goto end;

  state = Py_BuildValue("(OON)", __newobj__, args, state);

 end:
  Py_XDECREF(bargs);
  Py_XDECREF(args);
  Py_XDECREF(getnewargs);

  return state;
}
Exemple #16
0
static PyObject *
iobase_close(PyObject *self, PyObject *args)
{
    PyObject *res;
    _Py_IDENTIFIER(__IOBase_closed);

    if (IS_CLOSED(self))
        Py_RETURN_NONE;

    res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
    _PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True);
    if (res == NULL) {
        return NULL;
    }
    Py_XDECREF(res);
    Py_RETURN_NONE;
}
/*
        def __call__(self, obj, alternate=_marker):
            conform = getattr(obj, '__conform__', None)
            if conform is not None:
                adapter = self._call_conform(conform)
                if adapter is not None:
                    return adapter

            adapter = self.__adapt__(obj)

            if adapter is not None:
                return adapter
            elif alternate is not _marker:
                return alternate
            else:
                raise TypeError("Could not adapt", obj, self)
*/
static PyObject *
ib_call(PyObject *self, PyObject *args, PyObject *kwargs)
{
  PyObject *conform, *obj, *alternate=NULL, *adapter;

  static char *kwlist[] = {"obj", "alternate", NULL};

  if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist,
                                   &obj, &alternate))
    return NULL;

  conform = PyObject_GetAttr(obj, str__conform__);
  if (conform != NULL)
    {
      adapter = PyObject_CallMethodObjArgs(self, str_call_conform,
                                           conform, NULL);
      Py_DECREF(conform);
      if (adapter == NULL || adapter != Py_None)
        return adapter;
      Py_DECREF(adapter);
    }
  else
    PyErr_Clear();

  adapter = __adapt__(self, obj);
  if (adapter == NULL || adapter != Py_None)
    return adapter;
  Py_DECREF(adapter);

  if (alternate != NULL)
    {
      Py_INCREF(alternate);
      return alternate;
    }

  adapter = Py_BuildValue("sOO", "Could not adapt", obj, self);
  if (adapter != NULL)
    {
      PyErr_SetObject(PyExc_TypeError, adapter);
      Py_DECREF(adapter);
    }
  return NULL;
}
Exemple #18
0
static void
iobase_finalize(PyObject *self)
{
    PyObject *res;
    PyObject *error_type, *error_value, *error_traceback;
    int closed;
    _Py_IDENTIFIER(_finalizing);

    /* Save the current exception, if any. */
    PyErr_Fetch(&error_type, &error_value, &error_traceback);

    /* If `closed` doesn't exist or can't be evaluated as bool, then the
       object is probably in an unusable state, so ignore. */
    res = PyObject_GetAttr(self, _PyIO_str_closed);
    if (res == NULL) {
        PyErr_Clear();
        closed = -1;
    }
    else {
        closed = PyObject_IsTrue(res);
        Py_DECREF(res);
        if (closed == -1)
            PyErr_Clear();
    }
    if (closed == 0) {
        /* Signal close() that it was called as part of the object
           finalization process. */
        if (_PyObject_SetAttrId(self, &PyId__finalizing, Py_True))
            PyErr_Clear();
        res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_close,
                                          NULL);
        /* Silencing I/O errors is bad, but printing spurious tracebacks is
           equally as bad, and potentially more frequent (because of
           shutdown issues). */
        if (res == NULL)
            PyErr_Clear();
        else
            Py_DECREF(res);
    }

    /* Restore the saved exception. */
    PyErr_Restore(error_type, error_value, error_traceback);
}
Exemple #19
0
static int t_descriptor___delete__(t_descriptor *self, t_item *item)
{
    t_attribute *attr = self->attr;

    if (attr)
    {
        t_values *attrDict = get_attrdict(item, attr->flags);
        PyObject *value = PyObject_CallMethodObjArgs((PyObject *) item, removeAttributeValue_NAME, self->name, attrDict ? (PyObject *) attrDict : Py_None, attr->attrID, NULL);

        if (!value)
            return -1;

        Py_DECREF(value);
        return 0;
    }

    PyErr_SetObject(PyExc_AttributeError, self->name);
    return -1;
}
/*
    def subscriptions(self, required, provided):
        cache = self._scache.get(provided)
        if cache is None:
            cache = {}
            self._scache[provided] = cache

        required = tuple(required)
        result = cache.get(required, _not_in_mapping)
        if result is _not_in_mapping:
            result = self._uncached_subscriptions(required, provided)
            cache[required] = result

        return result
*/
static PyObject *
_subscriptions(lookup *self, PyObject *required, PyObject *provided)
{
  PyObject *cache, *result;

  ASSURE_DICT(self->_scache);
  cache = _subcache(self->_scache, provided);
  if (cache == NULL)
    return NULL;

  required = tuplefy(required);
  if (required == NULL)
    return NULL;

  result = PyDict_GetItem(cache, required);
  if (result == NULL)
    {
      int status;

      result = PyObject_CallMethodObjArgs(
                                 OBJECT(self), str_uncached_subscriptions,
                                 required, provided, NULL);
      if (result == NULL)
        {
          Py_DECREF(required);
          return NULL;
        }
      status = PyDict_SetItem(cache, required, result);
      Py_DECREF(required);
      if (status < 0)
        {
          Py_DECREF(result);
          return NULL;
        }
    }
  else
    {
      Py_INCREF(result);
      Py_DECREF(required);
    }

  return result;
}
PyObject *Client_set_timeout(PyClient *self, PyObject *args)
{

  PyObject *timeout;

  if (!PyArg_ParseTuple (args, "O", &timeout))
  {
    return NULL;
  }

  PyObject *method = PyString_FromString("settimeout");
  PyObject *res = PyObject_CallMethodObjArgs(self->sock, method, timeout, NULL);

  PRINTMARK();

  Py_DECREF(method);

  return res;
}
Exemple #22
0
    le_int32 get_le_int32(const char *name) const
    {
        PyObject *s = PyString_FromString(name);
        PyObject *result =
            PyObject_CallMethodObjArgs((PyObject *) self, s, NULL);

        Py_DECREF(s);
        if (result != NULL)
        {
            int n;

            if (!parseArg(result, "i", &n))
            {
                Py_DECREF(result);
                return (le_int32) n;
            }
        }

        return 0;
    }
Exemple #23
0
static double _udate(PyObject *dt)
{
    PyObject *result = PyObject_CallMethodObjArgs(dt, toordinal_NAME, NULL);

    if (!result)
        return 0.0;

#if PY_MAJOR_VERSION >= 3
    unsigned long ordinal = PyLong_AsUnsignedLong(result);
#else
    unsigned long ordinal = PyInt_AS_LONG(result);
#endif

    Py_DECREF(result);
    return ((ordinal - 719163) * 86400.0 +
            PyDateTime_DATE_GET_HOUR(dt) * 3600.0 +
            PyDateTime_DATE_GET_MINUTE(dt) * 60.0 +
            PyDateTime_DATE_GET_SECOND(dt) +
            PyDateTime_DATE_GET_MICROSECOND(dt) / 1e6) * 1000.0;
}
Exemple #24
0
    float get_float(const char *name) const
    {
        PyObject *s = PyString_FromString(name);
        PyObject *result =
            PyObject_CallMethodObjArgs((PyObject *) self, s, NULL);

        Py_DECREF(s);
        if (result != NULL)
        {
            double d;

            if (!parseArg(result, "d", &d))
            {
                Py_DECREF(result);
                return (float) d;
            }
        }

        return 0.0f;
    }
Exemple #25
0
static PyObject *
iobase_writelines(PyObject *self, PyObject *args)
{
    PyObject *lines, *iter, *res;

    if (!PyArg_ParseTuple(args, "O:writelines", &lines)) {
        return NULL;
    }

    if (_PyIOBase_check_closed(self, Py_True) == NULL)
        return NULL;

    iter = PyObject_GetIter(lines);
    if (iter == NULL)
        return NULL;

    while (1) {
        PyObject *line = PyIter_Next(iter);
        if (line == NULL) {
            if (PyErr_Occurred()) {
                Py_DECREF(iter);
                return NULL;
            }
            else
                break; /* Stop Iteration */
        }

        res = NULL;
        do {
            res = PyObject_CallMethodObjArgs(self, _PyIO_str_write, line, NULL);
        } while (res == NULL && _PyIO_trap_eintr());
        Py_DECREF(line);
        if (res == NULL) {
            Py_DECREF(iter);
            return NULL;
        }
        Py_DECREF(res);
    }
    Py_DECREF(iter);
    Py_RETURN_NONE;
}
Exemple #26
0
static void rpy_Mode(int mode, pDevDesc dd)
{
  PyObject *result;

  /* Restore the Python handler */
  /* FIXME */
  /* PyOS_setsig(SIGINT, python_sighandler); */

  PyObject *self = (PyObject *)dd->deviceSpecific;
#if (PY_VERSION_HEX < 0x03010000)
  PyObject *py_mode = PyInt_FromLong((long)mode);
#else
  PyObject *py_mode = PyLong_FromLong((long)mode);
#endif
  result = PyObject_CallMethodObjArgs(self, GrDev_mode_name, 
                                      py_mode,
                                      NULL);
  rpy_printandclear_error();
  Py_DECREF(py_mode);
  Py_DECREF(result);  
}
static PyObject *
CP__p_deactivate(ProxyObject *self)
{
    PyObject *result;

    result = PyObject_CallMethodObjArgs(OBJECT(cPersistenceCAPI->pertype),
                                        str_p_deactivate,
                                        self, NULL);
    if (result == NULL)
        return NULL;

    if (self->jar && self->oid && self->state == cPersistent_UPTODATE_STATE)
    {
        Py_XDECREF(self->__parent__);
        self->__parent__ = NULL;
        Py_XDECREF(self->__name__);
        self->__name__ = NULL;
    }

    return result;
}
Exemple #28
0
static PyObject *t_tzinfo_utcoffset(t_tzinfo *self, PyObject *dt)
{
    PyObject *weekday = PyObject_CallMethodObjArgs(dt, weekday_NAME, NULL);
    if (!weekday)
        return NULL;

    // python's MINYEAR is 1
    int era = GregorianCalendar::AD;
    int year = PyDateTime_GET_YEAR(dt);

    // python's month is 1-based, 1 is January
    // ICU's month is 0-based, 0 is January
    int month = PyDateTime_GET_MONTH(dt) - 1;
    int day = PyDateTime_GET_DAY(dt);

    // python's weekday is 0-based, 0 is Monday
    // ICU's dayofweek is 1-based, 1 is Sunday
    int dayofweek = ((PyInt_AsLong(weekday) + 1) % 7) + 1;
    Py_DECREF(weekday);

    int millis = (int) ((PyDateTime_DATE_GET_HOUR(dt) * 3600.0 +
                         PyDateTime_DATE_GET_MINUTE(dt) * 60.0 +
                         PyDateTime_DATE_GET_SECOND(dt) +
                         PyDateTime_DATE_GET_MICROSECOND(dt) / 1e6) * 1000.0);
    int offset;

    STATUS_CALL(offset = self->tz->object->getOffset(era, year, month, day,
                                                     dayofweek, millis,
                                                     status));

    PyObject *args = PyTuple_New(2);
    PyObject *result;

    PyTuple_SET_ITEM(args, 0, PyInt_FromLong(0));
    PyTuple_SET_ITEM(args, 1, PyInt_FromLong(offset / 1000));
    result = PyObject_Call((PyObject *) datetime_deltaType, args, NULL);
    Py_DECREF(args);

    return result;
}
Exemple #29
0
static PyObject *_internal_stream_load(PyObject *args, unsigned int blocking)
{
    PyObject *decoder = NULL;
    PyObject *stream = NULL;
    PyObject *buffer = NULL;
    PyObject *result = NULL;

    if (!PyArg_ParseTuple(args, "O", &stream)) {
        goto bad_type;
    }

    if (__read == NULL) {
        __read = PyString_FromString("read");
    }

    if (!PyObject_HasAttr(stream, __read)) {
        goto bad_type;
    }

    buffer = PyObject_CallMethodObjArgs(stream, __read, NULL);

    if (!buffer)
        return NULL;

    decoder = PyObject_Call((PyObject *)(&YajlDecoderType), NULL, NULL);
    if (decoder == NULL) {
        return NULL;
    }

    result = _internal_decode((_YajlDecoder *)decoder, PyString_AsString(buffer),
                  PyString_Size(buffer));
    Py_XDECREF(decoder);
    Py_XDECREF(buffer);
    return result;

bad_type:
    PyErr_SetObject(PyExc_TypeError, PyString_FromString("Must pass a single stream object"));
    return NULL;
}
Exemple #30
0
    virtual LEGlyphID mapCharToGlyph(LEUnicode32 u) const
    {
        PyObject *name = PyString_FromString("mapCharToGlyph");
        PyObject *n = PyInt_FromLong(u);
        PyObject *result =
            PyObject_CallMethodObjArgs((PyObject *) self, name, n, NULL);

        Py_DECREF(n);
        Py_DECREF(name);
        if (result != NULL)
        {
            int id;

            if (!parseArg(result, "i", &id))
            {
                Py_DECREF(result);
                return id;
            }
        }

        return 0;
    }