bool Command::DoReturn( void ) { if( mpExpr ) { sqlite3_context* ctx = mpVM->mpContext; Value vl = mpExpr->get_Value(); if( mpVM->mType != kUnknown && vl.mType != mpVM->mType ) vl.Convert( mpVM->mType ); switch( vl.mType ) { case kDouble : RESULT_DOUBLE( vl.ToDouble() ); break; case kInt : RESULT_INT( vl.ToInt() ); break; case kText : RESULT_WTEXT( vl.ToString() ); break; default: sqlite3_result_null( mpVM->mpContext ); } } return false; }
static PyObject* PyLocale_localeconv(PyObject* self) { PyObject* result; struct lconv *l; PyObject *x; result = PyDict_New(); if (!result) return NULL; /* if LC_NUMERIC is different in the C library, use saved value */ l = localeconv(); /* hopefully, the localeconv result survives the C library calls involved herein */ #define RESULT_STRING(s)\ x = PyString_FromString(l->s);\ if (!x) goto failed;\ PyDict_SetItemString(result, #s, x);\ Py_XDECREF(x) #define RESULT_INT(i)\ x = PyInt_FromLong(l->i);\ if (!x) goto failed;\ PyDict_SetItemString(result, #i, x);\ Py_XDECREF(x) /* Numeric information */ RESULT_STRING(decimal_point); RESULT_STRING(thousands_sep); x = copy_grouping(l->grouping); if (!x) goto failed; PyDict_SetItemString(result, "grouping", x); Py_XDECREF(x); /* Monetary information */ RESULT_STRING(int_curr_symbol); RESULT_STRING(currency_symbol); RESULT_STRING(mon_decimal_point); RESULT_STRING(mon_thousands_sep); x = copy_grouping(l->mon_grouping); if (!x) goto failed; PyDict_SetItemString(result, "mon_grouping", x); Py_XDECREF(x); RESULT_STRING(positive_sign); RESULT_STRING(negative_sign); RESULT_INT(int_frac_digits); RESULT_INT(frac_digits); RESULT_INT(p_cs_precedes); RESULT_INT(p_sep_by_space); RESULT_INT(n_cs_precedes); RESULT_INT(n_sep_by_space); RESULT_INT(p_sign_posn); RESULT_INT(n_sign_posn); return result; failed: Py_XDECREF(result); Py_XDECREF(x); return NULL; }