Commit Graph

81 Commits

Author SHA1 Message Date
Joey
7bfd2e6e84 Move function items out of pyobject module 2019-03-15 21:27:11 -07:00
Joey
fa9e48a5b3 Take &mut VirtualMachine insteadof &PyContext 2019-03-14 21:43:19 -07:00
Joey
737ec12fa5 Rename PyValue::{required_type => class} 2019-03-14 20:08:41 -07:00
Adam Kelly
5b41cc4b0d Fix subclasses of string. (Fixes #130) 2019-03-14 09:06:29 +00:00
Joey Hain
5971fc3bd4 rename PyObjectPayload2 to PyValue 2019-03-10 13:48:51 -07:00
Joey Hain
45bc8c8f7a Move PyRef to pyobject module 2019-03-10 13:01:46 -07:00
Chylli
e38a82e540 add __doc__ to str 2019-03-10 22:39:22 +08:00
Joey Hain
e1d728e81f slice 2019-03-09 15:10:44 -08:00
Adrian Wielgosik
b81a0a16d8 Convert most remaining string methods to implicit args
Also support out-of-range start/end params for some functions.
2019-03-07 20:39:57 +01:00
Joey
4a000c424c Improvements to OptionalArg extractor 2019-03-06 19:53:03 -08:00
Joey Hain
c68dbcc1ab Improve readability of methods on PyRef<PyString>
- Introduce PyStringRef type alias
- Impl python methods on PyStringRef to allow receiver to just be `self`
2019-03-05 19:56:25 -08:00
Adrian Wielgosik
e4e8b135ef Convert a bunch of string methods to new-args-style.
Mostly skipped the ones dealing with ints.
2019-03-05 20:41:02 +01:00
Joey Hain
3478251d40 Merge remote-tracking branch 'origin/master' into joey/fun-with-functions
Conflicts:
      vm/src/lib.rs
      vm/src/pyobject.rs
      wasm/lib/src/vm_class.rs
2019-03-02 04:04:22 -08:00
coolreader18
f364ea5943 Fix a bunch of clippy lints 2019-03-01 18:41:45 -06:00
Joey Hain
713edc57ee Convert some objstring methods to new style. 2019-02-27 19:53:31 -08:00
Joey Hain
7f75e3ee8a Significant improvements to new function definition style
- PyRef<T> type for accepting references to payloads.
- Args<T> type for consuming remaining positional args
  (mirrors python `*args`).
- KwArgs<T> type for consuming remaining keyword args
  (mirrors python `*kwargs`).
- OptArg<T> type for consuming remaining keyword args
  (no python code equivalent, only possible in native functions like in cpython).
- PyIterable<T> for accepting an iterator over a sequence of Ts.
- Arity checking (but TypeError messages need work)
2019-02-27 19:53:20 -08:00
Joey Hain
f10fa6db44 Remove outer RefCell from PyObjectRef 2019-02-25 21:01:37 -08:00
Joey Hain
2919d7f520 Initial arg type checking 2019-02-23 19:27:22 -08:00
Joey
df76ffe116 Replace most relative imports with 2018-style crate 2019-02-20 08:50:53 -08:00
silmeth
0c626dd595 rename objstr::get_value_as_ref to objstr::borrow_value 2019-02-15 19:29:58 +01:00
janczer
89e947a04f Fix typos 2019-02-14 20:38:18 +01:00
silmeth
7b7aa13295 microoptimize print (lock stdout, borrow strings) 2019-02-12 22:25:46 +01:00
ZapAnton
206ccc55fb Fixed the len_without_is_empty clippy warning 2019-02-12 16:49:34 +03:00
ZapAnton
00cfa47f64 Fixed the should_implement_trait clippy warning 2019-02-12 16:35:28 +03:00
ZapAnton
56e2d4c495 Fixed into_iter_on_ref clippy warning 2019-02-11 15:24:51 +03:00
ZapAnton
c8d619c123 Fixed useless_let_if_seq clippy warnings 2019-02-11 15:24:13 +03:00
janczer
aac1ce4e07 Fix the str.{__lt__, __gt__} and add the methods str.{__le__, __ge__} 2019-02-10 16:40:09 +01:00
klemens
b109ea954a Merge branch 'master' into spelling 2019-02-09 12:03:08 +01:00
klemens
79a7e5e42b spelling fixes 2019-02-09 12:00:46 +01:00
ben
7abf02180a implement slice negative step handling 2019-02-09 15:48:07 +13:00
ben
907dfb6770 Add slice type and use BigInts in slice payload. 2019-02-09 12:07:04 +13:00
Windel Bouwman
3d2d04596c Merge pull request #343 from ZapAnton/fix_various_clippy
Fixed various small clippy warnings
2019-02-07 17:35:29 +01:00
Adam Kelly
fd344ec1e0 Remove unnecessary to_bigint().unwrap() everywhere. 2019-02-06 17:38:01 +00:00
ZapAnton
3464828499 Fixed various small clippy warnings 2019-02-06 13:24:24 +03:00
Homer McMillan
00ef668022 String is* methods return false on empty string #363 2019-02-06 03:15:03 -05:00
Windel Bouwman
aaf0eab530 Merge pull request #342 from ZapAnton/fix_collapsible_if
Fixed the 'collapsible_if' clippy warnings
2019-02-05 23:34:29 +01:00
Windel Bouwman
69e3571d0c Merge pull request #341 from ZapAnton/toplevel_ref_arg
Fixed the 'toplevel_ref_arg' clippy warning
2019-02-05 22:42:31 +01:00
Windel Bouwman
3fb0f32a87 Merge pull request #335 from ZapAnton/fix_ptr_arg
Fixed the 'ptr_arg' clippy warnings
2019-02-05 22:36:29 +01:00
Windel Bouwman
9d5a953c8a Merge pull request #337 from ZapAnton/fix_unneeded_field_pattern
Fixed the 'unneeded_field_pattern' clippy warnings
2019-02-05 22:34:31 +01:00
Windel Bouwman
835a55777b Merge pull request #334 from ZapAnton/fix_len_zero
Fixed the 'len_zero' clippy warnings
2019-02-05 22:31:54 +01:00
ZapAnton
b0cbb23b43 Fixed the 'collapsible_if' clippy warnings
Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
2019-02-05 21:49:07 +03:00
ZapAnton
0d3b218237 Fixed the 'toplevel_ref_arg' clippy warning
This replaces all the occurrences of the
'let ref var = another_var' with the
'let var = &another_var'

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
2019-02-05 21:45:56 +03:00
ZapAnton
526ed98d93 Fixed the 'needless_return' clippy warnings
This replaces all the occurrences of the 'return var;' at
the end of the functions with the 'var'.

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
2019-02-05 21:39:38 +03:00
ZapAnton
d445e3082a Fixed the 'unneeded_field_pattern' clippy warnings
This replaces all the occurrences of the Struct {field: _} with
the Struct { .. }.

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#unneeded_field_pattern
2019-02-05 21:37:41 +03:00
ZapAnton
1a6840280b Fixed the 'ptr_arg' clippy warnings
This replaces all the occurrences of &<dynamic collection><T>
with the &[T].

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
2019-02-05 21:22:16 +03:00
ZapAnton
6fb91ddfed Fixed the 'len_zero' clippy warnings
This replaces all the occurrences of the <collection>.len() == 0
with the <collection>.is_empty() and the occurrences of the
<collection>.len() > 0 with the !<collection>.is_empty()

Relevant clippy warning: https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
2019-02-05 20:54:49 +03:00
Windel Bouwman
676f60296d Merge pull request #330 from ichyo/string-len
Use the number of characters instead of bytes for str.__len__
2019-02-05 17:57:58 +01:00
ichyo
fc779c2e3a Use the number of characters instead of bytes for str.__len__ 2019-02-05 23:26:13 +09:00
Vladimir Karamyshev
ebbd3d9f22 Add error handling for objsequence and objstr index overflow 2019-02-05 10:17:43 +03:00
holygits
33a3ec8832 Handle unicode string slicing with graphemes 2019-02-04 15:40:30 +13:00