Open Bug 1188991 Opened 10 years ago Updated 2 years ago

Rewrite nsCharSeparatedTokenizer on top of Tokenizer

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

Tracking Status
firefox42 --- affected

People

(Reporter: mayhemer, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

...or remove nsCharSeparatedTokenizer altogether and migrate usage to Tokenizer. Needs a careful check, however based on quick look into MXR less work will probably be to wrap Tokenizer in nsCharSeparatedTokenizer for the starter.
Assignee: honzab.moz → nobody
Blocks: 1189349

(In reply to Honza Bambas (:mayhemer) from comment #0)

...or remove nsCharSeparatedTokenizer altogether and migrate usage to
Tokenizer.

Needs a careful check, however based on quick look into MXR less work will
probably be to wrap Tokenizer in nsCharSeparatedTokenizer for the starter.

Hi I would like to work on this issue. Could you please guide me bit as to how to begin with this?
Thanks :)

Flags: needinfo?(honzab.moz)

An overview doc is here:
https://www.janbambas.cz/string-parsing-made-simple-with-mozillatokenizer/

Then read the header of the TokenizerBase class, it's a base template for char and wchar

Mainly understand the Next and Check methods usage. There are variants to Check* that will help you build a simple code.

Few good examples how you can use mozilla::Tokenizer are here:

Flags: needinfo?(honzab.moz)
Assignee: nobody → anjali.jha1903
Status: NEW → ASSIGNED

(In reply to Honza Bambas (:mayhemer) from comment #2)

An overview doc is here:
https://www.janbambas.cz/string-parsing-made-simple-with-mozillatokenizer/

Then read the header of the TokenizerBase class, it's a base template for char and wchar

Mainly understand the Next and Check methods usage. There are variants to Check* that will help you build a simple code.

Few good examples how you can use mozilla::Tokenizer are here:

Hi! I am trying to apply the approach of declaring aSource in the header so that it is available for all the functions. Something like this

template <typename DependentSubstringType, bool IsWhitespace(char16_t)>
class nsTCharSeparatedTokenizer {
  typedef typename DependentSubstringType::char_type CharType;
  typedef typename DependentSubstringType::substring_type SubstringType;
  const SubstringType& aSource;

 public:
  // Flags -- only one for now. If we need more, they should be defined to
  // be 1 << 1, 1 << 2, etc. (They're masks, and aFlags is a bitfield.)
  enum { SEPARATOR_OPTIONAL = 1 };

  nsTCharSeparatedTokenizer(aSource,
                            CharType aSeparatorChar, uint32_t aFlags = 0)
      : mIter(aSource.Data(), aSource.Length()),
        mEnd(aSource.Data() + aSource.Length(), aSource.Data(),
             aSource.Length()),
        mSeparatorChar(aSeparatorChar),
        mWhitespaceBeforeFirstToken(false),
        mWhitespaceAfterCurrentToken(false),
        mSeparatorAfterCurrentToken(false),
        mSeparatorOptional(aFlags & SEPARATOR_OPTIONAL) {
    mozilla::TTokenizer<CharType> t(aSource);
    // Skip initial whitespace
    while (t.CheckWhite()) {
      mWhitespaceBeforeFirstToken = true;
    }
  }

Does this sound okay?

I'll remove mIter and mEnd after I refactor the entire file. I just wanted to know if I am heading in the right direction

The bug assignee didn't login in Bugzilla in the last 7 months, so the assignee is being reset.

Assignee: anjali.jha1903 → nobody
Status: ASSIGNED → NEW
Severity: normal → S3

I would be interested in working on this. I have a long train ride coming up and am looking to make some open source contributions.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: