Skip to content

Commit

Permalink
Merge pull request #2193 from natalie-lang/string-byterindex
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m authored Jul 6, 2024
2 parents 3877bed + fd71f8b commit 29f62a1
Show file tree
Hide file tree
Showing 6 changed files with 423 additions and 16 deletions.
6 changes: 5 additions & 1 deletion include/natalie/regexp_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class RegexpObject : public Object {
return m_options & RegexOpts::IgnoreCase;
}

int search(Env *env, const StringObject *string_obj, int start, OnigRegion *region, OnigOptionType options);
long search(Env *env, const StringObject *string_obj, long start, OnigRegion *region, OnigOptionType options, bool reverse = false);

bool eq(Env *env, Value other) const {
assert_initialized(env);
Expand All @@ -163,6 +163,10 @@ class RegexpObject : public Object {
return this->send(env, "=~"_s, { env->global_get("$_"_s) });
}

bool is_fixed_encoding() const {
return m_options & RegexOpts::FixedEncoding;
}

bool has_match(Env *env, Value, Value);
Value initialize(Env *, Value, Value);
Value inspect(Env *env);
Expand Down
1 change: 1 addition & 0 deletions include/natalie/string_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class StringObject : public Object {
StringObject *successive_in_place(Env *);

Value byteindex(Env *, Value, Value = nullptr) const;
Value byterindex(Env *, Value, Value = nullptr) const;

Value index(Env *, Value, Value);
Value index(Env *, Value, size_t start);
Expand Down
1 change: 1 addition & 0 deletions lib/natalie/compiler/binding_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ def generate_name
gen.binding('String', 'b', 'StringObject', 'b', argc: 0, pass_env: true, pass_block: false, return_type: :Object)
gen.binding('String', 'bytes', 'StringObject', 'bytes', argc: 0, pass_env: true, pass_block: true, return_type: :Object)
gen.binding('String', 'byteindex', 'StringObject', 'byteindex', argc: 1..2, pass_env: true, pass_block: false, return_type: :Object)
gen.binding('String', 'byterindex', 'StringObject', 'byterindex', argc: 1..2, pass_env: true, pass_block: false, return_type: :Object)
gen.binding('String', 'byteslice', 'StringObject', 'byteslice', argc: 1..2, pass_env: true, pass_block: false, return_type: :Object)
gen.binding('String', 'bytesize', 'StringObject', 'bytesize', argc: 0, pass_env: false, pass_block: false, return_type: :size_t)
gen.binding('String', 'capitalize', 'StringObject', 'capitalize', argc: 0..2, pass_env: true, pass_block: false, return_type: :Object)
Expand Down
Loading

0 comments on commit 29f62a1

Please sign in to comment.