1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-19 19:55:30 +08:00
Commit Graph

26 Commits

Author SHA1 Message Date
Steven Hartland
026a1d9a9c
chore: lint and naming refactor (#475)
Enable more linters, address the issues and do a major naming refactor
to use golang lower camelCase identifiers for types, functions, methods
and variable names.

Also: 
* Clean up inline generation so it doesn't rely on temporary variables.
* Remove unused functions generated by inline.pl.
2022-12-04 21:49:38 +00:00
Steven Hartland
ad8875609a
feat: use exported methods when setting go values (#469)
When putting JavaScript objects into _go*object use exported values.
This reverts PR #467 in favour of this more complete work.

Fixes #118 #252

Co-authored-by: Dmitry Panov <dop@itoolabs.com>
2022-11-28 20:58:40 +00:00
Jens Alfke
09fc211e5a
feat: implement MarshalJSON for Value and Object (#437)
Value and Object now conform to the json.Marshaler interface and produce the
correct JSON when passed (directly or indirectly) to json.Marshal().

Before, both types would marshal as "{}" because they're structs with no public
fields.

This fixes some nasty problems marshaling object trees that mix Go and JS
collections. This can happen when you pass a Go collection into a JS function,
which modifies it adding JS values; and then back in Go you marshal the
collection to JSON. Before this commit the JS values would marshal to "{}".
(The new unit test TestNestedJSONMarshaling demonstrates this.)

Fixes #262
2022-10-11 18:56:42 +01:00
Douglas Thrift
12a6322603
fix: export when an array has multiple types (#387)
Fix a panic in value export when an array has multiple types of arrays.

This takes into account the types of elements in sub arrays, slices, etc.

Fixes #279
Fixes #377
2021-10-04 14:44:30 +01:00
Steven Hartland
9297a9abe4
feat: add github action tests and linting (#418)
Leverage github actions for tests and linting.

This includes fixing a bunch of issues highlighted by golangci
including:
* Dead code.
* Ineffectual assigns.
* Goto warnings.
* Nil return err.
* Reused literal strings.
* Test parameter order.

Also:
* Setup clog.
2021-09-27 16:19:28 +01:00
Steven Hartland
209b1fb8e8
Revert "feat: support null value returns for toValue (#325)" (#417)
This reverts commit 26cb6ccce6.
2021-09-27 12:00:52 +01:00
Ryan
26cb6ccce6
feat: support null value returns for toValue (#325)
Add nullValue as the return value for the nil case in toValue.

Co-authored-by: Ryan Macleod <ryan.macleod@cumul8.com>
2021-09-27 11:47:21 +01:00
Simon Stone
7a965dd45d Handle []uint16 to boolean conversion (resolves #232) 2016-11-24 16:28:05 +00:00
deoxxa
da054efc5f fixes #165 - crash exporting an array with undefined as the first element 2016-04-04 00:25:24 +10:00
Robert Krimen
7597815bd0 Fix toReflectValue(0) => float32
This fixes #123
2015-05-07 22:53:02 -07:00
Robert Krimen
709a0aa7ff Value.string(), .float64(), .bool(), etc. 2014-06-06 21:29:40 -07:00
Robert Krimen
918abeb8d8 The zero value of Value is now defined to be undefined
Previously, it was a publically accessible but invalid value (valueEmpty).

* Deprecate internal use of UndefinedValue(), NullValue(), FalseValue(), TrueValue()
* Guard against Empty, Result, Reference values from escaping the package
2014-05-28 21:23:32 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Daniel Cannon
661a61c5a0 Fix toValue not properly converting type aliases
This fixes #61
2014-03-16 08:46:20 -07:00
Daniel Cannon
fd6b047e2b Updated toValue to properly handle nil pointers (dancannon)
Also, added test
2014-01-18 17:35:26 -08:00
Robert Krimen
091c371aea Change handling of undefined in .Export
This fixes #28
2013-06-22 16:33:41 +02:00
Robert Krimen
83c56dd73d Add Otto.Call 2013-05-19 19:03:05 -07:00
Robert Krimen
3c139264ef Handle ToValue(nil) 2013-05-19 17:43:08 -07:00
Robert Krimen
adf21d0208 No rush to change the interface of Value.Export() 2013-05-15 19:30:39 -07:00
Robert Krimen
faaed09553 Change Export() to have new interface and slightly different behavior 2013-05-15 19:04:39 -07:00
Robert Krimen
9184233705 Bundle terst dependency (github.com/robertkrimen/terst) 2013-04-15 10:20:34 -07:00
Robert Krimen
a8a7c323e8 Better testing for toUint16/32/Int32 2013-02-18 16:26:35 -08:00
Robert Krimen
bdaa00884d toU16/U32/I32 => toUint16/Uint32/Int32 2013-02-18 15:58:48 -08:00
Robert Krimen
20d2e8bba6 gofmt
Ugh.
2013-01-25 09:59:42 -08:00
Marty Schoch
5bac9a7a34 add Export capability to javascript Value
this allows you to export a javascript Value back
for use in go.  the result structure should be the
same as if you serialized to JSON in javascript
and then Unmarshal'd those bytes in go
2012-11-07 08:18:46 -05:00
Robert Krimen
4a8c7ffc00 Initial commit 2012-10-05 18:47:53 -07:00