Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ohler55 committed Aug 16, 2023
1 parent a48eca9 commit c8428e2
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 40 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# CHANGELOG

## 3.16.0 - 2023-08-15 [unreleased]
## 3.16.0 - 2023-08-16

- Added the `flaot_format` option.
- Added the `float_format` option.

- Expanded the `max_nesting` option to allow integer values as well as
the previous boolean (true or nil).

- Skip nesting tests with Truffle Ruby in the json gem tests.

## 3.15.1 - 2023-07-30

- Add protection against some using `require 'oj/json`, an internal file.
Expand Down
18 changes: 0 additions & 18 deletions ext/oj/dump_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,30 +875,12 @@ void oj_dump_compat_val(VALUE obj, int depth, Out out, bool as_ok) {
// okay. That means a check for a collectable value is needed before
// raising.
if (out->opts->dump_opts.max_depth <= depth) {
#if 0
// When JSON.dump is called then an ArgumentError is expected and the
// limit is the depth inclusive. If JSON.generate is called then a
// NestingError is expected and the limit is inclusive. Worse than
// that there are unit tests for both.
if (CALLER_DUMP == out->caller) {
if (0 < out->argc) {
set_state_depth(*out->argv, depth);
}
rb_raise(rb_eArgError, "Too deeply nested.");
} else if (out->opts->dump_opts.max_depth < depth) {
if (0 < out->argc) {
set_state_depth(*out->argv, depth - 1);
}
raise_json_err("Too deeply nested", "NestingError");
}
#else
if (RUBY_T_ARRAY == type || RUBY_T_HASH == type) {
if (0 < out->argc) {
set_state_depth(*out->argv, depth);
}
raise_json_err("Too deeply nested", "NestingError");
}
#endif
}
if (0 < type && type <= RUBY_T_FIXNUM) {
DumpFunc f = compat_funcs[type];
Expand Down
2 changes: 0 additions & 2 deletions ext/oj/mimic_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ static VALUE mimic_dump(int argc, VALUE *argv, VALUE self) {

oj_out_init(&out);

out.caller = CALLER_DUMP;
copts.escape_mode = JXEsc;
copts.mode = CompatMode;

Expand Down Expand Up @@ -368,7 +367,6 @@ static VALUE mimic_generate_core(int argc, VALUE *argv, Options copts) {
oj_out_init(&out);

out.omit_nil = copts->dump_opts.omit_nil;
out.caller = CALLER_GENERATE;
// For obj.to_json or generate nan is not allowed but if called from dump
// it is.
copts->dump_opts.nan_dump = RaiseNan;
Expand Down
1 change: 0 additions & 1 deletion ext/oj/oj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,6 @@ static VALUE dump(int argc, VALUE *argv, VALUE self) {

arg.out->omit_nil = copts.dump_opts.omit_nil;
arg.out->omit_null_byte = copts.dump_opts.omit_null_byte;
arg.out->caller = CALLER_DUMP;

return rb_ensure(dump_body, (VALUE)&arg, dump_ensure, (VALUE)&arg);
}
Expand Down
8 changes: 0 additions & 8 deletions ext/oj/oj.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ typedef enum {
FILE_IO = 'f',
} StreamWriterType;

typedef enum {
CALLER_DUMP = 'd',
CALLER_TO_JSON = 't',
CALLER_GENERATE = 'g',
// Add the fast versions if necessary. Maybe unparse as well if needed.
} DumpCaller;

typedef struct _dumpOpts {
bool use;
char indent_str[16];
Expand Down Expand Up @@ -203,7 +196,6 @@ typedef struct _out {
bool omit_null_byte;
int argc;
VALUE *argv;
DumpCaller caller; // used for the mimic json only
ROptTable ropts;
} *Out;

Expand Down
1 change: 0 additions & 1 deletion ext/oj/rails.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,6 @@ static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *a
oj_out_init(&out);

out.omit_nil = copts.dump_opts.omit_nil;
out.caller = 0;
out.cur = out.buf;
out.circ_cnt = 0;
out.opts = &copts;
Expand Down
1 change: 0 additions & 1 deletion ext/oj/string_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void oj_str_writer_init(StrWriter sw, int buf_size) {
sw->out.depth = 0;
sw->out.argc = 0;
sw->out.argv = NULL;
sw->out.caller = 0;
sw->out.ropts = NULL;
sw->out.omit_nil = oj_default_options.dump_opts.omit_nil;
}
Expand Down
7 changes: 0 additions & 7 deletions notes
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
- skip_null_byte => omit_null_byte
- and move to dump parameters

- max_nesting
- JSON.dump([[]], n) - n = 2 ok, n = 1 fails
- generate is the same
- fast_generate is the same
- pretty_generate is the same
- [[]].to_json same


- stream writes
- dump.c:685
Expand Down

0 comments on commit c8428e2

Please sign in to comment.