コード例 #1
0
static void prepare(void)
{
    prepare_s(jstest_buf4);
    prepare_s(jstest_expected4);
    prepare_s(jstest_buf5);
    prepare_s(jstest_buf9);
}
コード例 #2
0
ファイル: _struct.c プロジェクト: grobe0ba/plan9front
static int
s_init(PyObject *self, PyObject *args, PyObject *kwds)
{
	PyStructObject *soself = (PyStructObject *)self;
	PyObject *o_format = NULL;
	int ret = 0;
	static char *kwlist[] = {"format", 0};

	assert(PyStruct_Check(self));

	if (!PyArg_ParseTupleAndKeywords(args, kwds, "S:Struct", kwlist,
					 &o_format))
		return -1;

	Py_INCREF(o_format);
	Py_XDECREF(soself->s_format);
	soself->s_format = o_format;

	ret = prepare_s(soself);
	return ret;
}
コード例 #3
0
static int
s_init(PyObject *self, PyObject *args, PyObject *kwds)
{
	PyStructObject *soself = (PyStructObject *)self;
	PyObject *o_format = NULL;
	int ret = 0;
	static char *kwlist[] = {"format", 0};

	assert(PyStruct_Check(self));

	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:Struct", kwlist,
					 &o_format))
		return -1;

	if (PyUnicode_Check(o_format)) {
		o_format = PyUnicode_AsASCIIString(o_format);
		if (o_format == NULL)
			return -1;
	}
	/* XXX support buffer interface, too */
	else {
		Py_INCREF(o_format);
	}

	if (!PyBytes_Check(o_format)) {
		Py_DECREF(o_format);
		PyErr_Format(PyExc_TypeError,
			     "Struct() argument 1 must be bytes, not %.200s",
			     Py_TYPE(o_format)->tp_name);
		return -1;
	}

	Py_CLEAR(soself->s_format);
	soself->s_format = o_format;

	ret = prepare_s(soself);
	return ret;
}