Ejemplo n.º 1
0
static int t_locale_init(t_locale *self, PyObject *args, PyObject *kwds)
{
    charsArg language, country, variant;
    int lcid, len;

    switch (PyTuple_Size(args)) {
      case 0:
        self->object = new Locale();
        self->flags = T_OWNED;
        break;
      case 1:
        if (!parseArgs(args, "n", &language))
        {
            self->object = new Locale(language);
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "i", &lcid))
        {
            char code[128];

            INT_STATUS_CALL(len = uloc_getLocaleForLCID(
                lcid, code, sizeof(code), &status));
            if (len < sizeof(code))
            {
                self->object = new Locale(code);
                self->flags = T_OWNED;
            }
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      case 2:
        if (!parseArgs(args, "nn", &language, &country))
        {
            self->object = new Locale(language, country);
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      case 3:
        if (!parseArgs(args, "nnn", &language, &country, &variant))
        {
            self->object = new Locale(language, country, variant);
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      default:
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
    }
        
    if (self->object)
        return 0;

    return -1;
}
Ejemplo n.º 2
0
static int t_localedata_init(t_localedata *self, PyObject *args, PyObject *kwds)
{
    charsArg id;

    switch (PyTuple_Size(args)) {
      case 1:
        if (!parseArgs(args, "n", &id))
        {
            ULocaleData *locale_data;

            INT_STATUS_CALL(locale_data = ulocdata_open(id, &status));
            self->object = locale_data;
            self->locale_id = strdup((const char *) id);
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      default:
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
    }
        
    if (self->object)
        return 0;

    return -1;
}
Ejemplo n.º 3
0
static int t_regexmatcher_init(t_regexmatcher *self,
                               PyObject *args, PyObject *kwds)
{
    RegexMatcher *matcher;
    UnicodeString *u0, *u1;
    uint32_t flags;

    switch (PyTuple_Size(args)) {
      case 2:
        if (!parseArgs(args, "Wi", &u0, &self->re, &flags))
        {
            INT_STATUS_CALL(matcher = new RegexMatcher(*u0, flags, status));
            self->object = matcher;
            self->pattern = NULL;
            self->input = NULL;
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      case 3:
        if (!parseArgs(args, "WWi", &u0, &self->re, &u1, &self->input, &flags))
        {
            INT_STATUS_CALL(matcher = new RegexMatcher(*u0, *u1, flags,
                                                       status));
            self->object = matcher;
            self->pattern = NULL;
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      default:
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
    }

    if (self->object)
        return 0;

    return -1;
}
Ejemplo n.º 4
0
static int t_resourcebundle_init(t_resourcebundle *self,
                                 PyObject *args, PyObject *kwds)
{
    UnicodeString *u, _u;
    Locale *locale;
    ResourceBundle *bundle;

    switch (PyTuple_Size(args)) {
      case 0:
        INT_STATUS_CALL(bundle = new ResourceBundle(status));
        self->object = bundle;
        self->flags = T_OWNED;
        break;
      case 1:
        if (!parseArgs(args, "S", &u, &_u))
        {
            INT_STATUS_CALL(bundle = new ResourceBundle(*u, status));
            self->object = bundle;
            self->flags = T_OWNED;
            break;
        }
      case 2:
        if (!parseArgs(args, "SP", TYPE_CLASSID(Locale),
                       &u, &_u, &locale))
        {
            INT_STATUS_CALL(bundle = new ResourceBundle(*u, *locale, status));
            self->object = bundle;
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
    }
        
    if (self->object)
        return 0;

    return -1;
}
static int t_canonicaliterator_init(t_canonicaliterator *self,
                                    PyObject *args, PyObject *kwds)
{
    UnicodeString *u;
    UnicodeString _u;

    if (!parseArgs(args, "S", &u, &_u))
    {
        CanonicalIterator *iterator;

        INT_STATUS_CALL(iterator = new CanonicalIterator(*u, status));
        self->object = iterator;
        self->flags = T_OWNED;

        return 0;
    }

    PyErr_SetArgsError((PyObject *) self, "__init__", args);
    return -1;
}
Ejemplo n.º 6
0
static int t_stringsearch_init(t_stringsearch *self,
                               PyObject *args, PyObject *kwds)
{
    UnicodeString *u0, _u0;
    UnicodeString *u1;
    Locale *locale;
    BreakIterator *iterator;
    RuleBasedCollator *collator;
    CharacterIterator *chars;

    switch (PyTuple_Size(args)) {
      case 3:
        if (!parseArgs(args, "SWP",
                       TYPE_CLASSID(Locale),
                       &u0, &_u0, &u1, &self->text, &locale))
        {
            INT_STATUS_CALL(self->object = new StringSearch(*u0, *u1, *locale,
                                                            NULL, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "SWp",
                       TYPE_CLASSID(RuleBasedCollator),
                       &u0, &_u0, &u1, &self->text,
                       &collator, &self->collator))
        {
            INT_STATUS_CALL(self->object = new StringSearch(*u0, *u1, collator,
                                                            NULL, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "SpP",
                       TYPE_ID(CharacterIterator),
                       TYPE_CLASSID(Locale),
                       &u0, &_u0, &chars, &self->text, &locale))
        {
            INT_STATUS_CALL(self->object =
                            new StringSearch(*u0, *chars, *locale,
                                             NULL, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "Spp",
                       TYPE_ID(CharacterIterator),
                       TYPE_CLASSID(RuleBasedCollator),
                       &u0, &_u0, &chars, &self->text,
                       &collator, &self->collator))
        {
            INT_STATUS_CALL(self->object =
                            new StringSearch(*u0, *chars, collator,
                                             NULL, status));
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      case 4:
        if (!parseArgs(args, "SWPp",
                       TYPE_CLASSID(Locale),
                       TYPE_ID(BreakIterator),
                       &u0, &_u0, &u1, &self->text,
                       &locale, &iterator, &self->iterator))
        {
            INT_STATUS_CALL(self->object = new StringSearch(*u0, *u1, *locale,
                                                            iterator, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "SWpp",
                       TYPE_CLASSID(RuleBasedCollator),
                       TYPE_ID(BreakIterator),
                       &u0, &_u0, &u1, &self->text,
                       &collator, &self->collator,
                       &iterator, &self->iterator))
        {
            INT_STATUS_CALL(self->object = new StringSearch(*u0, *u1, collator,
                                                            NULL, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "SpPp",
                       TYPE_ID(CharacterIterator),
                       TYPE_CLASSID(Locale),
                       TYPE_ID(BreakIterator),
                       &u0, &_u0, &chars, &self->text, &locale,
                       &iterator, &self->iterator))
        {
            INT_STATUS_CALL(self->object =
                            new StringSearch(*u0, *chars, *locale,
                                             iterator, status));
            self->flags = T_OWNED;
            break;
        }
        if (!parseArgs(args, "Sppp",
                       TYPE_ID(CharacterIterator),
                       TYPE_CLASSID(RuleBasedCollator),
                       TYPE_ID(BreakIterator),
                       &u0, &_u0, &chars, &self->text,
                       &collator, &self->collator,
                       &iterator, &self->iterator))
        {
            INT_STATUS_CALL(self->object =
                            new StringSearch(*u0, *chars, collator,
                                             iterator, status));
            self->flags = T_OWNED;
            break;
        }
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
      default:
        PyErr_SetArgsError((PyObject *) self, "__init__", args);
        return -1;
    }
        
    if (self->object)
        return 0;

    return -1;
}