Lines Matching refs:self

575 pattern_traverse(PatternObject *self, visitproc visit, void *arg)
577 Py_VISIT(Py_TYPE(self));
578 Py_VISIT(self->groupindex);
579 Py_VISIT(self->indexgroup);
580 Py_VISIT(self->pattern);
585 pattern_clear(PatternObject *self)
587 Py_CLEAR(self->groupindex);
588 Py_CLEAR(self->indexgroup);
589 Py_CLEAR(self->pattern);
594 pattern_dealloc(PatternObject* self)
596 PyTypeObject *tp = Py_TYPE(self);
598 PyObject_GC_UnTrack(self);
599 if (self->weakreflist != NULL) {
600 PyObject_ClearWeakRefs((PyObject *) self);
602 (void)pattern_clear(self);
603 tp->tp_free(self);
642 _sre_SRE_Pattern_match_impl(PatternObject *self, PyTypeObject *cls,
652 if (!state_init(&state, (PatternObject *)self, string, pos, endpos))
657 TRACE(("|%p|%p|MATCH\n", PatternObject_GetCode(self), state.ptr));
659 status = sre_match(&state, PatternObject_GetCode(self));
661 TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr));
667 match = pattern_new_match(module_state, self, &state, status);
685 _sre_SRE_Pattern_fullmatch_impl(PatternObject *self, PyTypeObject *cls,
695 if (!state_init(&state, self, string, pos, endpos))
700 TRACE(("|%p|%p|FULLMATCH\n", PatternObject_GetCode(self), state.ptr));
703 status = sre_match(&state, PatternObject_GetCode(self));
705 TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr));
711 match = pattern_new_match(module_state, self, &state, status);
731 _sre_SRE_Pattern_search_impl(PatternObject *self, PyTypeObject *cls,
741 if (!state_init(&state, self, string, pos, endpos))
744 TRACE(("|%p|%p|SEARCH\n", PatternObject_GetCode(self), state.ptr));
746 status = sre_search(&state, PatternObject_GetCode(self));
748 TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr));
755 match = pattern_new_match(module_state, self, &state, status);
798 _sre_SRE_Pattern_findall_impl(PatternObject *self, PyObject *string,
807 if (!state_init(&state, self, string, pos, endpos))
824 status = sre_search(&state, PatternObject_GetCode(self));
836 switch (self->groups) {
851 item = PyTuple_New(self->groups);
854 for (i = 0; i < self->groups; i++) {
899 _sre_SRE_Pattern_finditer_impl(PatternObject *self, PyTypeObject *cls,
909 scanner = pattern_scanner(module_state, self, string, pos, endpos);
936 _sre_SRE_Pattern_scanner_impl(PatternObject *self, PyTypeObject *cls,
943 return pattern_scanner(module_state, self, string, pos, endpos);
956 _sre_SRE_Pattern_split_impl(PatternObject *self, PyObject *string,
968 assert(self->codesize != 0);
970 if (!state_init(&state, self, string, 0, PY_SSIZE_T_MAX))
988 status = sre_search(&state, PatternObject_GetCode(self));
1012 for (i = 0; i < self->groups; i++) {
1051 PatternObject* self,
1100 PyTuple_Pack(2, self, ptemplate)
1108 if (!state_init(&state, self, string, 0, PY_SSIZE_T_MAX)) {
1128 status = sre_search(&state, PatternObject_GetCode(self));
1157 match = pattern_new_match(module_state, self, &state, 1);
1247 _sre_SRE_Pattern_sub_impl(PatternObject *self, PyTypeObject *cls,
1253 return pattern_subx(module_state, self, repl, string, count, 0);
1269 _sre_SRE_Pattern_subn_impl(PatternObject *self, PyTypeObject *cls,
1276 return pattern_subx(module_state, self, repl, string, count, 1);
1285 _sre_SRE_Pattern___copy___impl(PatternObject *self)
1288 Py_INCREF(self);
1289 return (PyObject *)self;
1301 _sre_SRE_Pattern___deepcopy__(PatternObject *self, PyObject *memo)
1304 Py_INCREF(self);
1305 return (PyObject *)self;
1392 pattern_groupindex(PatternObject *self, void *Py_UNUSED(ignored))
1394 if (self->groupindex == NULL)
1396 return PyDictProxy_New(self->groupindex);
1399 static int _validate(PatternObject *self); /* Forward */
1422 PatternObject* self;
1427 self = PyObject_GC_NewVar(PatternObject, module_state->Pattern_Type, n);
1428 if (!self)
1430 self->weakreflist = NULL;
1431 self->pattern = NULL;
1432 self->groupindex = NULL;
1433 self->indexgroup = NULL;
1435 self->codesize = n;
1440 self->code[i] = (SRE_CODE) value;
1441 if ((unsigned long) self->code[i] != value) {
1447 PyObject_GC_Track(self);
1450 Py_DECREF(self);
1455 self->isbytes = -1;
1462 if (!getstring(pattern, &p_length, &self->isbytes,
1464 Py_DECREF(self);
1472 self->pattern = pattern;
1474 self->flags = flags;
1476 self->groups = groups;
1480 self->groupindex = groupindex;
1483 self->indexgroup = indexgroup;
1487 if (!_validate(self)) {
1488 Py_DECREF(self);
1492 return (PyObject*) self;
1976 _validate(PatternObject *self)
1978 if (_validate_outer(self->code, self->code+self->codesize, self->groups))
1992 match_traverse(MatchObject *self, visitproc visit, void *arg)
1994 Py_VISIT(Py_TYPE(self));
1995 Py_VISIT(self->string);
1996 Py_VISIT(self->regs);
1997 Py_VISIT(self->pattern);
2002 match_clear(MatchObject *self)
2004 Py_CLEAR(self->string);
2005 Py_CLEAR(self->regs);
2006 Py_CLEAR(self->pattern);
2011 match_dealloc(MatchObject* self)
2013 PyTypeObject *tp = Py_TYPE(self);
2015 PyObject_GC_UnTrack(self);
2016 (void)match_clear(self);
2017 tp->tp_free(self);
2022 match_getslice_by_index(MatchObject* self, Py_ssize_t index, PyObject* def)
2031 assert(0 <= index && index < self->groups);
2034 if (self->string == Py_None || self->mark[index] < 0) {
2040 ptr = getstring(self->string, &length, &isbytes, &charsize, &view);
2044 i = self->mark[index];
2045 j = self->mark[index+1];
2048 result = getslice(isbytes, ptr, self->string, i, j);
2055 match_getindex(MatchObject* self, PyObject* index)
2069 if (self->pattern->groupindex) {
2070 index = PyDict_GetItemWithError(self->pattern->groupindex, index);
2076 if (i < 0 || i >= self->groups) {
2088 match_getslice(MatchObject* self, PyObject* index, PyObject* def)
2090 Py_ssize_t i = match_getindex(self, index);
2096 return match_getslice_by_index(self, i, def);
2108 _sre_SRE_Match_expand_impl(MatchObject *self, PyObject *template)
2114 PyTuple_Pack(3, self->pattern, self, template)
2119 match_group(MatchObject* self, PyObject* args)
2128 result = match_getslice(self, _PyLong_GetZero(), Py_None);
2131 result = match_getslice(self, PyTuple_GET_ITEM(args, 0), Py_None);
2140 self, PyTuple_GET_ITEM(args, i), Py_None
2154 match_getitem(MatchObject* self, PyObject* name)
2156 return match_getslice(self, name, Py_None);
2169 _sre_SRE_Match_groups_impl(MatchObject *self, PyObject *default_value)
2175 result = PyTuple_New(self->groups-1);
2179 for (index = 1; index < self->groups; index++) {
2181 item = match_getslice_by_index(self, index, default_value);
2202 _sre_SRE_Match_groupdict_impl(MatchObject *self, PyObject *default_value)
2212 if (!result || !self->pattern->groupindex)
2215 while (_PyDict_Next(self->pattern->groupindex, &pos, &key, &value, &hash)) {
2218 value = match_getslice(self, key, default_value);
2247 _sre_SRE_Match_start_impl(MatchObject *self, PyObject *group)
2250 Py_ssize_t index = match_getindex(self, group);
2257 return self->mark[index*2];
2270 _sre_SRE_Match_end_impl(MatchObject *self, PyObject *group)
2273 Py_ssize_t index = match_getindex(self, group);
2280 return self->mark[index*2+1];
2320 _sre_SRE_Match_span_impl(MatchObject *self, PyObject *group)
2323 Py_ssize_t index = match_getindex(self, group);
2330 return _pair(self->mark[index*2], self->mark[index*2+1]);
2334 match_regs(MatchObject* self)
2340 regs = PyTuple_New(self->groups);
2344 for (index = 0; index < self->groups; index++) {
2345 item = _pair(self->mark[index*2], self->mark[index*2+1]);
2354 self->regs = regs;
2365 _sre_SRE_Match___copy___impl(MatchObject *self)
2368 Py_INCREF(self);
2369 return (PyObject *)self;
2381 _sre_SRE_Match___deepcopy__(MatchObject *self, PyObject *memo)
2384 Py_INCREF(self);
2385 return (PyObject *)self;
2398 match_lastindex_get(MatchObject *self, void *Py_UNUSED(ignored))
2400 if (self->lastindex >= 0)
2401 return PyLong_FromSsize_t(self->lastindex);
2406 match_lastgroup_get(MatchObject *self, void *Py_UNUSED(ignored))
2408 if (self->pattern->indexgroup &&
2409 self->lastindex >= 0 &&
2410 self->lastindex < PyTuple_GET_SIZE(self->pattern->indexgroup))
2412 PyObject *result = PyTuple_GET_ITEM(self->pattern->indexgroup,
2413 self->lastindex);
2421 match_regs_get(MatchObject *self, void *Py_UNUSED(ignored))
2423 if (self->regs) {
2424 Py_INCREF(self->regs);
2425 return self->regs;
2427 return match_regs(self);
2431 match_repr(MatchObject *self)
2434 PyObject *group0 = match_getslice_by_index(self, 0, Py_None);
2439 Py_TYPE(self)->tp_name,
2440 self->mark[0], self->mark[1], group0);
2527 scanner_traverse(ScannerObject *self, visitproc visit, void *arg)
2529 Py_VISIT(Py_TYPE(self));
2530 Py_VISIT(self->pattern);
2535 scanner_clear(ScannerObject *self)
2537 Py_CLEAR(self->pattern);
2542 scanner_dealloc(ScannerObject* self)
2544 PyTypeObject *tp = Py_TYPE(self);
2546 PyObject_GC_UnTrack(self);
2547 state_fini(&self->state);
2548 (void)scanner_clear(self);
2549 tp->tp_free(self);
2554 scanner_begin(ScannerObject* self)
2556 if (self->executing) {
2561 self->executing = 1;
2566 scanner_end(ScannerObject* self)
2568 assert(self->executing);
2569 self->executing = 0;
2581 _sre_SRE_Scanner_match_impl(ScannerObject *self, PyTypeObject *cls)
2585 SRE_STATE* state = &self->state;
2589 if (!scanner_begin(self)) {
2593 scanner_end(self);
2601 status = sre_match(state, PatternObject_GetCode(self->pattern));
2603 scanner_end(self);
2607 match = pattern_new_match(module_state, (PatternObject*) self->pattern,
2617 scanner_end(self);
2631 _sre_SRE_Scanner_search_impl(ScannerObject *self, PyTypeObject *cls)
2635 SRE_STATE* state = &self->state;
2639 if (!scanner_begin(self)) {
2643 scanner_end(self);
2651 status = sre_search(state, PatternObject_GetCode(self->pattern));
2653 scanner_end(self);
2657 match = pattern_new_match(module_state, (PatternObject*) self->pattern,
2667 scanner_end(self);
2673 PatternObject *self,
2688 if (!state_init(&scanner->state, self, string, pos, endpos)) {
2693 Py_INCREF(self);
2694 scanner->pattern = (PyObject*) self;
2701 pattern_hash(PatternObject *self)
2705 hash = PyObject_Hash(self->pattern);
2710 hash2 = _Py_HashBytes(self->code, sizeof(self->code[0]) * self->codesize);
2713 hash ^= self->flags;
2714 hash ^= self->isbytes;
2715 hash ^= self->codesize;