Tom Alexander
648ae5dfdb
Turns out I was wrong, the @size helper attempts to cast to a number regardless of the input and it uses that. Fixed the test.
2020-06-14 15:20:54 -04:00
Tom Alexander
e70f397545
First attempt at fixing by reading all indirect references containing a reference to a single value as the original value is a failure. Turns out the @size helper treats numeric types in indirect references differently.
2020-06-14 14:51:31 -04:00
Tom Alexander
a6c22417e5
Implement Sizable for both OwnedLiterals and serde_json.
2020-06-14 13:06:03 -04:00
Tom Alexander
1a54e35736
Add tests and a Sizable trait for ContextElement.
2020-06-14 12:54:03 -04:00
Tom Alexander
cdd10576e8
Wire up serde_json for the math functions.
2020-06-13 22:55:38 -04:00
Tom Alexander
431b34dac7
Wired up the OwnedLiterals to the math functions.
2020-06-13 22:52:07 -04:00
Tom Alexander
d8b8c223f0
Add stubs for the math functions.
2020-06-13 22:12:00 -04:00
Tom Alexander
2c5c2d239c
Add a special case to not render anything if the method parameter to the math helper is a template to match the official DustJS implementation.
2020-06-13 22:03:48 -04:00
Tom Alexander
b897656cef
Fix all of the math test except for block template-based methods.
2020-06-13 21:37:11 -04:00
Tom Alexander
d9f10290f5
Math helper nearly done, test almost passes.
2020-06-13 21:28:21 -04:00
Tom Alexander
28a4fea96f
Remove RValue from ParametersContext so I can re-use it for calculated values from math.
2020-06-13 21:13:16 -04:00
Tom Alexander
dcbf8e83f6
Implement number casting.
2020-06-13 19:55:40 -04:00
Tom Alexander
9eb70f436c
Starting a type casting trait
2020-06-13 19:39:31 -04:00
Tom Alexander
d6ad7c28f3
Move MathNumber into the library.
...
While this will be used for the OwnedLiterals since they must always exhibit the original DustJS behavior, I am going to keep exposing separate math functions for ContextElement instead of simply requiring them to implement Into<MathNumber> since people might want to implement math in unusual ways with unusual types.
2020-06-13 19:13:02 -04:00
Tom Alexander
df0ae05648
Start of implementation for serde_json but I'm going to change my approach.
...
The permutations are pretty intense, so I think I'm going to do the same design I did for comparison where I have a JsonNumber (but I'll call this one MathNumber and rename JsonNumber to ComparisonNumber), convert the types to that, and then do the math.
2020-06-13 18:34:13 -04:00
Tom Alexander
db11677b22
Implement addition for OwnedLiterals.
2020-06-13 17:50:22 -04:00
Tom Alexander
d99aa44d8e
Add support for negative integers.
2020-06-13 16:06:31 -04:00
Tom Alexander
978bbe6eb3
Implemented float literals for OwnedLiterals, not yet for serde_json.
2020-06-13 13:37:26 -04:00
Tom Alexander
f2740987ec
Add a parent to ParametersContext so we can chain parameters contexts for use with the select helper.
2020-06-07 17:56:51 -04:00
Tom Alexander
d06fbea288
Remove unused code and clean up warnings.
2020-06-07 13:27:57 -04:00
Tom Alexander
b1a85165b0
All tests passing!
2020-06-07 01:04:00 -04:00
Tom Alexander
8cbb31251c
port over the equals/not equals helpers.
2020-06-07 00:03:51 -04:00
Tom Alexander
71592a9a32
Switching back to a Vec because inserting multiple elements into the linked list structure while maintaining ownership of each node proved to be difficult.
2020-06-06 22:24:27 -04:00
Tom Alexander
77b842f8de
Implement IntoContextElement for ParametersContext.
2020-06-06 20:48:29 -04:00
Tom Alexander
02259b9bd6
Create from_borrowed and from_owned constructors for IceResult and BreadcrumbTreeElement.
...
In an effort to keep track of how often memory is getting heap allocated, I am implementing constructors for IceResult and BreadcrumbTreeElement. This should limit the places that I call Rc::new and allow me to place tracing code into it later to ensure all code paths doing heap allocation make sense.
2020-06-06 20:24:01 -04:00
Tom Alexander
3c15e35b67
Finished constructor for ParametersContext.
2020-06-06 20:02:50 -04:00
Tom Alexander
ed7d80de6c
Handling RVPath for ParametersContext constructor.
2020-06-06 19:57:33 -04:00
Tom Alexander
f9dea70d23
Implement conversion from IceResult into BreadcrumbTreeNode.
...
I believe this change will remove an extra heap allocation I was doing in the new_breadcrumbs_* functions for the explicit context by adding support for converting from Rc<dyn ContextElement> to Rc<dyn IntoContextElement> without copying the underlying data. This should allow conversion of the IceResult::Owned variant to the BreadcrumbTreeElement::Owned variant without extra copying.
2020-06-06 19:39:44 -04:00
Tom Alexander
7253c7d99e
Implement function to convert IceResult into a BreadcrumbTreeElement.
2020-06-06 18:37:35 -04:00
Tom Alexander
18c1687064
Starting the constructor for ParametersContext.
2020-06-06 18:15:11 -04:00
Tom Alexander
f4f309caad
Working implementation of into_context_element for RValue.
2020-06-06 18:10:30 -04:00
Tom Alexander
303f092c30
Running into lifetime issues again.
2020-05-31 23:47:20 -04:00
Tom Alexander
da15439946
Start of IceResult to return owned values from into_context_element.
2020-05-31 23:29:12 -04:00
Tom Alexander
7789e6245d
I need to be able to returned owned data from into_context_element.
2020-05-31 22:35:46 -04:00
Tom Alexander
064027e77b
Worked around a lifetime issue with into_context_element.
2020-05-31 22:31:05 -04:00
Tom Alexander
b74dc394a8
Switched to returning an Option for into_context_element().
2020-05-31 22:17:58 -04:00
Tom Alexander
3aaf7f9987
I think I need to make into_context_element return an Option.
...
The reason is, missing values for paths are not equal to null so I can't use an OwnedLiteral unless I create a special "walking failed" OwnedLiteral.
2020-05-31 22:06:12 -04:00
Tom Alexander
09e0b046a0
Copy over the implementation of ContextElement for OwnedLiteral which will be the result of calling IntoContextElement on RValues.
2020-05-31 21:59:24 -04:00
Tom Alexander
ff74d78fdb
Starting the new parameters context object.
2020-05-31 21:46:00 -04:00
Tom Alexander
a578b57f12
Switch the call for IntoContextElement back to a static integer so it compiles again.
2020-05-31 13:21:47 -04:00
Tom Alexander
21b9e9282b
Ran into issue: Can't returned owned data when its expecting a trait object.
2020-05-30 18:28:33 -04:00
Tom Alexander
737c98d8b7
Add the renderer to calls to convert to a context element.
2020-05-30 18:16:58 -04:00
Tom Alexander
917da5a073
Put IntoContextElement everywhere. It compiles again.
2020-05-30 17:50:27 -04:00
Tom Alexander
975ab278ef
Starting an IntoContextElement trait to allow for delayed evaluation.
2020-05-30 16:34:32 -04:00
Tom Alexander
3c9a369908
Skipping over pseudo contexts has fixed most of the tests.
2020-05-30 11:50:55 -04:00
Tom Alexander
966499db76
Switch the get_loop_elements implementation to only return populated arrays when its an array-like object.
2020-05-24 16:27:13 -04:00
Tom Alexander
59ee4f508f
Add a new trait to ContextElement for Truthiness.
...
Before I was relying on Loopable to both determine truthiness and get a list of elements to loop over. This will no longer work since I need to only set $idx and $len when iterating over actual arrays, as opposed to all truthy values, so I've finally made truthiness explicit.
2020-05-24 16:16:43 -04:00
Tom Alexander
39c579171b
Rename the new functions to replace the old functions.
2020-05-24 15:21:30 -04:00
Tom Alexander
4790ac77d6
Initial implementation combining owned_walk_path and walk_path. Works everywhere except one spot.
2020-05-24 14:56:09 -04:00
Tom Alexander
03a8328148
Fix the equality test.
2020-05-16 23:19:02 -04:00