00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "python/py_spoolss.h"
00022 #include "python/py_conv.h"
00023
00024 struct pyconv py_FORM[] = {
00025 { "flags", PY_UINT32, offsetof(FORM, flags) },
00026 { "width", PY_UINT32, offsetof(FORM, size_x) },
00027 { "length", PY_UINT32, offsetof(FORM, size_y) },
00028 { "top", PY_UINT32, offsetof(FORM, top) },
00029 { "left", PY_UINT32, offsetof(FORM, left) },
00030 { "right", PY_UINT32, offsetof(FORM, right) },
00031 { "bottom", PY_UINT32, offsetof(FORM, bottom) },
00032 { NULL }
00033 };
00034
00035 struct pyconv py_FORM_1[] = {
00036 { "flags", PY_UINT32, offsetof(FORM_1, flag) },
00037 { "width", PY_UINT32, offsetof(FORM_1, width) },
00038 { "length", PY_UINT32, offsetof(FORM_1, length) },
00039 { "top", PY_UINT32, offsetof(FORM_1, top) },
00040 { "left", PY_UINT32, offsetof(FORM_1, left) },
00041 { "right", PY_UINT32, offsetof(FORM_1, right) },
00042 { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
00043 { "name", PY_UNISTR, offsetof(FORM_1, name) },
00044 { NULL }
00045 };
00046
00047 BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form)
00048 {
00049 *dict = from_struct(form, py_FORM_1);
00050
00051 PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
00052
00053 return True;
00054 }
00055
00056 BOOL py_to_FORM(FORM *form, PyObject *dict)
00057 {
00058 PyObject *obj, *dict_copy = PyDict_Copy(dict);
00059 char *name;
00060 BOOL result = False;
00061
00062 if (!(obj = PyDict_GetItemString(dict_copy, "name")) ||
00063 !PyString_Check(obj))
00064 goto done;
00065
00066 PyDict_DelItemString(dict_copy, "name");
00067
00068 if (!(obj = PyDict_GetItemString(dict_copy, "level")) ||
00069 !PyInt_Check(obj))
00070 goto done;
00071
00072 PyDict_DelItemString(dict_copy, "level");
00073
00074 if (!to_struct(form, dict_copy, py_FORM))
00075 goto done;
00076
00077
00078
00079
00080
00081 obj = PyDict_GetItemString(dict, "name");
00082 name = PyString_AsString(obj);
00083
00084 init_unistr2(&form->name, name, UNI_STR_TERMINATE);
00085
00086 result = True;
00087
00088 done:
00089 Py_DECREF(dict_copy);
00090 return result;
00091 }