summaryrefslogtreecommitdiff
path: root/ext/intl/breakiterator/breakiterator_methods.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Warning to ValueError promotion in Intl extension Part 1George Peter Banyard2020-07-311-27/+16
| | | | | | | | | Affects: - IntlCalendar - IntlGregorianCalendar - IntlBreakIterator Closes GH-5669
* Introduce InternalIteratorNikita Popov2020-06-241-0/+10
| | | | | | | | | | | | | | | | | | | Userland classes that implement Traversable must do so either through Iterator or IteratorAggregate. The same requirement does not exist for internal classes: They can implement the internal get_iterator mechanism, without exposing either the Iterator or IteratorAggregate APIs. This makes them usable in get_iterator(), but incompatible with any Iterator based APIs. A lot of internal classes do this, because exposing the userland APIs is simply a lot of work. This patch alleviates this issue by providing a generic InternalIterator class, which acts as an adapater between get_iterator and Iterator, and can be easily used by many internal classes. At the same time, we extend the requirement that Traversable implies Iterator or IteratorAggregate to internal classes as well. Closes GH-5216.
* Refactor IntlBreakIterator::next() handlingGeorge Peter Banyard2020-06-051-13/+8
|
* Generate method entries for ext/intlMáté Kocsis2020-04-141-21/+21
| | | | Closes GH-5370
* Get rid of method mapping of BreakIterator classesMáté Kocsis2020-02-251-20/+20
|
* Remove unnecessary checks in breakpoint iteratorNikita Popov2020-02-251-5/+0
| | | | | The result of Z_INTL_BREAKITERATOR_P() cannot be NULL. This type of macro in general can never be NULL.
* Use RETURN_THROWS() during ZPP in most of the extensionsMáté Kocsis2019-12-311-12/+12
| | | | Except for some bigger ones: reflection, sodium, spl
* Cleanup return values for Intl when parameter parsing is unsuccessfulMáté Kocsis2019-10-301-12/+12
| | | | Closes GH-4871.
* Remove mention of PHP major version in Copyright headersGabriel Caruso2019-09-251-2/+0
| | | | Closes GH-4732.
* Intl: Don't separately report "bad arguments" errorsNikita Popov2019-03-111-27/+0
| | | | | zpp will be throwing for these now, don't report them in addition to that.
* Use ZEND_THIS macro to hide implementation details in extensions code.Dmitry Stogov2018-11-151-10/+10
|
* Eliminate useless $this related checkDmitry Stogov2018-11-141-10/+10
|
* Remove unused variablesGabriel Caruso2018-07-251-1/+0
|
* Merge branch 'PHP-7.2'Nikita Popov2018-06-131-1/+1
|\
| * Make $locale parameter to BreakIterator ctors optionalNikita Popov2018-06-131-1/+1
| | | | | | | | It's documented as such and already accepts null.
* | Simplify namespace accessAnatol Belski2018-04-011-2/+2
| | | | | | | | The icu namespace is an alias which resolves to the real namespace.
* | Utilize the recommended way to handle the icu namespaceAnatol Belski2018-03-311-0/+2
|/
* Use ZSTR_ API to access zend_string elements (this is just renaming without ↵Dmitry Stogov2015-06-301-1/+1
| | | | semantick changes).
* Fix Intl constructor leaksNikita Popov2015-04-171-2/+2
| | | | | Drop the Z_OBJ(return_value) = NULL hack and return status code from ctor function instead.
* zend_get_parameters_ex is deprecatedXinchen Hui2015-02-131-15/+5
|
* first shot remove TSRMLS_* thingsAnatol Belski2014-12-131-32/+32
|
* s/PHP 5/PHP 7/Johannes Schlüter2014-09-191-1/+1
|
* first show to make 's' work with size_tAnatol Belski2014-08-271-2/+2
|
* master renames phase 1Anatol Belski2014-08-251-13/+13
|
* ported ext/intl, bugfixes to goAnatol Belski2014-08-191-13/+13
|
* basic macro replacements, all at onceAnatol Belski2014-08-191-4/+4
|
* Fixed temporarily un-expected object re-initXinchen Hui2014-06-291-2/+2
|
* Refactoring ext/intl (only compilerable now, far to finish :<)Xinchen Hui2014-06-281-17/+14
|
* Fix "passing NULL to non-pointer argument" warnings in intlNikita Popov2013-03-291-5/+5
| | | | The second argument to spprintf is a size_t (maximum length).
* - Fixed buildFelipe Pena2012-06-271-0/+1
|
* BreakIterator::getPartsIterator: new optional argGustavo André dos Santos Lopes2012-06-221-3/+13
| | | | | | | | | Can take one of: * IntlPartsIterator::KEY_SEQUENTIAL (keys are 0, 1, ...) * IntlPartsIterator::KEY_LEFT (keys are left boundaries) * IntlPartsIterator::KEY_LEFT (keys are right boundaries) The default is IntlPartsIterator::KEY_SEQUENTIAL (the previous behavior).
* Added IntlCodePointBreakIterator.Gustavo André dos Santos Lopes2012-06-221-0/+18
| | | | | | | | | | | | | | | | | Objects of this class can be instantiated with IntlBreakIterator::createCodePointInstance() The method does not take a locale, as it would not make sense in this context. This class has one additional method: long IntlCodePointIterator::getLastCodePoint() which returns either -1 or the last code point we moved over, if any (and discounting any movement before the last call to IntlBreakIterator::first() or IntlBreakIterator::last()).
* Remove trailing spaceGustavo André dos Santos Lopes2012-06-101-35/+35
|
* Replaced zend_parse_method_params with plain zppGustavo André dos Santos Lopes2012-06-101-20/+22
|
* BreakIter: Removed getAvailableLocales/getHashCodeGustavo André dos Santos Lopes2012-06-101-21/+0
|
* BreakIterator and RuleBasedBreakiterator addedGustavo André dos Santos Lopes2012-06-041-0/+442
This commit adds wrappers for the classes BreakIterator and RuleBasedbreakIterator. The C++ ICU classes are described here: <http://icu-project.org/apiref/icu4c/classBreakIterator.html> <http://icu-project.org/apiref/icu4c/classRuleBasedBreakIterator.html> Additionally, a tutorial is available at: <http://userguide.icu-project.org/boundaryanalysis> This implementation wraps UTF-8 text in a UText. The text is iterated without any copying or conversion to UTF-16. There is also no validation that the input is actually UTF-8; where there are malformed sequences, the UText will simply U+FFFD. The class BreakIterator cannot be instantiated directly (has a private constructor). It provides the interface exposed by the ICU abstract class with the same name. The PHP class is not abstract because we may use it to wrap native subclasses of BreakIterator that we don't know how to wrap. This class includes methods to move the iterator position to the beginning (first()), to the end (last()), forward (next()), backwards (previous()), to the boundary preceding a certain position (preceding()) and following a certain position (following()) and to obtain the current position (current()). next() can also be used to advance or recede an arbitrary number of positions. BreakIterator also exposes other native methods: getAvailableLocales(), getLocale() and factory methods to build several predefined types of BreakIterators: createWordInstance() for word boundaries, createCharacterInstance() for locale dependent notions of "characters", createSentenceInstance() for sentences, createLineInstance() and createTitleInstance() -- for title casing breaks. These factories currently return RuleBasedbreakIterators where the names of the rule sets are found in the ICU data, observing the passed locale (although the locale is taken into considering there are very few exceptions to the root rules). The clone and compare_object PHP object handlers are also implemented, though the comparison does not yield meaningful results when used with >, <, >= and <=. Note that BreakIterator is an iterator only in the sense of the first 'Iterator' in 'IteratorIterator', i.e., it does not implement the Iterator interface. The reason is that there is no sensible implementation for Iterator::key(). Using it for an ordinal of the current boundary is not feasible because we are allowed to move to any boundary at any time. It we were to determine the current ordinal when last() is called we'd have to traverse the whole input text to find out how many breaks there were before. Therefore, BreakIterator implements only Traversable. It can be wrapped in an IteratorIterator, but the usual warnings apply. Finally, I added a convenience method to BreakIterator: getPartsIterator(). This provides an IntlIterator, backed by the BreakIterator PHP object (i.e. moving the pointer or changing the text in BreakIterator affects the iterator and also moving the iterator affects the backing BreakIterator), which allows traversing the text between each boundary. This iterator uses the original text to retrieve the text between two positions, not the code points returned by the wrapping UText. Therefore, if the text includes invalid code unit sequences, these invalid sequences will be in the output of this iterator, not U+FFFD code points. The class RuleBasedIterator exposes a constructor that allows building an iterator from arbitrary compiled or non-compiled rules. The form of these rules in described in the tutorial linked above. The rest of the methods allow retrieving the rules -- getRules() and getCompiledRules() --, a hash code of the rule set (hashCode()) and the rules statuses (getRuleStatus() and getRuleStatusVec()). Because the RuleBasedBreakIterator constructor may return parse errors, I reuse the UParseError to text function that was in the transliterator files. Therefore, I move that function to intl_error.c. common_enum.cpp was also changed, mainly to expose previously static functions. This avoided code duplication when implementing the BreakIterator iterator and the IntlIterator returned by BreakIterator::getPartsIterator().