diff options
author | Charles Oliver Nutter <headius@headius.com> | 2023-02-06 10:28:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-06 10:28:18 -0500 |
commit | 104fbe9b56dacaa9c4d02e6da7b22ea8a513c14f (patch) | |
tree | ec9a622d4ed6739f5483777524a859f97b284613 /ext | |
parent | ccf3b071bf1ee9326ba6006c35dc54759ff46464 (diff) | |
parent | 5b5d9451d5776c31e5db4791553086ff731f6c0f (diff) | |
download | psych-104fbe9b56dacaa9c4d02e6da7b22ea8a513c14f.tar.gz |
Merge pull request #613 from headius/expose_load_settings
Expose load settings
Diffstat (limited to 'ext')
-rw-r--r-- | ext/java/org/jruby/ext/psych/PsychParser.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ext/java/org/jruby/ext/psych/PsychParser.java b/ext/java/org/jruby/ext/psych/PsychParser.java index 0975f46..07b8b02 100644 --- a/ext/java/org/jruby/ext/psych/PsychParser.java +++ b/ext/java/org/jruby/ext/psych/PsychParser.java @@ -34,6 +34,7 @@ import org.jcodings.specific.UTF8Encoding; import org.jcodings.unicode.UnicodeEncoding; import org.jruby.Ruby; import org.jruby.RubyArray; +import org.jruby.RubyBoolean; import org.jruby.RubyClass; import org.jruby.RubyEncoding; import org.jruby.RubyFixnum; @@ -514,6 +515,54 @@ public class PsychParser extends RubyObject { ); } + @JRubyMethod(name = "max_aliases_for_collections=") + public IRubyObject max_aliases_for_collections_set(IRubyObject max) { + loadSettingsBuilder.setMaxAliasesForCollections(max.convertToInteger().getIntValue()); + + return max; + } + + @JRubyMethod(name = "max_aliases_for_collections") + public IRubyObject max_aliases_for_collections(ThreadContext context) { + return context.runtime.newFixnum(buildSettings().getMaxAliasesForCollections()); + } + + @JRubyMethod(name = "allow_duplicate_keys=") + public IRubyObject allow_duplicate_keys_set(IRubyObject allow) { + loadSettingsBuilder.setAllowDuplicateKeys(allow.isTrue()); + + return allow; + } + + @JRubyMethod(name = "allow_duplicate_keys") + public IRubyObject allow_duplicate_keys(ThreadContext context) { + return RubyBoolean.newBoolean(context, buildSettings().getAllowDuplicateKeys()); + } + + @JRubyMethod(name = "allow_recursive_keys=") + public IRubyObject allow_recursive_keys_set(IRubyObject allow) { + loadSettingsBuilder.setAllowRecursiveKeys(allow.isTrue()); + + return allow; + } + + @JRubyMethod(name = "allow_recursive_keys") + public IRubyObject allow_recursive_keys(ThreadContext context) { + return RubyBoolean.newBoolean(context, buildSettings().getAllowRecursiveKeys()); + } + + @JRubyMethod(name = "code_point_limit=") + public IRubyObject code_point_limit_set(IRubyObject limit) { + loadSettingsBuilder.setCodePointLimit(limit.convertToInteger().getIntValue()); + + return limit; + } + + @JRubyMethod(name = "code_point_limit") + public IRubyObject code_point_limit(ThreadContext context) { + return context.runtime.newFixnum(buildSettings().getCodePointLimit()); + } + private LoadSettings buildSettings() { return loadSettingsBuilder.build(); } |