Open parrot opened 15 years ago
29445 byte attachment from bsdz at http://trac.parrot.org/parrot/raw-attachment/ticket/508/json.patch
--- compilers/json/JSON.pir (revision 37749) +++ compilers/json/JSON.pir (working copy) @@ -1,82 +0,0 @@
-Given a valid JSON string, the compiler will return a PMC containing the
-Will create a pmc that C
-For more information about the structure of the JSON representation, see the
-.sub '__onload' :load
-.sub '__compiler'
-# Local Variables: -# mode: pir -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4 ft=pir:
Property changes on: compilers\json\JSONReader.pir
Added: svn:mergeinfo Merged /branches/RELEASE_0_8_2/compilers/json/JSON.pir:r34004-34020 Merged /branches/removing_stm/compilers/json/JSON.pir:r35464-35502 Merged /branches/assert_args/compilers/json/JSON.pir:r34776-34857 Merged /branches/jit_h_files/compilers/json/JSON.pir:r34166-35215
--- compilers/json/postalcodes.pir (revision 37749) +++ compilers/json/postalcodes.pir (working copy) @@ -68,7 +68,7 @@ $I0 = index json_result, "\r\n\r\n" substr json_result, 0, $I0, ""
--- compilers/json/test.pir (revision 37749) +++ compilers/json/test.pir (working copy) @@ -9,7 +9,7 @@
load_bytecode 'PGE.pbc' load_bytecode 'PGE/Util.pbc'
load_bytecode 'library/JSONReader.pbc'
.local pmc JSON JSON = compreg "JSON"
--- config/gen/makefiles/json.in (revision 37749) +++ config/gen/makefiles/json.in (working copy) @@ -9,15 +9,17 @@ PGE_DIR := ../../compilers/pge TGE_DIR := ../../compilers/tge
+PARROT_LIBRARY := ../../runtime/parrot/library +
-all: JSON.pbc +all: $(PARROT_LIBRARY)/JSONReader.pbc
help: @echo "" @echo "Following targets are available for the user:" @echo ""
-JSON.pbc : JSON/grammar.pbc JSON/pge2pir.pbc JSON.pir
$(PARROT) --output=$(PARROT_LIBRARY)/JSONReader.pbc JSONReader.pir
JSON/grammar.pbc : JSON/grammar.pir $(PARROT) --output=JSON/grammar.pbc JSON/grammar.pir @@ -52,7 +54,7 @@ $(PARROT) $(TGE_DIR)/tgc.pir --output=JSON/pge2pir.pir JSON/pge2pir.tg
clean : testclean
$(RMF) "JSON/.pbc" "JSON/_.pir" $(PARROT_LIBRARY)/JSONReader.pbc
--- config/gen/makefiles/root.in (revision 37749) +++ config/gen/makefiles/root.in (working copy) @@ -249,7 +249,7 @@ $(LIBRARY_DIR)/dumper.pbc \ $(LIBRARY_DIR)/yaml_dumper.pbc \ $(LIBRARY_DIR)/Getopt/Obj.pbc \
--- ports/cygwin/README (revision 37749) +++ ports/cygwin/README (working copy) @@ -147,7 +147,7 @@ /usr/lib/parrot/1.0.0/library/Getopt/Obj.pir /usr/lib/parrot/1.0.0/library/HTTP/Daemon.pir /usr/lib/parrot/1.0.0/library/Iter.pir
/usr/lib/parrot/1.0.0/library/JSONWriter.pir /usr/lib/parrot/1.0.0/library/libpcre.pir /usr/lib/parrot/1.0.0/library/Math/Rand.pbc /usr/lib/parrot/1.0.0/library/Math/Rand.pir
--- runtime/parrot/library/Config/JSON.pir (revision 37749) +++ runtime/parrot/library/Config/JSON.pir (working copy) @@ -33,7 +33,7 @@ text = fh.'readall'()
load_bytecode 'library/JSONReader.pbc'
.local pmc JSON, config JSON = compreg "JSON" @@ -77,7 +77,7 @@ close $P1
.end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir'
--- runtime/parrot/library/JSON.pir (revision 37749) +++ runtime/parrot/library/JSON.pir (working copy) @@ -1,376 +0,0 @@
-Convert a PMC to a JSON-serialized string. Note: If you pass in a cyclic
-Optional. Boolean: If true, then the generated string will be very -readable for humans. Defaults to false, which will generate the
-.sub _json
-done_init:
-.sub _json_any
-done_init:
-json_null:
-.sub '_json_null'
-plain:
-.sub '_json_string'
-plain:
-.sub '_json_boolean'
-plain:
-.sub '_json_number'
-plain:
-.sub '_json_array'
-pre_loop:
-loop:
-done_loop:
-indent1:
-done:
-.sub '_json_hash'
-iter_loop:
-done_iter:
-pre_loop:
-loop:
-space_loop:
-space_loop_done:
-done_loop:
-indent1:
-done:
--- runtime/parrot/library/JSONWriter.pir (revision 37749) +++ runtime/parrot/library/JSONWriter.pir (working copy) @@ -1,15 +1,15 @@ =head1 TITLE
-JSON.pir - PIR implementation of JSON data interchange format. +JSONWriter.pir - PIR implementation of JSON data interchange format.
=head1 SYNOPSIS
Use the C<_json> method to generate a JSON representation of a PMC.
-To generate a PMC from a JSON string, see L<compilers/json/JSON.pir>. +To generate a PMC from a JSON string, see L<compilers/json/JSONReader.pir>.
=cut
Property changes on: runtime\parrot\library\JSONWriter.pir
Added: svn:mergeinfo Merged /branches/assert_args/runtime/parrot/library/JSON.pir:r34776-34857 Merged /branches/jit_h_files/runtime/parrot/library/JSON.pir:r34166-35215 Merged /branches/RELEASE_0_8_2/runtime/parrot/library/JSON.pir:r34004-34020 Merged /branches/removing_stm/runtime/parrot/library/JSON.pir:r35464-35502
--- t/compilers/json/from_parrot.t (revision 37749) +++ t/compilers/json/from_parrot.t (working copy) @@ -33,7 +33,7 @@ $S0 = _json( s, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE "" OUT @@ -48,7 +48,7 @@ $S0 = json( s, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE "abcdeABCDE01234$%^&" OUT @@ -63,7 +63,7 @@ $S0 = json( s, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE "abcde\ABCDE\"01234\n$%^&" OUT @@ -89,7 +89,7 @@ $S0 = _json( i, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE 0 35 @@ -116,7 +116,7 @@ $S0 = _json( n ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE 0 2.5 @@ -143,7 +143,7 @@ $S0 = _json( n, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE "abcde\ABCDE\"01234\n$%^&*" -42 @@ -172,7 +172,7 @@ $S0 = _json( array, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE [0,1,2,3,4,5,6,7,8,9] OUT @@ -199,7 +199,7 @@ $S0 = _json( array, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE [ 0, @@ -233,7 +233,7 @@ $S0 = _json( array, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE [ 35, @@ -263,7 +263,7 @@ $S0 = _json( array, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE [ 0, @@ -290,7 +290,7 @@ $S0 = _json( hash, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE { "alpha" : 29, @@ -315,7 +315,7 @@ $S0 = _json( hash, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE {"alpha":29,"beta":"B","delta":"DELTA","gamma":3.1} OUT @@ -352,7 +352,7 @@ $S0 = _json( world, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE { "population" : 1234567890, @@ -403,7 +403,7 @@ $S0 = _json( world, 0 ) say $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE {"population":1234567890,"some_country":[[{"Perl":"Highway","Python":"Grove","Ruby":"Lane"},{}],[]]} OUT @@ -428,7 +428,7 @@ $S0 = _json( s, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE "" "" @@ -456,7 +456,7 @@ $S0 = _json( i, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE 0 0 @@ -484,7 +484,7 @@ $S0 = _json( b, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE false false @@ -510,7 +510,7 @@ $S0 = _json( n, 1 ) print $S0 .end -.include 'library/JSON.pir' +.include 'library/JSONWriter.pir' CODE null null
--- t/compilers/json/to_parrot.t (revision 37749) +++ t/compilers/json/to_parrot.t (working copy) @@ -689,7 +689,7 @@ return pir_output_is( <<"END_PIR", $dumped, $reason, %args );
.sub test :main
load_bytecode 'library/JSONReader.pbc' load_bytecode 'library/dumper.pbc'
.local pmc JSON, result @@ -710,7 +710,7 @@ return pir_error_output_like( <<"END_PIR", qr/not a valid JSON value/, $reason, %args );
.sub test :main
load_bytecode 'library/JSONReader.pbc'
.local pmc JSON, result JSON = compreg "JSON"
--- t/library/mime_base64.t (revision 37749) +++ t/library/mime_base64.t (working copy) @@ -24,7 +24,7 @@ load_bytecode 'MIME/Base64.pir' load_bytecode 'PGE.pbc' load_bytecode 'PGE/Util.pbc'
load_bytecode 'library/JSONReader.pbc'
.local pmc plan, is, ok plan = get_hll_global [ 'Test'; 'More' ], 'plan'
Trac commenter: bsdz
<p>
Patch to rename to JSONReader and JSONWriter
Rather than putting in deprecation stubs, we'll just enter a deprecation notice now for the old library names (done in 37768) and make the change in 1.5.
For consistency and clarity, let's move these to library/JSON/Reader.pbc, library/JSON/Writer.pbc and library/JSON/Config.pbc. (With the class names ['JSON'; 'Reader'] etc).
compilers/json is gone, use data_json instead.
So, resolving ticket.
Original issue still not resolved.
Is this something we still want to work on? If so, we're probably going to need an updated patch.
There are three JSON.pbc files currently:-
The supplied patch renames the purely read/write ones to library/JSONReader.pbc and library/JSONWriter.pbc.
However, what this patch misses is leaving a stub PBCs to manage a proper deprecation cycle.
Originally http://trac.parrot.org/parrot/ticket/508 by bsdz