The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
.gitignore 02
AMF.xs 181279
Changes 303330
MANIFEST 03
META.json 054
META.yml 2424
Makefile.PL 1614
TODO 01
lib/Storable/AMF/Mapper.pm 105
lib/Storable/AMF.pm 175
lib/Storable/AMF0.pm 2618
lib/Storable/AMF3.pm 2014
t/00-compile.t 22
t/06-aux-utility.t 04
t/40-negative-freeze.t 210
t/55-store-etc-amf0.t 256
t/64-prefer-number.t 48
t/65-prefer-number3.t 411
t/74-amf-skip-bad.t 035
t/75-devel-api.t 043
20 files changed (This is a version diff) 611918
@@ -9,3 +9,5 @@ MYMETA.yml
 _build
 *.tar.gz
 [a-z].pl
+AMF.o
+MYMETA.json
@@ -22,6 +22,9 @@
 
 #ifndef inline /* don't like borgs definitions */ /* inline is keyword for STDC compiler  */
 #   if defined(__GNUC__) || defined(__cplusplus__) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
+#   	if defined(__APPLE__)
+#	    define inline 
+#	endif
 #   else
 #	if defined(WIN32) && defined(_MSV) /* Microsoft Compiler */
 #	    define inline _inline
@@ -30,6 +33,8 @@
 #	endif
 #   endif
 #endif /* inline  */
+/* Stupid FreeBSD compiler failed with plain inline */
+#define FREE_INLINE STATIC_INLINE
 
 #define MARKER3_UNDEF	  '\x00'
 #define MARKER3_NULL	  '\x01'
@@ -96,6 +101,7 @@
 #define OPT_JSON_BOOLEAN  64
 #define OPT_MAPPER        128
 #define OPT_TARG          256
+#define OPT_SKIP_BAD      512
 
 #define EXPERIMENT1
 
@@ -197,35 +203,35 @@ struct io_struct{
     bool reuse;
 };
 
-inline SV*  get_tmp_storage( pTHX_ SV *option );
-inline void destroy_tmp_storage( pTHX_ SV *self);
+FREE_INLINE SV*  get_tmp_storage( pTHX_ SV *option );
+FREE_INLINE void destroy_tmp_storage( pTHX_ SV *self);
 
 STATIC_INLINE SV * amf0_parse_one(pTHX_ struct io_struct * io);
 STATIC_INLINE SV * amf3_parse_one(pTHX_ struct io_struct * io);
-inline void io_in_destroy(pTHX_ struct io_struct * io, AV *);
-inline void io_out_cleanup(pTHX_ struct io_struct * io);
+FREE_INLINE void io_in_destroy(pTHX_ struct io_struct * io, AV *);
+FREE_INLINE void io_out_cleanup(pTHX_ struct io_struct * io);
 
-inline void io_test_eof(pTHX_ struct io_struct *io);
-inline void io_register_error(struct io_struct *io, int);
-inline void io_register_error_and_free(pTHX_ struct io_struct *io, int, void *);
-inline int
+FREE_INLINE void io_test_eof(pTHX_ struct io_struct *io);
+FREE_INLINE void io_register_error(struct io_struct *io, int);
+FREE_INLINE void io_register_error_and_free(pTHX_ struct io_struct *io, int, void *);
+FREE_INLINE int
 io_position(struct io_struct *io){
     return io->pos-io->ptr;
 }
 
-inline void
+FREE_INLINE void
 io_set_position(struct io_struct *io, int pos){
     io->pos = io->ptr + pos;
 }
 
-inline void 
+FREE_INLINE void 
 io_savepoint(pTHX_ struct io_struct *io, struct amf3_restore_point *p){
     p->offset_buffer = io_position(io);
     p->offset_object = av_len(io->arr_object);
     p->offset_trait  = av_len(io->arr_trait);
     p->offset_string = av_len(io->arr_string);
 }
-inline void
+FREE_INLINE void
 io_restorepoint(pTHX_ struct io_struct *io, struct amf3_restore_point *p){
     io_set_position(io, p->offset_buffer);	
     while(av_len(io->arr_object) > p->offset_object){
@@ -241,24 +247,24 @@ io_restorepoint(pTHX_ struct io_struct *io, struct amf3_restore_point *p){
 }
 
 
-inline void
+FREE_INLINE void
 io_move_backward(struct io_struct *io, int step){
     io->pos-= step;
 }
 
-inline void
+FREE_INLINE void
 io_move_forward(struct io_struct *io, int len){
     io->pos+=len;	
 }
 
-inline void
+FREE_INLINE void
 io_require(struct io_struct *io, int len){
     if (io->end - io->pos < len){
         io_register_error(io, ERR_EOF);
     }
 }
 
-inline void
+FREE_INLINE void
 io_reserve(pTHX_ struct io_struct *io, int len){
     if (io->end - io->pos< len){
         unsigned int ipos = io->pos - io->ptr;
@@ -274,12 +280,12 @@ io_reserve(pTHX_ struct io_struct *io, int len){
         io->end = io->ptr + SvLEN(io->sv_buffer);
     }
 }
-inline void io_register_error(struct io_struct *io, int errtype){
+FREE_INLINE void io_register_error(struct io_struct *io, int errtype){
     io->error_code = errtype;
     Siglongjmp(io->target_error, errtype);
 }
 
-inline void io_test_eof(pTHX_ struct io_struct *io){
+FREE_INLINE void io_test_eof(pTHX_ struct io_struct *io){
     if (io->pos!=io->end){
 	io_register_error( io, ERR_EOF );
     }
@@ -318,22 +324,21 @@ void io_format_error(pTHX_ struct io_struct *io ){
     }
 }
 
-inline void io_register_error_and_free(pTHX_ struct io_struct *io, int errtype, void *pointer){
+FREE_INLINE void io_register_error_and_free(pTHX_ struct io_struct *io, int errtype, void *pointer){
     if (pointer)
         sv_2mortal((SV*) pointer);
     Siglongjmp(io->target_error, errtype);
 }
-inline SV*  get_tmp_storage(pTHX_ SV* option){
+FREE_INLINE SV*  get_tmp_storage(pTHX_ SV* option){
     struct io_struct * io;
     SV *sv ;
-    AV *tmp;
     Newxz( io, 1, struct io_struct );
     sv = sv_newmortal();
     sv_setref_iv( sv, "Storable::AMF0::TemporaryStorage", PTR2IV( io ) );
 
-    tmp = io->arr_trait  = newAV();
-    tmp = io->arr_string = newAV();
-    tmp = io->arr_object = newAV();
+    io->arr_trait  = newAV();
+    io->arr_string = newAV();
+    io->arr_object = newAV();
 
     io->hv_object        = newHV();
     HvSHAREKEYS_off( io->hv_object );
@@ -356,7 +361,7 @@ inline SV*  get_tmp_storage(pTHX_ SV* option){
     }
     return sv;
 }
-inline void destroy_tmp_storage( pTHX_ SV *self ){
+FREE_INLINE void destroy_tmp_storage( pTHX_ SV *self ){
     if ( ! SvROK( self )) {
         croak( "Bad Storable::AMF0::TemporaryStorage" );
     }
@@ -369,26 +374,26 @@ inline void destroy_tmp_storage( pTHX_ SV *self ){
         SvREFCNT_dec( (SV *) io->hv_object );
         SvREFCNT_dec( (SV *) io->hv_string );
         SvREFCNT_dec( (SV *) io->hv_trait );
-        // SvREFCNT_dec( (SV *) io->sv_buffer );
+        /* SvREFCNT_dec( (SV *) io->sv_buffer ); */
         Safefree( io );  
     /*    fprintf( stderr, "Destroy\n"); */
     }
 }
-inline void io_in_cleanup(pTHX_ struct io_struct *io){
+FREE_INLINE void io_in_cleanup(pTHX_ struct io_struct *io){
     av_clear( io->arr_object );
     if ( AMF3_VERSION == io->final_version ){
         av_clear( io->arr_string );
         av_clear( io->arr_trait );
     };
 }
-inline void io_out_cleanup(pTHX_ struct io_struct *io){
+FREE_INLINE void io_out_cleanup(pTHX_ struct io_struct *io){
     hv_clear( io->hv_object );
     if ( AMF3_VERSION == io->version ){
         hv_clear( io->hv_string );
         hv_clear( io->hv_trait );
     };
 }
-inline void io_in_init(pTHX_ struct io_struct * io,  SV* data, int amf_version, SV * sv_option){
+FREE_INLINE void io_in_init(pTHX_ struct io_struct * io,  SV* data, int amf_version, SV * sv_option){
     struct io_struct *reuse_storage_ptr;
     bool  reuse_storage;
     /*    PerlInterpreter *my_perl = io->interpreter; */
@@ -464,7 +469,7 @@ inline void io_in_init(pTHX_ struct io_struct * io,  SV* data, int amf_version,
         }
     }
 }
-inline void io_in_destroy(pTHX_ struct io_struct * io, AV *a){
+FREE_INLINE void io_in_destroy(pTHX_ struct io_struct * io, AV *a){
     int i;
     SV **ref_item;
     int alen;
@@ -502,7 +507,7 @@ inline void io_in_destroy(pTHX_ struct io_struct * io, AV *a){
         }
     }
 }
-inline void io_out_init(pTHX_ struct io_struct *io, SV*sv_option, int amf_version){
+STATIC_INLINE void io_out_init(pTHX_ struct io_struct *io, SV*sv_option, int amf_version){
     SV *sbuffer;
     unsigned int ibuf_size ;
     unsigned int ibuf_step ;
@@ -612,17 +617,17 @@ inline void io_out_init(pTHX_ struct io_struct *io, SV*sv_option, int amf_versio
     
 }
 
-inline SV * io_buffer(struct io_struct *io){
+FREE_INLINE SV * io_buffer(struct io_struct *io){
     SvCUR_set(io->sv_buffer, io->pos - io->ptr);
     return io->sv_buffer;
 }
 
-inline double io_read_double(struct io_struct *io);
-inline unsigned char io_read_marker(struct io_struct * io);
-inline int io_read_u8(struct io_struct * io);
-inline int io_read_u16(struct io_struct * io);
-inline int io_read_u32(struct io_struct * io);
-inline int io_read_u24(struct io_struct * io);
+FREE_INLINE double io_read_double(struct io_struct *io);
+FREE_INLINE unsigned char io_read_marker(struct io_struct * io);
+FREE_INLINE int io_read_u8(struct io_struct * io);
+FREE_INLINE int io_read_u16(struct io_struct * io);
+FREE_INLINE int io_read_u32(struct io_struct * io);
+FREE_INLINE int io_read_u24(struct io_struct * io);
 
 
 #define MOVERFLOW(VALUE, MAXVALUE, PROC)\
@@ -633,7 +638,7 @@ inline int io_read_u24(struct io_struct * io);
 
 
 
-inline void io_write_double(pTHX_ struct io_struct *io, double value){
+FREE_INLINE void io_write_double(pTHX_ struct io_struct *io, double value){
     const int step = 8;
     union {
         signed   int iv;
@@ -654,14 +659,14 @@ inline void io_write_double(pTHX_ struct io_struct *io, double value){
     io->pos+= step ;
     return;
 }
-inline void io_write_marker(pTHX_ struct io_struct * io, char value)	{
+FREE_INLINE void io_write_marker(pTHX_ struct io_struct * io, char value)	{
     const int step = 1;
     io_reserve(aTHX_  io, 1);
     io->pos[0]= value;
     io->pos+=step;
     return;
 }
-inline void io_write_uchar (pTHX_ struct io_struct * io, unsigned char value)	{
+FREE_INLINE void io_write_uchar (pTHX_ struct io_struct * io, unsigned char value)	{
     const int step = 1;
     io_reserve(aTHX_  io, 1);
     io->pos[0]= value;
@@ -669,7 +674,7 @@ inline void io_write_uchar (pTHX_ struct io_struct * io, unsigned char value)	{
     return;
 }
 
-inline void io_write_u8(pTHX_ struct io_struct * io, unsigned int value){
+FREE_INLINE void io_write_u8(pTHX_ struct io_struct * io, unsigned int value){
     const int step = 1;
     union {
         signed   int iv;
@@ -686,7 +691,7 @@ inline void io_write_u8(pTHX_ struct io_struct * io, unsigned int value){
 }
 
 
-inline void io_write_s16(pTHX_ struct io_struct * io, signed int value){
+FREE_INLINE void io_write_s16(pTHX_ struct io_struct * io, signed int value){
     const int step = 2;
     union {
         signed   int iv;
@@ -703,7 +708,7 @@ inline void io_write_s16(pTHX_ struct io_struct * io, signed int value){
     return;
 }
 
-inline void io_write_u16(pTHX_ struct io_struct * io, unsigned int value){
+FREE_INLINE void io_write_u16(pTHX_ struct io_struct * io, unsigned int value){
     const int step = 2;
     union {
         signed   int iv;
@@ -720,7 +725,7 @@ inline void io_write_u16(pTHX_ struct io_struct * io, unsigned int value){
     return;
 }
 
-inline void io_write_u32(pTHX_ struct io_struct * io, unsigned int value){
+FREE_INLINE void io_write_u32(pTHX_ struct io_struct * io, unsigned int value){
     const int step = 4;
     union {
         signed   int iv;
@@ -738,7 +743,7 @@ inline void io_write_u32(pTHX_ struct io_struct * io, unsigned int value){
     return;
 }
 
-inline void io_write_u24(pTHX_ struct io_struct * io, unsigned int value){
+FREE_INLINE void io_write_u24(pTHX_ struct io_struct * io, unsigned int value){
     const int step = 3;
     union {
         signed   int iv;
@@ -755,24 +760,24 @@ inline void io_write_u24(pTHX_ struct io_struct * io, unsigned int value){
     io->pos+=step;
     return;
 }
-inline void io_write_bytes(pTHX_ struct io_struct* io, const char * const buffer, int len){
+FREE_INLINE void io_write_bytes(pTHX_ struct io_struct* io, const char * const buffer, int len){
     io_reserve(aTHX_  io, len);
     Copy(buffer, io->pos, len, char);
     io->pos+=len;
 }	
 /* Date checking */
-inline bool   util_is_date(SV *one);
-inline double util_date_time(SV *one);
-
-inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one);
-inline void amf0_format_number(pTHX_ struct io_struct *io, SV * one);
-inline void amf0_format_string(pTHX_ struct io_struct *io, SV * one);
-inline void amf0_format_strict_array(pTHX_ struct io_struct *io, AV * one);
-inline void amf0_format_object(pTHX_ struct io_struct *io, HV * one);
-inline void amf0_format_null(pTHX_ struct io_struct *io);
-inline void amf0_format_typed_object(pTHX_ struct io_struct *io, HV * one);
-
-inline bool util_is_date(SV *one){
+FREE_INLINE bool   util_is_date(SV *one);
+FREE_INLINE double util_date_time(SV *one);
+
+STATIC_INLINE void amf0_format_one(pTHX_ struct io_struct *io, SV * one);
+STATIC_INLINE void amf0_format_number(pTHX_ struct io_struct *io, SV * one);
+STATIC_INLINE void amf0_format_string(pTHX_ struct io_struct *io, SV * one);
+STATIC_INLINE void amf0_format_strict_array(pTHX_ struct io_struct *io, AV * one);
+STATIC_INLINE void amf0_format_object(pTHX_ struct io_struct *io, HV * one);
+STATIC_INLINE void amf0_format_null(pTHX_ struct io_struct *io);
+STATIC_INLINE void amf0_format_typed_object(pTHX_ struct io_struct *io, HV * one);
+
+FREE_INLINE bool util_is_date(SV *one){
     if (SvNOKp(one)){
 	HV* stash = SvSTASH(one);
 	char *class_name = HvNAME(stash);
@@ -787,14 +792,14 @@ inline bool util_is_date(SV *one){
 	return 0;
     }
 }
-inline double util_date_time(SV *one){
+FREE_INLINE double util_date_time(SV *one){
     return (SvNVX(one)*1000);
 }
-inline void amf0_format_reference(pTHX_ struct io_struct * io, SV *ref){
+FREE_INLINE void amf0_format_reference(pTHX_ struct io_struct * io, SV *ref){
     io_write_marker(aTHX_  io, MARKER0_REFERENCE);
     io_write_u16(aTHX_  io, SvIV(ref));
 }
-inline void amf0_format_scalar_ref(pTHX_ struct io_struct * io, SV *ref){
+FREE_INLINE void amf0_format_scalar_ref(pTHX_ struct io_struct * io, SV *ref){
     const char *const reftype = "REFVAL";
     
     io_write_marker(aTHX_  io, MARKER0_TYPED_OBJECT);
@@ -811,16 +816,27 @@ inline void amf0_format_scalar_ref(pTHX_ struct io_struct * io, SV *ref){
     io_write_marker(aTHX_  io, MARKER0_OBJECT_END);
 }
 
-inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
+FREE_INLINE void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
+    SV *rv = 0;
+    bool is_perl_bool = 0;
     if (SvROK(one)){
+        rv = (SV*) SvRV(one);
 	if ( sv_isobject( one )){
-	    bool is_perl_bool = 0;
-	    if ( sv_isa(one, "boolean" )){
-		is_perl_bool  = 1;
-	    }
-	    if ( sv_isa(one, "JSON::XS::Boolean")){
-		is_perl_bool =  1;
-	    }
+            HV* stash = SvSTASH(rv);
+            char *class_name = HvNAME(stash);
+            if ( class_name[0] == 'J' ){
+                if ( sv_isa(one, "JSON::PP::Boolean")){
+                    is_perl_bool =  1;
+                }
+                else if ( sv_isa(one, "JSON::XS::Boolean") ){
+                    is_perl_bool =  1;
+                }
+            }
+            else if ( class_name[0] == 'b' ){
+                if ( sv_isa(one, "boolean" )){
+                    is_perl_bool  = 1;
+                }
+            }
 	    if ( is_perl_bool ){
 		io_write_marker(aTHX_ io, MARKER0_BOOLEAN );
 		/*  TODO SvTRUE can call die or something like */
@@ -830,8 +846,7 @@ inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
 	}
     }
 
-    if (SvROK(one)){
-        SV * rv = (SV*) SvRV(one);
+    if (rv){
         /*  test has stored */
         SV **OK = hv_fetch(io->hv_object, (char *)(&rv), sizeof (rv), 1);
         if (SvOK(*OK)) {
@@ -880,7 +895,11 @@ inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
 		}
 		else {		    
                     /* may be i has to format as undef */
-                    io_register_error(io, ERR_BAD_OBJECT);
+		    if ( io->options & OPT_SKIP_BAD ){
+			io_write_marker( aTHX_ io, MARKER0_UNDEFINED );
+		    }
+		    else 
+			io_register_error(io, ERR_BAD_OBJECT);
                 }
             }
             else if (SvTYPE(rv) == SVt_PVAV) 
@@ -893,7 +912,10 @@ inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
                 amf0_format_scalar_ref(aTHX_  io, (SV*) rv);
             }
             else {
-                io_register_error(io, ERR_BAD_OBJECT);
+		if ( io->options & OPT_SKIP_BAD ) 
+		    io_write_marker( aTHX_ io, MARKER0_UNDEFINED );
+		else
+		    io_register_error(io, ERR_BAD_OBJECT);
             }
         }
     }
@@ -913,9 +935,16 @@ inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
 		if (SvPOK(one)){
 		    amf0_format_string(aTHX_  io, one);
 		}
-		else {
+		else if ( SvNIOK(one) ){
 		    amf0_format_number(aTHX_  io, one);
 		}
+		else {
+		    if (io->options & OPT_SKIP_BAD ){
+			io_write_marker(aTHX_ io, MARKER0_UNDEFINED );
+		    }
+		    else 
+			io_register_error(io, ERR_BAD_OBJECT);
+		}
         }
         else {
             amf0_format_null(aTHX_  io);
@@ -923,12 +952,12 @@ inline void amf0_format_one(pTHX_ struct io_struct *io, SV * one){
     }
 }
 
-inline void amf0_format_number(pTHX_ struct io_struct *io, SV * one){
+FREE_INLINE void amf0_format_number(pTHX_ struct io_struct *io, SV * one){
 
     io_write_marker(aTHX_  io, MARKER0_NUMBER);
     io_write_double(aTHX_  io, SvNV(one));	
 }
-inline void amf0_format_string(pTHX_ struct io_struct *io, SV * one){
+FREE_INLINE void amf0_format_string(pTHX_ struct io_struct *io, SV * one){
 
     /* TODO: process long string */
     if (SvPOK(one)){
@@ -950,7 +979,7 @@ inline void amf0_format_string(pTHX_ struct io_struct *io, SV * one){
         amf0_format_null(aTHX_  io);
     }
 }
-inline void amf0_format_strict_array(pTHX_ struct io_struct *io, AV * one){
+FREE_INLINE void amf0_format_strict_array(pTHX_ struct io_struct *io, AV * one){
     int i, len;
     AV * one_array;
     one_array =  one;
@@ -968,31 +997,24 @@ inline void amf0_format_strict_array(pTHX_ struct io_struct *io, AV * one){
         }
     }
 }
-inline void amf0_format_object(pTHX_ struct io_struct *io, HV * one){
-    STRLEN key_len;
-    HV *hv;
-    HE *he;
+FREE_INLINE void amf0_format_object(pTHX_ struct io_struct *io, HV * one){
+    I32 key_len;
     SV * value;
-    char * key_str;
-    hv = one;
-    if (1) {
-        hv_iterinit(hv);
-        while( (he =  hv_iternext(hv))){
-            key_str = HePV(he, key_len);
-            value   = HeVAL(he);
-            io_write_u16(aTHX_  io, key_len);
-            io_write_bytes(aTHX_  io, key_str, key_len);
-            amf0_format_one(aTHX_  io, value);
-        }
+    char *key_str;
+    hv_iterinit(one);
+    while(( value = hv_iternextsv(one, &key_str, &key_len))){
+	io_write_u16(aTHX_  io, key_len);
+	io_write_bytes(aTHX_  io, key_str, key_len);
+	amf0_format_one(aTHX_  io, value);
     }
     io_write_u16(aTHX_  io, 0);
     io_write_marker(aTHX_  io, MARKER0_OBJECT_END);
 }
-inline void amf0_format_null(pTHX_ struct io_struct *io){
+FREE_INLINE void amf0_format_null(pTHX_ struct io_struct *io){
 
     io_write_marker(aTHX_  io, MARKER0_UNDEFINED);
 }
-inline void amf0_format_typed_object(pTHX_ struct io_struct *io,  HV * one){
+FREE_INLINE void amf0_format_typed_object(pTHX_ struct io_struct *io,  HV * one){
     HV* stash = SvSTASH(one);
     char *class_name = HvNAME(stash);
     io_write_marker(aTHX_  io, MARKER0_TYPED_OBJECT);
@@ -1018,16 +1040,18 @@ STATIC_INLINE SV* amf0_parse_recordset(pTHX_ struct io_struct *io);
 STATIC_INLINE SV* amf0_parse_xml_document(pTHX_ struct io_struct *io);
 STATIC_INLINE SV* amf0_parse_typed_object(pTHX_ struct io_struct *io);
 
-inline void io_write_double(pTHX_ struct io_struct *io, double value);
-inline void io_write_marker(pTHX_ struct io_struct * io, char value);
-inline void io_write_uchar (pTHX_ struct io_struct * io, unsigned char value);
-inline void io_write_u8(pTHX_ struct io_struct * io, unsigned int value);
-inline void io_write_s16(pTHX_ struct io_struct * io, signed int value);
-inline void io_write_u16(pTHX_ struct io_struct * io, unsigned int value);
-inline void io_write_u32(pTHX_ struct io_struct * io, unsigned int value);
-inline void io_write_u24(pTHX_ struct io_struct * io, unsigned int value);
-
-inline double io_read_double(struct io_struct *io){
+FREE_INLINE  void io_write_double(pTHX_ struct io_struct *io, double value);
+FREE_INLINE  void io_write_marker(pTHX_ struct io_struct * io, char value);
+FREE_INLINE  void io_write_uchar (pTHX_ struct io_struct * io, unsigned char value);
+FREE_INLINE  void io_write_u8(pTHX_ struct io_struct * io, unsigned int value);
+FREE_INLINE  void io_write_s16(pTHX_ struct io_struct * io, signed int value);
+FREE_INLINE  void io_write_u16(pTHX_ struct io_struct * io, unsigned int value);
+FREE_INLINE  void io_write_u32(pTHX_ struct io_struct * io, unsigned int value);
+FREE_INLINE  void io_write_u24(pTHX_ struct io_struct * io, unsigned int value);
+/*
+*/
+
+FREE_INLINE  double io_read_double(struct io_struct *io){
     const int step = sizeof(double);
     double a;
     unsigned char * ptr_in  = io->pos;
@@ -1044,20 +1068,20 @@ inline double io_read_double(struct io_struct *io){
     io->pos += step;
     return a;
 }
-inline char *io_read_bytes(struct io_struct *io, int len){
+FREE_INLINE  char *io_read_bytes(struct io_struct *io, int len){
     char * pos = ( char * )io->pos;
     io_require(io, len);
     io->pos+=len;
     return pos;
 }
-inline char *io_read_chars(struct io_struct *io, int len){
+FREE_INLINE  char *io_read_chars(struct io_struct *io, int len){
     char * pos = ( char * )io->pos;
     io_require(io, len);
     io->pos+=len;
     return pos;
 }
 
-inline unsigned char io_read_marker(struct io_struct * io){
+FREE_INLINE  unsigned char io_read_marker(struct io_struct * io){
     const int step = 1;
     unsigned char marker;
     io_require(io, step);
@@ -1065,7 +1089,7 @@ inline unsigned char io_read_marker(struct io_struct * io){
     io->pos++;
     return marker;
 }
-inline int io_read_u8(struct io_struct * io){
+FREE_INLINE  int io_read_u8(struct io_struct * io){
     const int step = 1;
     union{
         unsigned int x;
@@ -1077,7 +1101,7 @@ inline int io_read_u8(struct io_struct * io){
     io->pos+= step;
     return (int) str.x;
 }
-inline int io_read_s16(struct io_struct * io){
+FREE_INLINE  int io_read_s16(struct io_struct * io){
     const int step = 2;
     union{
         int x;
@@ -1090,7 +1114,7 @@ inline int io_read_s16(struct io_struct * io){
     io->pos+= step;
     return (int) str.x;
 }
-inline int io_read_u16(struct io_struct * io){
+FREE_INLINE  int io_read_u16(struct io_struct * io){
     const int step = 2;
     union{
         unsigned int x;
@@ -1103,7 +1127,7 @@ inline int io_read_u16(struct io_struct * io){
     io->pos+= step;
     return (int) str.x;
 }
-inline int io_read_u24(struct io_struct * io){
+FREE_INLINE  int io_read_u24(struct io_struct * io){
     const int step = 3;
     union{
         unsigned int x;
@@ -1117,7 +1141,7 @@ inline int io_read_u24(struct io_struct * io){
     io->pos+= step;
     return (int) str.x;
 }
-inline int io_read_u32(struct io_struct * io){
+FREE_INLINE  int io_read_u32(struct io_struct * io){
     const int step = 4;
     union{
         unsigned int x;
@@ -1132,7 +1156,7 @@ inline int io_read_u32(struct io_struct * io){
     io->pos+= step;
     return (int) str.x;
 }
-inline void amf3_write_integer(pTHX_ struct io_struct *io, IV ivalue){
+FREE_INLINE  void amf3_write_integer(pTHX_ struct io_struct *io, IV ivalue){
     UV value;
     if (ivalue<0){
 	if ( ivalue < -( 1 << 28) ){
@@ -1178,7 +1202,7 @@ inline void amf3_write_integer(pTHX_ struct io_struct *io, IV ivalue){
     return;
 }
 
-inline int amf3_read_integer(struct io_struct *io){
+FREE_INLINE int amf3_read_integer(struct io_struct *io){
     I32 value;
     io_require(io, 1);
     if ((U8) io->pos[0] > 0x7f) {
@@ -1231,19 +1255,17 @@ STATIC_INLINE SV * amf0_parse_object(pTHX_ struct io_struct * io){
     int len_next;
     char * key;
     SV * value;
-    int  obj_pos;
     SV *RETVALUE;
 
     obj =  newHV();
     RETVALUE = newRV_noinc( (SV *) obj );
     av_push(io->arr_object, RETVALUE);
-    obj_pos = av_len(io->arr_object);
     while(1){
         len_next = io_read_u16(io);
         if (len_next == 0) {
             char object_end;
             object_end= io_read_marker(io);
-            if ((object_end == MARKER0_OBJECT_END))
+            if ( MARKER0_OBJECT_END == object_end )
             {
                 if (io->options & OPT_STRICT){
                     if (SvREFCNT(RETVALUE) > 1)
@@ -1372,7 +1394,7 @@ STATIC_INLINE SV* amf0_parse_ecma_array(pTHX_ struct io_struct *io){
     fprintf( stderr, "Start parse array %d\n", array_len);
     fprintf( stderr, "position %d\n", io_position(io));
     #endif
-    if (0 <= array_len){
+    if (1){
         bool ok;
         UV index;
         key_len = io_read_u16(io);
@@ -1469,9 +1491,8 @@ STATIC_INLINE SV* amf0_parse_ecma_array(pTHX_ struct io_struct *io){
 STATIC_INLINE SV* amf0_parse_date(pTHX_ struct io_struct *io){
     SV* RETVALUE;
     double time;
-    int tz;
     time = io_read_double(io);
-    tz = io_read_s16(io);
+    (void)io_read_s16(io);
     if ( io->options & OPT_MILLSEC_DATE )
 	RETVALUE = newSVnv(time);
     else 
@@ -1507,7 +1528,7 @@ STATIC_INLINE SV* amf0_parse_xml_document(pTHX_ struct io_struct *io){
     av_push(io->arr_object, RETVALUE);
     return RETVALUE;
 }
-inline SV *parse_scalar_ref(pTHX_ struct io_struct *io){
+FREE_INLINE SV *parse_scalar_ref(pTHX_ struct io_struct *io){
         SV * obj;
         int obj_pos;
         int len_next;
@@ -1525,7 +1546,7 @@ inline SV *parse_scalar_ref(pTHX_ struct io_struct *io){
             if (len_next == 0) {
                 char object_end;
                 object_end= io_read_marker(io);
-                if ((object_end == MARKER0_OBJECT_END))
+                if (MARKER0_OBJECT_END == object_end)
                 {
                     SV* RETVALUE = *av_fetch(io->arr_object, obj_pos, 0);
                     if (!value)
@@ -1589,7 +1610,7 @@ STATIC_INLINE SV* amf0_parse_double(pTHX_ struct io_struct * io){
     return newSVnv(io_read_double(io));
 }
 
-inline SV*  util_boolean(pTHX_ struct io_struct *io, bool value){
+FREE_INLINE SV*  util_boolean(pTHX_ struct io_struct *io, bool value){
     if ( ! (io->options & OPT_JSON_BOOLEAN) ){
 	SV *sv = boolSV( value );
 	/* SvREFCNT_inc_simple_void_NN( sv ); */
@@ -1646,7 +1667,7 @@ STATIC_INLINE SV* parse_boolean(pTHX_ struct io_struct * io){
     return value;
 }
 */ 
-inline SV * amf3_parse_one(pTHX_ struct io_struct *io);
+FREE_INLINE SV * amf3_parse_one(pTHX_ struct io_struct *io);
 STATIC_INLINE SV * amf3_parse_undefined(pTHX_ struct io_struct *io){
     SV * RETVALUE;
     RETVALUE = newSV(0);
@@ -1678,7 +1699,7 @@ STATIC_INLINE SV * amf3_parse_double(pTHX_ struct io_struct *io){
     RETVALUE = newSVnv(io_read_double(io));
     return RETVALUE;
 }
-inline char * amf3_read_string(pTHX_ struct io_struct *io, int ref_len, STRLEN *str_len){
+FREE_INLINE char * amf3_read_string(pTHX_ struct io_struct *io, int ref_len, STRLEN *str_len){
 
     AV * arr_string = io->arr_string;
     if (ref_len & 1) {
@@ -1726,7 +1747,7 @@ STATIC_INLINE SV * amf3_parse_xml_doc(pTHX_ struct io_struct *io){
     RETVALUE = amf3_parse_xml(aTHX_  io);
     return RETVALUE;
 }
-inline SV * amf3_parse_date(pTHX_ struct io_struct *io){
+STATIC_INLINE SV * amf3_parse_date(pTHX_ struct io_struct *io){
     SV * RETVALUE;
     int i = amf3_read_integer(io);
     if (i&1){
@@ -1756,14 +1777,14 @@ inline SV * amf3_parse_date(pTHX_ struct io_struct *io){
 }
 
 
-inline void amf3_store_object(pTHX_ struct io_struct *io, SV * item){
+FREE_INLINE void amf3_store_object(pTHX_ struct io_struct *io, SV * item){
     av_push(io->arr_object, newRV_noinc(item));
 }
-inline void amf3_store_object_rv(pTHX_ struct io_struct *io, SV * item){
+FREE_INLINE void amf3_store_object_rv(pTHX_ struct io_struct *io, SV * item){
     av_push(io->arr_object, item);
 }
 
-inline SV * amf3_parse_array(pTHX_ struct io_struct *io){
+STATIC_INLINE SV * amf3_parse_array(pTHX_ struct io_struct *io){
     SV * RETVALUE;
     int ref_len = amf3_read_integer(io);
     if (ref_len & 1){
@@ -1778,8 +1799,6 @@ inline SV * amf3_parse_array(pTHX_ struct io_struct *io){
         int old_vlen;
         SV * item_value;
         UV item_index;
-        int obj_pos;
-
 
         AV * array;
         str_len = amf3_read_integer(io);
@@ -1795,7 +1814,6 @@ inline SV * amf3_parse_array(pTHX_ struct io_struct *io){
         RETVALUE = newRV_noinc(item);
 
         amf3_store_object_rv(aTHX_  io, RETVALUE);
-        obj_pos = av_len(io->arr_object); 
 
         recover = FALSE;
         if (str_len !=1){
@@ -1896,7 +1914,7 @@ struct amf3_trait_struct{
     SV* class_name;
     HV* stash;
 };
-inline SV * amf3_parse_object(pTHX_ struct io_struct *io){
+STATIC_INLINE SV * amf3_parse_object(pTHX_ struct io_struct *io){
     SV * RETVALUE;
     int obj_ref = amf3_read_integer(io);
     #ifdef TRACE0
@@ -2047,13 +2065,13 @@ STATIC_INLINE SV * amf3_parse_bytearray(pTHX_ struct io_struct *io){
     }
     return RETVALUE;
 }
-inline void amf3_format_date( pTHX_ struct io_struct *io, SV * one){
+FREE_INLINE void amf3_format_date( pTHX_ struct io_struct *io, SV * one){
     io_write_marker( aTHX_ io, MARKER3_DATE );
     amf3_write_integer( aTHX_ io, 1 );
     io_write_double( aTHX_ io, util_date_time( one ));
 }
-inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one);
-inline void amf3_format_integer(pTHX_ struct io_struct *io, SV *one){
+FREE_INLINE void amf3_format_one(pTHX_ struct io_struct *io, SV * one);
+FREE_INLINE void amf3_format_integer(pTHX_ struct io_struct *io, SV *one){
 
     IV i = SvIV(one);
     if (i <= 0xfffffff && i>= -(0x10000000)){
@@ -2066,20 +2084,20 @@ inline void amf3_format_integer(pTHX_ struct io_struct *io, SV *one){
     }
 }
 
-inline void amf3_format_double(pTHX_ struct io_struct * io, SV *one){
+FREE_INLINE void amf3_format_double(pTHX_ struct io_struct * io, SV *one){
 
     io_write_marker(aTHX_  io, MARKER3_DOUBLE);
     io_write_double(aTHX_  io, SvNV(one));
 }
 
-inline void amf3_format_undef(pTHX_ struct io_struct *io){
+FREE_INLINE void amf3_format_undef(pTHX_ struct io_struct *io){
     io_write_marker(aTHX_  io, MARKER3_UNDEF);
 }
-inline void amf3_format_null(pTHX_ struct io_struct *io){
+FREE_INLINE void amf3_format_null(pTHX_ struct io_struct *io){
     io_write_marker(aTHX_  io, MARKER3_NULL);
 }
 
-inline void amf3_write_string_pvn(pTHX_ struct io_struct *io, char *pstr, STRLEN plen){
+FREE_INLINE void amf3_write_string_pvn(pTHX_ struct io_struct *io, char *pstr, STRLEN plen){
     HV* rhv;
     SV ** hv_item;
 
@@ -2103,7 +2121,7 @@ inline void amf3_write_string_pvn(pTHX_ struct io_struct *io, char *pstr, STRLEN
     }
 }
 
-inline void amf3_format_string(pTHX_ struct io_struct *io, SV *one){
+FREE_INLINE void amf3_format_string(pTHX_ struct io_struct *io, SV *one){
     char *pstr;
     STRLEN plen;
     pstr = SvPV(one, plen);
@@ -2111,11 +2129,11 @@ inline void amf3_format_string(pTHX_ struct io_struct *io, SV *one){
     amf3_write_string_pvn(aTHX_  io, pstr, plen);
 }
 
-inline void amf3_format_reference(pTHX_ struct io_struct *io, SV *num){
+FREE_INLINE void amf3_format_reference(pTHX_ struct io_struct *io, SV *num){
     amf3_write_integer(aTHX_  io, SvIV(num)<<1);
 }
 
-inline void amf3_format_array(pTHX_ struct io_struct *io, AV * one){
+FREE_INLINE void amf3_format_array(pTHX_ struct io_struct *io, AV * one){
     int alen;
     int i;
     SV ** aitem;
@@ -2133,7 +2151,7 @@ inline void amf3_format_array(pTHX_ struct io_struct *io, AV * one){
         }
     }
 }
-inline void amf3_format_object(pTHX_ struct io_struct *io, SV * rone){
+FREE_INLINE void amf3_format_object(pTHX_ struct io_struct *io, SV * rone){
     AV * trait;
     SV ** rv_trait;
     char *class_name;
@@ -2203,16 +2221,27 @@ inline void amf3_format_object(pTHX_ struct io_struct *io, SV * rone){
     io_write_marker(aTHX_  io, STR_EMPTY); 
 }
 
-inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
+FREE_INLINE void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
+    SV *rv=0;
+    bool is_perl_bool = 0;
     if (SvROK(one)){
+        rv = (SV*) SvRV(one);
 	if ( sv_isobject( one )){
-	    bool is_perl_bool = 0;
-	    if ( sv_isa(one, "boolean" )){
-		is_perl_bool  = 1;
-	    }
-	    if ( sv_isa(one, "JSON::XS::Boolean")){
-		is_perl_bool =  1;
-	    }
+            HV* stash = SvSTASH(rv);
+            char *class_name = HvNAME(stash);
+            if ( class_name[0] == 'J' ){
+                if ( sv_isa(one, "JSON::PP::Boolean")){
+                    is_perl_bool =  1;
+                }
+                else if ( sv_isa(one, "JSON::XS::Boolean") ){
+                    is_perl_bool =  1;
+                }
+            }
+            else if ( class_name[0] == 'b' ){
+                if ( sv_isa(one, "boolean" )){
+                    is_perl_bool  = 1;
+                }
+            }
 	    if ( is_perl_bool ){
 		io_write_marker(aTHX_ io, (SvTRUE( SvRV( one )) ? MARKER3_TRUE : MARKER3_FALSE ) );
 		return ;
@@ -2220,8 +2249,7 @@ inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
 	}
     }
 
-    if (SvROK(one)){
-        SV * rv = (SV*) SvRV(one);
+    if (rv){
         /* test has stored */
         SV **OK = hv_fetch(io->hv_object, (char *)(&rv), sizeof (rv), 1);
         if (SvOK(*OK)) {
@@ -2238,7 +2266,12 @@ inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
 		amf3_format_reference(aTHX_  io, *OK);
 	    }
             else {
-                io_register_error(io, ERR_BAD_OBJECT);
+		if ( io->options & OPT_SKIP_BAD ){
+		    io_write_marker( aTHX_ io, MARKER3_UNDEF );
+		}
+		else {
+		    io_register_error(io, ERR_BAD_OBJECT);
+		}
             }
         }
         else {
@@ -2246,7 +2279,7 @@ inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
             (void) hv_store(io->hv_object, (char *) (&rv), sizeof (rv), newSViv(io->rc_object), 0);
             ++io->rc_object;
 
-	    if ( io->options && OPT_MAPPER ){
+	    if ( io->options & OPT_MAPPER ){
 		if ( sv_isobject( one ) ){
 		    
 		    GV *to_amf = gv_fetchmethod_autoload (SvSTASH (rv), "TO_AMF", 0);
@@ -2285,7 +2318,10 @@ inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
 		amf3_format_date(aTHX_ io, rv );
 	    }
             else {
-                io_register_error(io, ERR_BAD_OBJECT);
+		if ( io->options & OPT_SKIP_BAD )
+		    io_write_marker( aTHX_ io, MARKER3_UNDEF );
+		else 
+		    io_register_error(io, ERR_BAD_OBJECT);
             }
         }
     }
@@ -2317,7 +2353,10 @@ inline void amf3_format_one(pTHX_ struct io_struct *io, SV * one){
                 amf3_format_double(aTHX_  io, one);
             }
 	    else {
-		io_register_error(io, ERR_BAD_OBJECT );
+		if ( io->options & OPT_SKIP_BAD )
+		    io_write_marker( aTHX_ io, MARKER3_UNDEF );
+		else 
+		    io_register_error(io, ERR_BAD_OBJECT );
 	    }
         }
         else {
@@ -2364,7 +2403,7 @@ parse_sub amf3_parse_subs[] = {
     &amf3_parse_bytearray,
 };
 
-inline SV * amf3_parse_one(pTHX_ struct io_struct * io){
+FREE_INLINE SV * amf3_parse_one(pTHX_ struct io_struct * io){
     unsigned char marker;
 
     marker = (unsigned char) io_read_marker(io);
@@ -2376,8 +2415,7 @@ inline SV * amf3_parse_one(pTHX_ struct io_struct * io){
 	return 0; /* Never reach this statement */
     }
 }
-inline SV* amf0_parse_one_tmp( pTHX_ struct io_struct *io, SV * reuse ){
-    char marker;
+FREE_INLINE SV* amf0_parse_one_tmp( pTHX_ struct io_struct *io, SV * reuse ){
     SV * RETVALUE;
     HV * obj;
 
@@ -2387,7 +2425,6 @@ inline SV* amf0_parse_one_tmp( pTHX_ struct io_struct *io, SV * reuse ){
     int obj_pos;
 
     io_require( io, 1 );
-    marker = *(io->pos);
     RETVALUE = reuse;
 
     if ( MARKER0_OBJECT != MARKER0_OBJECT || ! SvROK( reuse ) ){
@@ -2409,7 +2446,7 @@ inline SV* amf0_parse_one_tmp( pTHX_ struct io_struct *io, SV * reuse ){
         if (len_next == 0) {
             char object_end;
             object_end= io_read_marker(io);
-            if ((object_end == MARKER0_OBJECT_END))
+            if (MARKER0_OBJECT_END == object_end)
             {
                 if (io->options & OPT_STRICT){
                     SV* RETVALUE = *av_fetch(io->arr_object, obj_pos, 0);
@@ -2449,8 +2486,8 @@ STATIC_INLINE SV * amf0_parse_one(pTHX_ struct io_struct * io){
         return io_register_error(io, ERR_MARKER),(SV *)0;
     }
 }
-inline SV * deep_clone(pTHX_ SV * value);
-inline AV * deep_array(pTHX_ AV* value){
+FREE_INLINE SV * deep_clone(pTHX_ SV * value);
+FREE_INLINE AV * deep_array(pTHX_ AV* value){
     AV* copy =  (AV*) newAV();
     int c_len;
     int i;
@@ -2461,7 +2498,7 @@ inline AV * deep_array(pTHX_ AV* value){
     return copy;
 }
 
-inline HV * deep_hash(pTHX_ HV* value){
+FREE_INLINE HV * deep_hash(pTHX_ HV* value){
     HV * copy =  (HV*) newHV();
     SV * key_value;
     char * key_str;
@@ -2476,11 +2513,11 @@ inline HV * deep_hash(pTHX_ HV* value){
     return copy;
 }
 
-inline SV * deep_scalar(pTHX_ SV * value){
+FREE_INLINE SV * deep_scalar(pTHX_ SV * value){
     return deep_clone(aTHX_  value);
 }
 
-inline SV * deep_clone(pTHX_ SV * value){
+FREE_INLINE SV * deep_clone(pTHX_ SV * value){
     if (SvROK(value)){
         SV * rv = (SV*) SvRV(value);
         SV * copy;
@@ -2514,7 +2551,7 @@ inline SV * deep_clone(pTHX_ SV * value){
         return copy;
     }
 }
-inline void ref_clear(pTHX_ HV * go_once, SV *sv){
+FREE_INLINE void ref_clear(pTHX_ HV * go_once, SV *sv){
 
     SV *ref_addr;
     if (! SvROK(sv))
@@ -2557,7 +2594,12 @@ inline void ref_clear(pTHX_ HV * go_once, SV *sv){
  */
 
 /* Temporary Intenale Storage */
+#define check_bounds(low,high, mess) \
+    if (items < low || items > high )\
+        croak_xs_usage( cv, mess );
+
 MODULE = Storable::AMF0 PACKAGE = Storable::AMF0::TemporaryStorage
+PROTOTYPES: DISABLE 
 
 void
 new(SV *class, SV *option=0)
@@ -2570,6 +2612,8 @@ DESTROY(SV *self)
     PPCODE:
     destroy_tmp_storage( aTHX_ self );
 
+PROTOTYPES: ENABLE
+
 MODULE = Storable::AMF0 PACKAGE = Storable::AMF0		
 
 void 
@@ -2587,23 +2631,38 @@ dclone(SV * data)
         XPUSHs(retvalue);
 
 void 
-amf_tmp_storage(SV *option = 0)
+amf_tmp_storage(...)
     INIT:
         SV * retvalue;
+        SV * sv_option;
+    PROTOTYPE: ;$
     PPCODE:
-        retvalue = get_tmp_storage(aTHX_ option);
+        if (items<0 || items > 1)
+            croak_xs_usage(cv, "sv_option=0");
+        if (items<1)
+            sv_option = 0;
+        else 
+            sv_option = ST(0);
+
+        retvalue = get_tmp_storage(aTHX_ sv_option);
         XPUSHs(retvalue);
 
 void
-thaw(SV *data, SV *sv_option = 0)
+thaw(SV *data, ... )
     ALIAS:
 	Storable::AMF::thaw=1
 	Storable::AMF::thaw0=2
     PROTOTYPE: $;$
     INIT:
         SV* retvalue;
+        SV* sv_option;
         struct io_struct io[1];
     PPCODE:
+        check_bounds(1,2, "sv_option=0");
+        if ( items == 1 )
+            sv_option = 0;
+        else 
+            sv_option = ST(1);
 	PERL_UNUSED_VAR(ix);
         if ( ! Sigsetjmp(io->target_error, 0) ){
             io->subname = "Storable::AMF0::thaw( data, option )";
@@ -2622,15 +2681,21 @@ thaw(SV *data, SV *sv_option = 0)
         }
 
 void
-deparse_amf(SV *data, SV * sv_option = 0)
+deparse_amf(SV *data, ... )
     PROTOTYPE: $;$
     ALIAS:
 	Storable::AMF::deparse_amf=1
-	Storable::AMF::deparse_amf0=1
+	Storable::AMF::deparse_amf0=2
     INIT:
         SV* retvalue;
+        SV* sv_option;
 	struct io_struct io[1];
     PPCODE:
+        check_bounds(1,2, "sv_option=0");
+        if ( items == 1 )
+            sv_option = 0;
+        else 
+            sv_option = ST(1);
 	PERL_UNUSED_VAR(ix);
         if ( ! Sigsetjmp(io->target_error, 0)){
             io->subname = "Storable::AMF0::deparse( data, option )";
@@ -2655,15 +2720,21 @@ deparse_amf(SV *data, SV * sv_option = 0)
         }
 
 
-void freeze(SV *data, SV *sv_option = 0 )
+void freeze(SV *data, ... )
     ALIAS:
 	Storable::AMF::freeze=1
 	Storable::AMF::freeze0=2
     PROTOTYPE: $;$
     INIT:
         SV * retvalue;
+        SV * sv_option;
         struct io_struct io[1];
     PPCODE:
+        check_bounds(1,2, "sv_option=0");
+        if ( items == 1 )
+            sv_option = 0;
+        else 
+            sv_option = ST(1);
 	PERL_UNUSED_VAR(ix);
         if (! Sigsetjmp(io->target_error, 0)){
             io_out_init(aTHX_  io, sv_option, AMF0_VERSION);
@@ -2682,14 +2753,20 @@ void freeze(SV *data, SV *sv_option = 0 )
 MODULE = Storable::AMF0		PACKAGE = Storable::AMF3		
 
 void
-deparse_amf(SV *data, SV* sv_option = 0)
+deparse_amf(SV *data, ... )
     ALIAS: 
         Storable::AMF::deparse_amf3 = 1
     PROTOTYPE: $;$
     INIT:
         SV* retvalue;
+        SV* sv_option = 0;
         struct io_struct io[1];
     PPCODE:
+        check_bounds(1,2, "sv_option=0");
+        if ( items == 1 )
+            sv_option = 0;
+        else 
+            sv_option = ST(1);
 	PERL_UNUSED_VAR(ix);
         if ( ! Sigsetjmp(io->target_error, 0)){
             io->subname = "Storable::AMF3::deparse_amf( data, option )";
@@ -2711,14 +2788,20 @@ deparse_amf(SV *data, SV* sv_option = 0)
         }
 
 void
-thaw(SV *data, SV *sv_option = 0)
+thaw(SV *data, ... )
     PROTOTYPE: $;$
     INIT:
         SV* retvalue;
+        SV *sv_option = 0;
         struct io_struct io[1];
     ALIAS:
 	Storable::AMF::thaw3=1
     PPCODE:
+        check_bounds(1,2, "sv_option=0");
+        if ( items == 1 )
+            sv_option = 0;
+        else 
+            sv_option = ST(1);
 	PERL_UNUSED_VAR(ix);
         if ( ! Sigsetjmp(io->target_error, 0)){
             io->subname = "Storable::AMF3::thaw( data, option )";
@@ -2738,6 +2821,7 @@ thaw(SV *data, SV *sv_option = 0)
 
 void
 _test_thaw_integer(SV*data)
+    PROTOTYPE: $
     INIT:
         SV* retvalue;
         struct io_struct io[1];
@@ -2758,6 +2842,7 @@ _test_thaw_integer(SV*data)
 
 void
 _test_freeze_integer(SV*data)
+    PROTOTYPE: $
     PREINIT:
         SV * retvalue;
         struct io_struct io[1];
@@ -2776,8 +2861,13 @@ _test_freeze_integer(SV*data)
 
 void 
 endian()
+    PROTOTYPE:
+    PREINIT:
+        SV * retvalue;
     PPCODE:
-    PerlIO_printf(PerlIO_stderr(), "%s %x\n", GAX, BYTEORDER);
+    retvalue = newSVpvf("%s %x\n",GAX, BYTEORDER);
+    sv_2mortal(retvalue);
+    XPUSHs(retvalue);
 
 void freeze(SV *data, SV *sv_option = 0 )
     PROTOTYPE: $;$
@@ -2949,7 +3039,7 @@ parse_option(char * s, int options=0)
 	    error = 1;
 	};
 	if (error)
-	    croak("Storable::AMF0::parse_option: unknown option '%.*s'", current - word, word);
+	    croak("Storable::AMF0::parse_option: unknown option '%.*s'", (int)(current - word), word);
 
 	for(; *current && !isALPHA(*current) && *current!='+' && *current!='-'; ++current);
 	word = current;
@@ -2968,6 +3058,7 @@ MODULE = Storable::AMF0 PACKAGE = Storable::AMF::Util
 
 void
 total_sv()
+    PROTOTYPE: 
     PPCODE:
     I32 visited  = 0;
     SV* sva;
@@ -2976,7 +3067,7 @@ total_sv()
         SV * svi;
         /* fprintf( stderr, "=%p %d\n", sva, SvREFCNT( sva ) ); */
         for( svi = sva + 1; svi<svend; ++svi ){
-            if ( SvTYPE(svi) != SVTYPEMASK && SvREFCNT(svi) ){
+            if ( (unsigned int)SvTYPE(svi) != SVTYPEMASK && SvREFCNT(svi) ){
                 /** skip pads, they have a PVAV as their first element inside a PVAV **/
                 if (SvTYPE(svi) == SVt_PVAV &&  av_len( (AV*) svi) != -1) {
                     SV** first = AvARRAY((AV*)svi);
@@ -2999,11 +3090,18 @@ total_sv()
 MODULE=Storable::AMF0 PACKAGE = Storable::AMF 
 
 void 
-thaw0_sv( SV * data, SV * element, SV *sv_option = 0)
+thaw0_sv(SV * data, SV * element, ... )
+    PROTOTYPE: $$;$
     INIT: 
         SV * retvalue;
+        SV *sv_option;
         struct io_struct io[1];
     PPCODE:
+        check_bounds(2,3, "sv_option=0");
+        if ( items == 2 )
+            sv_option = 0;
+        else 
+            sv_option = ST(2);
 	/* PERL_UNUSED_VAR(ix); */
         if ( ! Sigsetjmp(io->target_error, 0) ){
             io->subname = "Storable::AMF0::thaw( data, option )";
@@ -1,392 +1,419 @@
 Revision history for Perl extension Storable::AMF.
 
-0.01  Mon Aug 25 13:04:31 2008
-	- original version; created by h2xs 1.23 with options
-		-A -n Data::AMF::XS
+1.07    2015-04-25
+        - test skip for modern perl
 
-0.0200 (  404) 2008-09-01 13:25:47 +0400 
-	- blessed referenses added
+1.06    2015-02-19
+        - Better locking for store (2015-02-18)
+        - tests for lock_store (2015-02-19)
+        - prototypes for XS    (2015-02-19)
+        - code tidy            (2015-02-19)
 
-0.0200 (  405) 2008-09-01 15:21:37 +0400 
-	- added documentation
-	- some error handling
+1.05    2015-02-14
+        - Fixed FreeBSD compiling issues
 
-0.0200 (  452) 2008-09-04 12:18:11 +0400 
-	- add warnings && some code improvement && use setjmp
-	- speed up  dclone for 20% gain
-	- add prototypes
+1.04    2015-02-11: 
+        - Pod fixes thanks to github kdk    (2015-02-11)
+        - Changes                           (2015-02-11)
+        - JSON::XS, Types::Serializer fixes (2015-01-14)
 
-0.0200 (  487) 2008-09-26 18:30:43 +0400 
-	- Minor error fixes
+1.03    2014-12-25
+        - skip_bad_option (512) for (saving subs as undefs )(2014-12-25)
+        - Fix Ubuntu compiling (CCFLAG is problem)
+        - Apple compiling issue (Thanks to Alberto)
 
-0.0200 (  523) 2008-10-08 11:11:48 +0400 
-	- fixed error with null array element
-	- added support for self referenses structures
+1.02    2014-06-24
+        - fixed test stability over perl  above 5.19.1
+        - remove gcc warnings
 
-0.0200 (  528) 2008-10-09 13:15:56 +0400 
-	- fixed ecma_array
-	- Create lots of real data tests 08(real-data)
-	- Add unicode support
+1.01    2011-08-19
+        - remove development notice
+        - some fix in documentaion
 
-0.0200 (  533) 2008-10-10 13:34:13 +0400 
-	- begin work for AMF3
-	- amf3 numbers worked
-	- added strings for amf3
-	- added  tests for AMF3 and improve Storable::AMF3 (array && objects)
+1.00    2011-06-10
+        - speed improvement
+        - major perl version fixes ( compile for 5.10-5.14 )
 
-0.1200 (  540) 2008-10-16 13:55:15 +0400 
-	- Tested for memory leak (mainly AMF0 and some AMF3) 
-	- Uploaded to cpan
-	- find bug report
+0.99    2011-06-03
+        - thaw0_sv for utilizing hashref
+        - small speed improvement (ecma_array)
+        - small fix of logic
 
-0.1400 (  581) 2008-11-07 11:25:31 +0300 
-	- improved docs
-	- deleted unused filex
-	- improved doc and tests
-	- remove UTF8 support
+0.98    2011-06-03
+        - added amf_tmp_storage for thaw()
+        - New function aliases: deparse_amf0, deparse_amf3
+        - make work amf_tmp_storage for freeze
 
-0.1500 (  593) 2008-11-12 15:13:44 +0300 
-	- fixed typos (date->data)
-	- add support of bigendian machines
+0.97    2011-04-06
+        - changed memtest code from Devel::Gladiator
+        - put forgotted PUTBACK
 
-0.1500 (  599) 2008-11-13 13:28:37 +0300 
-	- implements parse bytearray, xml-doc, xml, date. Added more descriptive error codes
-	- Added TODO section 
+0.96	20011-04-03
+	- better freeze integer ( added test for boundary conditions )
+	- added examples 
+        - added use TARG ( about 25% speed improvement for freeze )
+        - added bench for TARG usage
 
-0.1502 (  603) 2008-11-14 13:28:37 +0300 
-	- Remove Strange bug for BigEndian machine 
-	- Fixed int (I32) declaration for hv_iternextsv
-	- Upgrade ExtUtils::MakeMaker to 6.48
-	- remove warnings: empty declaration
+0.95	    2011-04-09
+	- examples change
+	- fix possible memleak with (amf_plus_marker)
+	- fix possible memleak in thaw/deparse_amf AMF3
+	- more correct creation temp structures 
+	- limit  for array size when array extend
+	- fix amf3_read_integer for big integers ( crazy typo )
+	- fix amf3_write_integer for boundary conditions
+	- added more tests for amf3 integer convertion t/08-amf3_integer.t
+	- uncomment memleak for amf3
 
-0.1503 (  605) 2008-11-15 11:53:53 +0300 
-	- Fixed read/write integer for BIGENDIAN machine
+0.94	    2011-02-28  --- 2011-04-08
+	- Extend boolean test
+	- fix routine io_write_u8
+	- fix amf0 boolean format
+	- added cope of amf-plus-marker  
+	- Rewrite of error reporting
+	- ( Dev remove &io_record )
 
-0.1600 (  608) 2008-11-15 16:39:32 +0300 
-	- Improved  MakeFile.  Some compile error for Solaris eliminated.
+0.93	    2011-02-17
+	-  New tests for roundtrip JSON::XS:Boolean and AMF::boolean
+	-  Fixed convertion from AMF::boolean -> JSON::XS::boolean
+	-  Test typo fix. Extend boolean tests
+	-  Added prefix for all amf0 functions
+	-  Added test for bigendian boolean ( darwin + IRIX )
 
-0.1700 (  611) 2008-11-17 13:25:30 +0300 
-	- fixed read_u* and read_s16 for big_endian machines
+0.92	    2011-01-24
+	- added experimental TO_AMF support for AMF3 freeze
 
-0.1701 (  613) 2008-11-17 14:31:00 +0300 
-	- Add Perl Licence. Add marker comments
+0.91	    2011-01-24
+	- added more real tests for boolean support 
+	- added experimental TO_AMF support for AMF0 freeze
 
-0.1800 (  615) 2008-11-18 10:39:57 +0300 
-	- Fixed stupid typo( NetBSD ).
+0.90	    2011-01-24
+	- fixed typo in boolean
+	- added more test
+	- remove dependeces in JSON::XS
 
-0.1900 (  627) 2008-11-21 14:04:41 +0300 
-	- Patch for Solaris 2.10 compile bug
-	- Fixed implicit convertion strings to numbers in some cases
-	- Improved Makefile.PL
+0.89	    2011-01-20
+	- boolean support ( JSON::XS and boolean type )
+	- new option ( 'json_boolean' )
+	- thaw( AMF0_FALSE ) now is '' before it was 0
+	- thaw( AMF3_FALSE ) now is '' before it was 0
 
-0.2000 (  634) 2008-11-24 17:32:35 +0300 
-	- added lots tests for date. more date. more references.(AMF0). 
-	- Some algoritms fixed for date
+0.86	       2010-10-26 23:45 +0400
+	- prefer number option added (experimental)
 
-0.2100 (  644) 2008-11-25 17:22:07 +0300 
-	- Added XMLDocument type parse(amf0)
-	- Added freeze long string. More tests
+0.85	       2010-10-25 23:40 +0400
+	- try please automated tests
 
-0.2200 (  694) 2008-12-05 12:45:20 +0300 
-	- blessed references mod to undef
-	- added more error messages. 
-    - Added tests for AMF3. 
-    - Fixed thaw_amf3 for array. 
-    - Fixed test for AMF3 XML
+0.84		2010-10-24 23:50 +0400
+	- added parse_serializator_option
+	- added option "millisecond_date"
+	- revealed option "utf8_decode"
+	- revealed option "utf8_encode" (does nothing)
+	- revealed option "raise_error"
+	- revealed option "strict"
+	- added tests for 'parse_serializator_option'
+	- switched to perlish date
+	- test for "utf8_decode", "millisecond_date"
+	- remove all "skipped utf8 tests"
 
-0.2300 (  704) 2008-12-08 11:54:41 +0300 
-	- Fixed bug behavior for freeze.
-    - Added tests for blessed or not CODEREF, etc.
+0.83		2010-10-24 02:25 +0400
+	- Added tests -basic externalized
+	- Added basic externalized test
+	- rewrite test suit for (adding dumps) 
+	- fix typo in memtest amf3
 
-0.2400 (  706) 2008-12-08 14:25:38 +0300 
-	- Add negative tests for trimed and extra bytes in stream (thaw). Bug with successfully parses was fixed.
+0.78	        2010-10-15 11:31 +0400
+	-  Strawberry Perl (PERL_IMPLICIT_SYS make not compile Sigsetjmp)   # undefine
+0.79	        2010-10-20 15:31 +0400
+	-  Date support for AMF0, AMF3 dates
+	-  through perl_date, new_date
+0.80	        2010-10-20 15:31 +0400
+	-  rename new_date to new_amfdate
+	-  perl_date add type check
+	-  some source refactor
+	-  add smoke tests for dates
+	-  Version check
+0.81		2010-10-22 11:25 +0400
+	- Fix Build.PL 
+	- Some regret for CPAN index problems
+	- Change some constant for buffer allocation.
+	- Convience hacks.
+0.82		2010-10-23 02:25 +0400
+	- test added and a little rewrite
+	- fix with date sigfault in 0.80(found in test)
 
-0.2600 (  718) 2008-12-09 17:57:51 +0300 
-	- added Carp for store, nstore, etc.
+0.77	        2010-10-12 11:31 +0400
+	- Next try compile for Strawberry Perl (replace jmp_buf, setjmp, longjmp for Sigjmp_buf, Sigsetjmp, Siglongjmp)  
 
-0.2700 (  746) 2008-12-12 18:56:23 +0300 
-	- added aux function: ref_destroy ref_lost_memory for AMF0
+0.76	        2010-10-07 11:00 +0400
+	- Fix for MS cl.exe && gcc distribution for WIN32 build  
 
-0.2800 (  749) 2008-12-13 18:10:47 +0300 
-	- Solaris: delete optimize for Solaris
+0.75	        2010-10-06 16:33 +0400
+	- Makefile rewrite add warnings -Wunused -Wuninitialized  
 
-0.2900 (  788) 2008-12-18 12:44:07 +0300 
-	- fprintf moved to PerlIO abstraction layer
-	- added documentation for ref_lost_memory ref_destroy.
-    - some fixes to documentation
-0.3000 (  797) 2008-12-18 15:09:08 +0300 
-	- remove magic marker numbers. 
-	- change error handle: set  setting error number and description
-	- checks for error reporting. test cleanup 
+0.74	        2010-10-06 16:33 +0400
+	- Typos in Some compilers fix ( STATIC_INLINE ) don't like inline 
 
-0.3100 (  843) 2008-12-26 12:11:33 +0300 
-	- Added dualvar behave. Document Regexp, io, error reporting
+0.73	        2010-10-06 16:33 +0400
+	- Some compilers fix ( STATIC_INLINE ) don't like inline 
+	- Copyright fix
+	- Docs && Abstract fix
 
-0.3200 (  848) 2008-12-26 15:14:23 +0300 
-	- First port to MSWin32
+0.72   (     ) 2010-10-03 23:25:02 +0400
+	- Code cleanup( remove some warnings )
 
-0.3300 (  857) 2008-12-27 17:10:34 +0300 
-	- add memory leak test for positive AMF0
-	- add memory leak test for positive AMF3
-	- REF and SCALAR option added to test
+0.71   (     ) 2010-09-07 14:02:02 +0400
+	- Basic external object parsing 
 
-0.3400 (  860) 2008-12-28 20:29:19 +0300 
-	- add io_destroy  memleak test for AMF0, AMF3
-    - add memory leak test for negative AMF0
+0.70   (     ) 2010-09-07 14:02:02 +0400
+	- improve retrive && store for speed ( for win32 specialy )
 
-0.3500 (  861) 2008-12-29 11:13:25 +0300 
-	- fixed memory leak positive AMF3
-    - add memory leak test for negative AMF3
+0.6600 ( 1904) 2009-08-27 01:10:02 +0400 
+        - Some fixes ???
 
-0.3600 (  863) 2008-12-29 14:18:27 +0300 
-	- fixed memory leak negative for AMF3
-	- replace  direct long_jmp with io_register_error
+0.6400 ( 1904) 2009-08-27 01:10:02 +0400 
+        - bug in thaw for empty string
 
-0.3700 (  865) 2008-12-29 14:48:04 +0300 
-	- improve memleak tests
+0.6300 ( 1766) 2009-04-10 14:48:01 +0400 
+	- change croaking for file operation 
+	- perltidy
+	- function deparse_amf 
+	- added deparse test for amf0
+	- deparse for AMF0 && AMF3
+	- added parse_amf
 
-0.3800 (  870) 2008-12-29 16:18:57 +0300 
-	- some fixes for port MSWin32
-	- fix some warns. Increase compiler warn.
+0.6100 ( 1447) 2009-03-31 17:25:10 +0400 
+	- add proto for store and etc .. add test for these functions
 
-0.3900 (  876) 2008-12-30 11:28:29 +0300 
-	- fix warnings
-	- remove stupid say from test
-	- comment out SVt_string for 5.11.0
+0.6000 ( 1445) 2009-03-31 16:31:28 +0400 
+	- allowed freeze of ref ( REF and SCALAR )
 
-0.4000 (  882) 2009-01-10 18:03:20 +0300 
-	- Now can handle  magical strings in thawing
+0.6000 ( 1444) 2009-03-31 14:35:42 +0400 
+	- tidy
 
-0.4100 (  884) 2009-01-10 18:03:20 +0300 
-	- fix IV to UV for some strict compilers 
+0.5800 ( 1418) 2009-03-24 16:17:19 +0300 
+	- Fix BYTEORDER
 
-0.4200 (  999) 2009-01-22 14:45:31 +0300 
-	- fixed typos in IV to UV for Solaris (again)
-	- dublicated test remove
-    - fix test never worked
-    - reorganize tests (move rename etc)
-    - added all files (amf0 amf3 xml eval) in one pack
-0.4300 (  999) 2009-01-22 14:45:31 +0300 
-    - fixed stupid typo
+0.5700 ( 1414) 2009-03-20 18:55:44 +0300 
+	- Make work on windows
+	- fix for Win32 build for broken Module::Build
 
-0.4400 ( 1033) 2009-01-26 18:53:38 +0300 
-	- amf3_format_integer: refactor
-	- rename read_* , write_*  to io_*
-	- some fix in store
+0.5600 ( 1411) 2009-03-20 16:35:19 +0300 
+	- Cleanup code
 
-0.4500 ( 1038) 2009-01-27 16:36:07 +0300 
-	- Added resolve bug for Flash 9.0
-	- fix in documentation. 
-	- store and retrieve
+0.5500 ( 1354) 2009-03-12 15:59:44 +0300 
+	- Port to Straberry perl 5.10
 
-0.4600 ( 1049) 2009-01-28 12:29:00 +0300 
-	- back_port to 5.8.8
-	- Find stupid bug AMF3 add test 
+0.5400 ( 1306) 2009-02-25 18:57:17 +0300 
+	- added UTF8_DECODE, UTF8_ENCODE, STRICT, ERROR_RAISE 
+	- added test pod
 
-0.4700 ( 1097) 2009-01-30 19:14:39 +0300 
-	- Added strict pragma. thaw bug fix
+0.5300 ( 1243) 2009-02-15 13:41:29 +0300 
+	- fixed build reqs for Build.PL
+	- fix some tests
+	- Fixed some memleak for strict mode. added test
+	- rename ref_destroy to ref_clean
+	- some fixes for opts
+
+0.5200 ( 1159) 2009-02-06 12:21:15 +0300 
+	- croaking on thaw(bytearray_array) then  bytearray is UTF8_on string 
+	- added Build.PL
+
+0.5100 ( 1138) 2009-02-04 18:24:16 +0300 
+	- add feature strict to amf3
+
+0.5000 ( 1134) 2009-02-04 16:54:15 +0300 
+	- new tests for flash 9.0 bug. and fixes
+
+0.4900 ( 1103) 2009-02-02 13:18:42 +0300 
+	- fix objects bugs in AMF3
 
 0.4800 ( 1100) 2009-02-02 11:08:10 +0300 
 	- fix file_read_bug. (Win32 test bug)
 	- added test for thaw(undef)
 
-0.4900 ( 1103) 2009-02-02 13:18:42 +0300 
-	- fix objects bugs in AMF3
+0.4700 ( 1097) 2009-01-30 19:14:39 +0300 
+	- Added strict pragma. thaw bug fix
 
-0.5000 ( 1134) 2009-02-04 16:54:15 +0300 
-	- new tests for flash 9.0 bug. and fixes
+0.4600 ( 1049) 2009-01-28 12:29:00 +0300 
+	- back_port to 5.8.8
+	- Find stupid bug AMF3 add test 
 
-0.5100 ( 1138) 2009-02-04 18:24:16 +0300 
-	- add feature strict to amf3
+0.4500 ( 1038) 2009-01-27 16:36:07 +0300 
+	- Added resolve bug for Flash 9.0
+	- fix in documentation. 
+	- store and retrieve
 
-0.5200 ( 1159) 2009-02-06 12:21:15 +0300 
-	- croaking on thaw(bytearray_array) then  bytearray is UTF8_on string 
-	- added Build.PL
+0.4400 ( 1033) 2009-01-26 18:53:38 +0300 
+	- amf3_format_integer: refactor
+	- rename read_* , write_*  to io_*
+	- some fix in store
 
-0.5300 ( 1243) 2009-02-15 13:41:29 +0300 
-	- fixed build reqs for Build.PL
-	- fix some tests
-	- Fixed some memleak for strict mode. added test
-	- rename ref_destroy to ref_clean
-	- some fixes for opts
+0.4200 (  999) 2009-01-22 14:45:31 +0300 
+	- fixed typos in IV to UV for Solaris (again)
+	- dublicated test remove
+        - fix test never worked
+        - reorganize tests (move rename etc)
+        - added all files (amf0 amf3 xml eval) in one pack
+0.4300 (  999) 2009-01-22 14:45:31 +0300 
+        - fixed stupid typo
 
-0.5400 ( 1306) 2009-02-25 18:57:17 +0300 
-	- added UTF8_DECODE, UTF8_ENCODE, STRICT, ERROR_RAISE 
-	- added test pod
+0.4100 (  884) 2009-01-10 18:03:20 +0300 
+	- fix IV to UV for some strict compilers 
 
-0.5500 ( 1354) 2009-03-12 15:59:44 +0300 
-	- Port to Straberry perl 5.10
+0.4000 (  882) 2009-01-10 18:03:20 +0300 
+	- Now can handle  magical strings in thawing
 
-0.5600 ( 1411) 2009-03-20 16:35:19 +0300 
-	- Cleanup code
+0.3900 (  876) 2008-12-30 11:28:29 +0300 
+	- fix warnings
+	- remove stupid say from test
+	- comment out SVt_string for 5.11.0
 
-0.5700 ( 1414) 2009-03-20 18:55:44 +0300 
-	- Make work on windows
-	- fix for Win32 build for broken Module::Build
+0.3800 (  870) 2008-12-29 16:18:57 +0300 
+	- some fixes for port MSWin32
+	- fix some warns. Increase compiler warn.
 
-0.5800 ( 1418) 2009-03-24 16:17:19 +0300 
-	- Fix BYTEORDER
+0.3700 (  865) 2008-12-29 14:48:04 +0300 
+	- improve memleak tests
 
-0.6000 ( 1444) 2009-03-31 14:35:42 +0400 
-	- tidy
+0.3600 (  863) 2008-12-29 14:18:27 +0300 
+	- fixed memory leak negative for AMF3
+	- replace  direct long_jmp with io_register_error
 
-0.6000 ( 1445) 2009-03-31 16:31:28 +0400 
-	- allowed freeze of ref ( REF and SCALAR )
+0.3500 (  861) 2008-12-29 11:13:25 +0300 
+	- fixed memory leak positive AMF3
+    - add memory leak test for negative AMF3
 
-0.6100 ( 1447) 2009-03-31 17:25:10 +0400 
-	- add proto for store and etc .. add test for these functions
+0.3400 (  860) 2008-12-28 20:29:19 +0300 
+	- add io_destroy  memleak test for AMF0, AMF3
+    - add memory leak test for negative AMF0
 
-0.6300 ( 1766) 2009-04-10 14:48:01 +0400 
-	- change croaking for file operation 
-	- perltidy
-	- function deparse_amf 
-	- added deparse test for amf0
-	- deparse for AMF0 && AMF3
-	- added parse_amf
+0.3300 (  857) 2008-12-27 17:10:34 +0300 
+	- add memory leak test for positive AMF0
+	- add memory leak test for positive AMF3
+	- REF and SCALAR option added to test
 
-0.6400 ( 1904) 2009-08-27 01:10:02 +0400 
-        - bug in thaw for empty string
-    
-0.6600 ( 1904) 2009-08-27 01:10:02 +0400 
-        - Some fixes ???
+0.3200 (  848) 2008-12-26 15:14:23 +0300 
+	- First port to MSWin32
 
-0.70   (     ) 2010-09-07 14:02:02 +0400
-	- improve retrive && store for speed ( for win32 specialy )
+0.3100 (  843) 2008-12-26 12:11:33 +0300 
+	- Added dualvar behave. Document Regexp, io, error reporting
 
-0.71   (     ) 2010-09-07 14:02:02 +0400
-	- Basic external object parsing 
+0.2900 (  788) 2008-12-18 12:44:07 +0300 
+	- fprintf moved to PerlIO abstraction layer
+	- added documentation for ref_lost_memory ref_destroy.
+    - some fixes to documentation
+0.3000 (  797) 2008-12-18 15:09:08 +0300 
+	- remove magic marker numbers. 
+	- change error handle: set  setting error number and description
+	- checks for error reporting. test cleanup 
 
-0.72   (     ) 2010-10-03 23:25:02 +0400
-	- Code cleanup( remove some warnings )
+0.2800 (  749) 2008-12-13 18:10:47 +0300 
+	- Solaris: delete optimize for Solaris
 
-0.73	        2010-10-06 16:33 +0400
-	- Some compilers fix ( STATIC_INLINE ) don't like inline 
-	- Copyright fix
-	- Docs && Abstract fix
+0.2700 (  746) 2008-12-12 18:56:23 +0300 
+	- added aux function: ref_destroy ref_lost_memory for AMF0
 
-0.74	        2010-10-06 16:33 +0400
-	- Typos in Some compilers fix ( STATIC_INLINE ) don't like inline 
+0.2600 (  718) 2008-12-09 17:57:51 +0300 
+	- added Carp for store, nstore, etc.
 
-0.75	        2010-10-06 16:33 +0400
-	- Makefile rewrite add warnings -Wunused -Wuninitialized  
+0.2400 (  706) 2008-12-08 14:25:38 +0300 
+	- Add negative tests for trimed and extra bytes in stream (thaw). Bug with successfully parses was fixed.
 
-0.76	        2010-10-07 11:00 +0400
-	- Fix for MS cl.exe && gcc distribution for WIN32 build  
+0.2300 (  704) 2008-12-08 11:54:41 +0300 
+	- Fixed bug behavior for freeze.
+    - Added tests for blessed or not CODEREF, etc.
 
-0.77	        2010-10-12 11:31 +0400
-	- Next try compile for Strawberry Perl (replace jmp_buf, setjmp, longjmp for Sigjmp_buf, Sigsetjmp, Siglongjmp)  
+0.2200 (  694) 2008-12-05 12:45:20 +0300 
+	- blessed references mod to undef
+	- added more error messages. 
+    - Added tests for AMF3. 
+    - Fixed thaw_amf3 for array. 
+    - Fixed test for AMF3 XML
 
-0.78	        2010-10-15 11:31 +0400
-	-  Strawberry Perl (PERL_IMPLICIT_SYS make not compile Sigsetjmp)   # undefine
-0.79	        2010-10-20 15:31 +0400
-	-  Date support for AMF0, AMF3 dates
-	-  through perl_date, new_date
-0.80	        2010-10-20 15:31 +0400
-	-  rename new_date to new_amfdate
-	-  perl_date add type check
-	-  some source refactor
-	-  add smoke tests for dates
-	-  Version check
-0.81		2010-10-22 11:25 +0400
-	- Fix Build.PL 
-	- Some regret for CPAN index problems
-	- Change some constant for buffer allocation.
-	- Convience hacks.
-0.82		2010-10-23 02:25 +0400
-	- test added and a little rewrite
-	- fix with date sigfault in 0.80(found in test)
+0.2100 (  644) 2008-11-25 17:22:07 +0300 
+	- Added XMLDocument type parse(amf0)
+	- Added freeze long string. More tests
 
-0.83		2010-10-24 02:25 +0400
-	- Added tests -basic externalized
-	- Added basic externalized test
-	- rewrite test suit for (adding dumps) 
-	- fix typo in memtest amf3
+0.2000 (  634) 2008-11-24 17:32:35 +0300 
+	- added lots tests for date. more date. more references.(AMF0). 
+	- Some algoritms fixed for date
 
-0.84		2010-10-24 23:50 +0400
-	- added parse_serializator_option
-	- added option "millisecond_date"
-	- revealed option "utf8_decode"
-	- revealed option "utf8_encode" (does nothing)
-	- revealed option "raise_error"
-	- revealed option "strict"
-	- added tests for 'parse_serializator_option'
-	- switched to perlish date
-	- test for "utf8_decode", "millisecond_date"
-	- remove all "skipped utf8 tests"
+0.1900 (  627) 2008-11-21 14:04:41 +0300 
+	- Patch for Solaris 2.10 compile bug
+	- Fixed implicit convertion strings to numbers in some cases
+	- Improved Makefile.PL
 
-0.85	       2010-10-25 23:40 +0400
-	- try please automated tests
+0.1800 (  615) 2008-11-18 10:39:57 +0300 
+	- Fixed stupid typo( NetBSD ).
 
-0.86	       2010-10-26 23:45 +0400
-	- prefer number option added (experimental)
+0.1701 (  613) 2008-11-17 14:31:00 +0300 
+	- Add Perl Licence. Add marker comments
 
-0.89	    2011-01-20
-	- boolean support ( JSON::XS and boolean type )
-	- new option ( 'json_boolean' )
-	- thaw( AMF0_FALSE ) now is '' before it was 0
-	- thaw( AMF3_FALSE ) now is '' before it was 0
+0.1700 (  611) 2008-11-17 13:25:30 +0300 
+	- fixed read_u* and read_s16 for big_endian machines
 
-0.90	    2011-01-24
-	- fixed typo in boolean
-	- added more test
-	- remove dependeces in JSON::XS
+0.1600 (  608) 2008-11-15 16:39:32 +0300 
+	- Improved  MakeFile.  Some compile error for Solaris eliminated.
 
-0.91	    2011-01-24
-	- added more real tests for boolean support 
-	- added experimental TO_AMF support for AMF0 freeze
+0.1503 (  605) 2008-11-15 11:53:53 +0300 
+	- Fixed read/write integer for BIGENDIAN machine
 
-0.92	    2011-01-24
-	- added experimental TO_AMF support for AMF3 freeze
+0.1502 (  603) 2008-11-14 13:28:37 +0300 
+	- Remove Strange bug for BigEndian machine 
+	- Fixed int (I32) declaration for hv_iternextsv
+	- Upgrade ExtUtils::MakeMaker to 6.48
+	- remove warnings: empty declaration
 
-0.93	    2011-02-17
-	-  New tests for roundtrip JSON::XS:Boolean and AMF::boolean
-	-  Fixed convertion from AMF::boolean -> JSON::XS::boolean
-	-  Test typo fix. Extend boolean tests
-	-  Added prefix for all amf0 functions
-	-  Added test for bigendian boolean ( darwin + IRIX )
-	
-	
-0.94	    2011-02-28  --- 2011-04-08
-	- Extend boolean test
-	- fix routine io_write_u8
-	- fix amf0 boolean format
-	- added cope of amf-plus-marker  
-	- Rewrite of error reporting
-	- ( Dev remove &io_record )
+0.1500 (  599) 2008-11-13 13:28:37 +0300 
+	- implements parse bytearray, xml-doc, xml, date. Added more descriptive error codes
+	- Added TODO section 
 
-0.95	    2011-04-09
-	- examples change
-	- fix possible memleak with (amf_plus_marker)
-	- fix possible memleak in thaw/deparse_amf AMF3
-	- more correct creation temp structures 
-	- limit  for array size when array extend
-	- fix amf3_read_integer for big integers ( crazy typo )
-	- fix amf3_write_integer for boundary conditions
-	- added more tests for amf3 integer convertion t/08-amf3_integer.t
-	- uncomment memleak for amf3
+0.1500 (  593) 2008-11-12 15:13:44 +0300 
+	- fixed typos (date->data)
+	- add support of bigendian machines
 
-0.96	20011-04-03
-	- better freeze integer ( added test for boundary conditions )
-	- added examples 
-        - added use TARG ( about 25% speed improvement for freeze )
-        - added bench for TARG usage
-	
-0.97    2011-04-06
-        - changed memtest code from Devel::Gladiator
-        - put forgotted PUTBACK
+0.1400 (  581) 2008-11-07 11:25:31 +0300 
+	- improved docs
+	- deleted unused filex
+	- improved doc and tests
+	- remove UTF8 support
 
-0.98    2011-06-03
-        - added amf_tmp_storage for thaw()
-        - New function aliases: deparse_amf0, deparse_amf3
-        - make work amf_tmp_storage for freeze
+0.1200 (  540) 2008-10-16 13:55:15 +0400 
+	- Tested for memory leak (mainly AMF0 and some AMF3) 
+	- Uploaded to cpan
+	- find bug report
 
+0.0200 (  533) 2008-10-10 13:34:13 +0400 
+	- begin work for AMF3
+	- amf3 numbers worked
+	- added strings for amf3
+	- added  tests for AMF3 and improve Storable::AMF3 (array && objects)
 
-0.99    2011-06-03
-        - thaw0_sv for utilizing hashref
-        - small speed improvement (ecma_array)
-        - small fix of logic
+0.0200 (  528) 2008-10-09 13:15:56 +0400 
+	- fixed ecma_array
+	- Create lots of real data tests 08(real-data)
+	- Add unicode support
 
-1.00    2011-06-10
-        - speed improvement
-        - major perl version fixes ( compile for 5.10-5.14 )
+0.0200 (  523) 2008-10-08 11:11:48 +0400 
+	- fixed error with null array element
+	- added support for self referenses structures
+
+0.0200 (  487) 2008-09-26 18:30:43 +0400 
+	- Minor error fixes
+
+0.0200 (  452) 2008-09-04 12:18:11 +0400 
+	- add warnings && some code improvement && use setjmp
+	- speed up  dclone for 20% gain
+	- add prototypes
 
+0.0200 (  405) 2008-09-01 15:21:37 +0400 
+	- added documentation
+	- some error handling
+
+0.0200 (  404) 2008-09-01 13:25:47 +0400 
+	- blessed referenses added
+
+0.01  Mon Aug 25 13:04:31 2008
+	- original version; created by h2xs 1.23 with options
+		-A -n Data::AMF::XS
@@ -64,6 +64,8 @@ t/70-Mapper.t
 t/71-amf-plus-marker.t
 t/72-max-array.t
 t/73-amf-tmp-storage.t
+t/74-amf-skip-bad.t
+t/75-devel-api.t
 t/AMF0/01-array-foo-bar-x2.pack
 t/AMF0/01-boolean-false.pack
 t/AMF0/01-boolean-true.pack
@@ -164,3 +166,4 @@ examples/packets/amf_packet3
 examples/packets/amf_packet4
 examples/packets/failed_chunk
 examples/packets/input
+META.json                                Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,54 @@
+{
+   "abstract" : "serializing/deserializing AMF0/AMF3 data",
+   "author" : [
+      "Grishaev Anatoliy  <grian@cpan.org>"
+   ],
+   "dynamic_config" : 1,
+   "generated_by" : "ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.112621",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "Storable-AMF",
+   "no_index" : {
+      "directory" : [
+         "t",
+         "inc"
+      ]
+   },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : 0
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : 0
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "XSLoader" : "0.06",
+            "perl" : "5.008001"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "resources" : {
+      "bugtracker" : {
+         "web" : "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Storable-AMF"
+      },
+      "homepage" : "http://search.cpan.org/dist/Storable-AMF",
+      "license" : [
+         "http://dev.perl.org/licenses/"
+      ],
+      "repository" : {
+         "url" : "git://github.com/Grian/Storable-AMF.git"
+      }
+   },
+   "version" : "1.08"
+}
@@ -1,28 +1,28 @@
---- #YAML:1.0
-name:               Storable-AMF
-version:            1.00
-abstract:           serializing/deserializing AMF0/AMF3 data
+---
+abstract: 'serializing/deserializing AMF0/AMF3 data'
 author:
-    - Grishaev Anatoliy  <grian@cpan.org>
-license:            perl
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
+  - 'Grishaev Anatoliy  <grian@cpan.org>'
 build_requires:
-    ExtUtils::MakeMaker:  0
+  ExtUtils::MakeMaker: 0
+configure_requires:
+  ExtUtils::MakeMaker: 0
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 6.68, CPAN::Meta::Converter version 2.112621'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: Storable-AMF
+no_index:
+  directory:
+    - t
+    - inc
 requires:
-    perl:      5.008001
-    XSLoader:  0.06
+  XSLoader: 0.06
+  perl: 5.008001
 resources:
-    bugtracker:  http://rt.cpan.org/NoAuth/Bugs.html?Dist=Storable-AMF
-    homepage:    http://search.cpan.org/dist/Storable-AMF
-    license:     http://dev.perl.org/licenses/
-    repository:  git://github.com/Grian/Storable-AMF.git
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.55_02
-meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+  bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Storable-AMF
+  homepage: http://search.cpan.org/dist/Storable-AMF
+  license: http://dev.perl.org/licenses/
+  repository: git://github.com/Grian/Storable-AMF.git
+version: 1.08
@@ -14,10 +14,8 @@ if ( $] < MIN_PERL_VERSION  ) {
 
 our %MyModule = (
     PREREQ_PM => {
-        # 'Module::Build::Compat' => 0.02,
-        #        'Module::Build' => 0.2,
 		'XSLoader'   => 0.06,
-    },    # e.g., Module::Name => 1.1
+    },
     ABSTRACT => 'serializing/deserializing AMF0/AMF3 data',
     AUTHOR   => 'Grishaev Anatoliy  <grian@cpan.org>',
     $ExtUtils::MakeMaker::VERSION >= 6.48 ? ( MIN_PERL_VERSION => MIN_PERL_VERSION ) : (),
@@ -43,20 +41,20 @@ our %MyModule = (
     OPTIMIZE  => "-O3 -pipe -fomit-frame-pointer ",
 
 );
-delete $MyModule{OPTIMIZE}
-  if ( $Config{osname} =~ /solaris/
-    or $Config{cc} eq 'cl' );
+if ( $Config{osname} =~ /solaris/ or $Config{cc} eq 'cl' ){
+    delete $MyModule{OPTIMIZE}
+};
 if ( $Config{cc} eq 'gcc' ||  $Config{gccversion}) {
-	if ($Config{osname}!~m/Win32/i ){
-		for (   $MyModule{CCFLAGS} ){
-			$_ .= ' -Wunused'; 
-			$_ .= ' -Wuninitialized'; 
-			$_ .= ' -Wall'; 
-		#$_  .= ' -Wunreachable-code';
-		#$_  .= ' -Wunsafe-loop-optimizations';
-		};
-	}
-      #$MyModule{CCFLAGS} = '-Wunused-variable -Wunused-label -Wunused-function -Wuninitialized -Wunused-value'
+    if (0 && $Config{osname}!~m/Win32/i ){
+        for ($MyModule{CCFLAGS} ){
+                $_ .= ' -Wunused'; 
+                $_ .= ' -Wuninitialized'; 
+                $_ .= ' -Wall'; 
+        #$_  .= ' -Wunreachable-code';
+        #$_  .= ' -Wunsafe-loop-optimizations';
+        };
+    }
+    #$MyModule{CCFLAGS} = '-Wunused-variable -Wunused-label -Wunused-function -Wuninitialized -Wunused-value'
 }
 
 WriteMakefile(%MyModule);
@@ -3,3 +3,4 @@
     - Improve testleak for strings
     - add documentation for boolean, basic externalized objects, boolean_json
     - memleak for amf_tmp_storage
+    - optimize amf[03]_format_one, more boolean
@@ -33,6 +33,10 @@ sub new{
 	}
 	return $option_int;
 }
+
+1;
+__END__
+
 =head1 SYNOPSYS 
 
   use Storable::AMF::Mapper;
@@ -50,15 +54,6 @@ sub new{
 
   my $obj  = thaw( $amf0 ); # $obj = { Zeta=> , some_key_to_be_added => "Key Value" }
 
-
-=cut 
-
 =head1 NOTICE
-  
-  This Mapper is experimental feature of Storable::AMF distro. So may change in future ...
 
-=cut 
-
-
-
-1;
+  This Mapper is experimental feature of Storable::AMF distro. So may change in future ...
@@ -3,7 +3,7 @@ use strict;
 use warnings;
 BEGIN{
 	our $VERSION;
-	$VERSION='1.00' unless $INC{'Storable/AMF0.pm'};
+	$VERSION='1.08' unless $INC{'Storable/AMF0.pm'};
 }
 use Storable::AMF0; # install and create all methods
 use Exporter 'import';
@@ -109,7 +109,6 @@ Storable::AMF - serializing/deserializing AMF0/AMF3 data
   $bytea = Storable::AMF3::freeze( ... );
 
   ...
-=cut
 
 =head1 DESCRIPTION
 
@@ -117,22 +116,17 @@ This module is (de)serializer for Adobe's AMF0/AMF3 (Action Message Format ver 0
 To deserialize AMF3 objects you can export function from Storable::AMF3 package
 Almost all function implemented in XS/C for speed, except file operation. 
 
-=cut
 =head1 MOTIVATION
 
 Speed, simplicity and agile. 
 
-=cut
 =head1 BENCHMARKS
 
 	About 50-60 times faster than Data::AMF pure perl module. (2009)
 	About 40% faster than Storable in big objects.        (2009)
 	About 6 times faster than Storable for small object    (2009)
 
-=cut
-
 =head1 FUNCTIONS
-=cut
 
 =over
 
@@ -155,7 +149,7 @@ Speed, simplicity and agile.
 
 =item $perl_time = perl_date( $date_member )
 	Converts value from AMF date to perl timestampr, can croak.
-	
+
 =item store $obj, $file
   --- Store serialized AMF0 data to file
 
@@ -184,27 +178,22 @@ Speed, simplicity and agile.
   --- test if object contain lost memory fragments inside.
   (Example do { my $a = []; @$a=$a; $a})
 
-=item parse_serializator_option
-=item parse_option
+=item parse_serializator_option / parse_option
   generate option scalar for freeze/thaw/deparse_amf
   See L<Storable::AMF0> for complete list of options
 
 =back
 
 =head1 EXPORT
-  
-  None by default.
-
-=cut
 
+  None by default.
 
 =head1 LIMITATION
 
 At current moment and with restriction of AMF0/AMF3 format referrences to scalar are not serialized,
 and can't/ may not serialize tied variables.
 And dualvars (See Scalar::Util) are serialized as string value.
-Freezing CODEREF, IO, Regexp, REF, GLOB, SCALAR referenses restricted.
-
+Freezing CODEREF, IO, Regexp, GLOB referenses are restricted.
 
 =head1 SEE ALSO
 
@@ -226,4 +215,3 @@ Copyright (C) 2011 by A. G. Grishaev
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.8.8 or,
 at your option, any later version of Perl 5 you may have available.
-=cut
@@ -2,7 +2,7 @@ package Storable::AMF0;
 use strict;
 use warnings;
 use Fcntl qw(:flock);
-our $VERSION = '1.00';
+our $VERSION = '1.08';
 use subs qw(freeze thaw);
 use Scalar::Util qw(refaddr reftype);    # for ref_circled
 use Exporter 'import';
@@ -54,9 +54,18 @@ sub store($$) {
         croak "Bad object";
     }
     else  {
-	open my $fh, ">:raw", $file or croak "Can't open file \"$file\" for write.";
-        flock $fh, LOCK_EX if $lock;
+        my $fh;
+        if ($lock){
+            open $fh, ">>:raw", $file or croak "Can't open file \"$file\" for write.";
+            flock $fh, LOCK_EX if $lock;
+            truncate $fh, 0;
+            seek $fh,0,0;
+        }
+        else {
+            open $fh, ">:raw", $file or croak "Can't open file \"$file\" for write.";
+        }
         print $fh $$freeze if defined $$freeze;
+        close $fh;
     };
 }
 
@@ -137,7 +146,6 @@ sub ref_lost_memory($) {
 
 1;
 __END__
-# Below is stub documentation for your module. You'd better edit it!
 
 =head1 NAME
 
@@ -200,8 +208,6 @@ Storable::AMF0 - serializing/deserializing AMF0 data
   $obj = thaw( $amf, $options );
   $amf = freeze( $obj, $options );
 
-=cut
-
 =head1 DESCRIPTION
 
 This module is (de)serializer for Adobe's AMF0/AMF3 (Action Message Format ver 0-3).
@@ -209,16 +215,11 @@ This is only module and it recognize only AMF0 data.
 Almost all function implemented in C for speed. 
 And some cases faster then Storable( for me always)
 
-=cut
-
 =head1 EXPORT
-  
-  None by default.
 
-=cut
+  None by default.
 
 =head1 FUNCTIONS
-=cut
 
 =over
 
@@ -261,10 +262,9 @@ And some cases faster then Storable( for me always)
   Return one object and number of bytes readed
   if scalar context return object
 
-=item parse_option( $option_string )
-=item parse_serializator_option( $option_string )
+=item parse_serializator_option( $option_string ) / parse_option( $option_string )
   --- generate option scalar from string usefull for some options of thaw/freeze/deparse_amf 
-	
+
 
 =back
 
@@ -295,18 +295,11 @@ And some cases faster then Storable( for me always)
 
 =back
 
-=cut
-
-=head1 NOTICE
-
-  Storable::AMF0 is currently is at development stage. 
-
-=cut
-
 =head1 LIMITATION
 
-At current moment and with restriction of AMF0/AMF3 format referrences to scalar are not serialized,
-and can't/ may not serialize tied variables.
+At current moment and with restriction of AMF0/AMF3 format 
+referrences to function, filehandles are not serialized,
+and can't/may not serialize tied variables.
 
 =head1 FEATURES
 
@@ -334,4 +327,3 @@ Copyright (C) 2011 by A. G. Grishaev
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.8.8 or,
 at your option, any later version of Perl 5 you may have available.
-=cut
@@ -7,7 +7,7 @@ use Exporter 'import';
 use Carp qw(croak);
 BEGIN{
 	our $VERSION;
-	$VERSION='1.00' unless $INC{'Storable/AMF0.pm'};
+	$VERSION='1.08' unless $INC{'Storable/AMF0.pm'};
 };
 use Storable::AMF0 ();
 
@@ -56,9 +56,18 @@ sub store($$) {
         croak "Bad object";
     }
     else  {
-	open my $fh, ">:raw", $file or croak "Can't open file \"$file\" for write.";
-        flock $fh, LOCK_EX if $lock;
+        my $fh;
+        if ($lock){
+            open $fh, ">>:raw", $file or croak "Can't open file \"$file\" for write.";
+            flock $fh, LOCK_EX if $lock;
+            truncate $fh, 0;
+            seek $fh,0,0;
+        }
+        else {
+            open $fh, ">:raw", $file or croak "Can't open file \"$file\" for write.";
+        }
         print $fh $$freeze if defined $$freeze;
+        close $fh;
     };
 }
 
@@ -73,7 +82,6 @@ sub lock_store($$) {
 }};
 1;
 __END__
-# Below is stub documentation for your module. You'd better edit it!
 
 =head1 NAME
 
@@ -110,8 +118,6 @@ Storable::AMF3 - serializing/deserializing AMF3 data
   - or -
   $obj = deparse_amf( freeze($a1) . freeze($a) ... );
 
-=cut
-
 =head1 DESCRIPTION
 
 This module is (de)serializer for Adobe's AMF3 (Action Message Format ver 3).
@@ -119,16 +125,11 @@ This is only module and it recognize only AMF3 data.
 Almost all function implemented in C for speed. 
 And some cases faster then Storable( for me always)
 
-=cut
-
 =head1 EXPORT
-  
-  None by default.
 
-=cut
+  None by default.
 
 =head1 FUNCTIONS
-=cut
 
 =over
 
@@ -171,19 +172,13 @@ And some cases faster then Storable( for me always)
   Return one object and number of bytes readed
   if scalar context return object
 
-=item parse_option
-=item parse_serializator_option
+=item parse_serializator_option / parse_option
   generate option scalar for freeze/thaw/deparse_amf
   See L<Storable::AMF0> for complete list of options
 
 =back
 
 
-=head1 LIMITATION
-
-At current moment and with restriction of AMF0/AMF3 format referrences to scalar are not serialized,
-and can't/ may not serialize tied variables.
-
 =head1 SEE ALSO
 
 L<Data::AMF>, L<Storable>, L<Storable::AMF3>, L<Storable::AMF>
@@ -204,4 +199,3 @@ Copyright (C) 2011 by A. G. Grishaev
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.8.8 or,
 at your option, any later version of Perl 5 you may have available.
-=cut
@@ -15,8 +15,8 @@ no warnings 'once';
 	use_ok('Storable::AMF0');
 	use_ok('Storable::AMF3');
 	use_ok('Storable::AMF::Mapper');
-    print STDERR unpack( "H*", pack "d", 12345678), " ";
-    Storable::AMF3::endian();
+    print STDERR unpack( "H*", pack "i", 0x12345678), " ";
+    print STDERR Storable::AMF3::endian();
 #	};
 #########################
 
@@ -5,6 +5,10 @@ use Scalar::Util qw(refaddr);
 use GrianUtils;
 use strict;
 no warnings 'once';
+if ($] > 5.020){
+    eval 'use Test::More skip_all => "This perl version is too modern( >= 5.020 )"';
+    exit;
+}
 eval 'use Test::More tests => 6+6;';
 use warnings;
 no warnings 'once';
@@ -1,18 +1,24 @@
 use ExtUtils::testlib;
 use strict;
 use warnings;
-use Test::More tests=>60; #'no_plan';
+use Test::More tests=>64; #'no_plan';
 use Storable::AMF0 qw(freeze thaw );
 use Data::Dumper;
 
+sub dehex{
+	unpack "H*", $_[0];
+}
 sub my_test(){
+	local $Test::Builder::Level = $Test::Builder::Level + 1;
     $@ = undef;
-    ok(! defined scalar Storable::AMF3::freeze($_), ref $_);
+    ok(! defined scalar Storable::AMF3::freeze($_), ref $_) ;
+#	! defined  Storable::AMF3::freeze($_) or warn Dumper( dehex (Storable::AMF3::freeze($_)));
     ok($@, "has error for3 ". ref $_);
     ok(! defined scalar Storable::AMF0::freeze($_), ref $_);
     ok($@, "has error for0 ". ref $_);
 };
 sub my_ok(){
+	local $Test::Builder::Level = $Test::Builder::Level + 1;
     ok( defined scalar Storable::AMF0::freeze($_), $@);
     is_deeply(Storable::AMF0::thaw(Storable::AMF0::freeze $_), $_, $@);
 	TODO: {
@@ -43,5 +49,7 @@ my_test for bless qr/\w+/, 'a';
 my_test for *STDERR{IO};
 my_test for bless *STDERR{IO}, 'a';
 
+my_test for \*STDERR;
+# my_test for *STDERR;
 
 
@@ -4,9 +4,12 @@ use strict;
 use warnings;
 use ExtUtils::testlib;
 use Storable::AMF0 qw(freeze thaw retrieve store nstore lock_store lock_nstore lock_retrieve);
-use Data::Dumper;
+use Storable::AMF3 qw();
+use Fcntl qw(LOCK_SH LOCK_EX LOCK_UN);
+use Time::HiRes qw(sleep);
+use Config;
 
-eval "use Test::More tests=>18;";
+eval "use Test::More tests=>20;";
 warn $@ if $@;
 
 my $a = { test => "Hello World\n\r \r\n"};
@@ -38,4 +41,55 @@ ok(lock_store( $a , $file));
 ok(-e $file, "exists file");
 ok(retrieve $file, "retrieve ok lock_store");
 is_deeply(retrieve $file, $a, "retrieve ok deeply lock_store");
+
+sub check_lock {
+    my ( $store, $retrieve, $lock_store ) = @_;
+    my @pmain;
+    no warnings 'redefine';
+    local *store = $store;
+    local *retrieve = $retrieve;
+    local *lock_store = $lock_store;
+    use warnings 'redefine';
+    my @pchld;
+    pipe $pmain[0], $pmain[1];
+    pipe $pchld[0], $pchld[1];
+    select( ( ( select $pmain[1] ), $| = 1 )[0] );
+    select( ( ( select $pchld[1] ), $| = 1 )[0] );
+
+    if ( $Config{osname}=~m/Win32/i ){
+        ok( 1, "Win32 skipped");
+    }
+    elsif ( my $pid = fork ) {
+        open my $fh, ">", $file;
+        flock $fh, LOCK_SH;
+        store( $a, $file );
+        print { $pchld[1] } "start\n";
+        sysread $pmain[0], $b, 6;
+
+        sleep(0.25);
+#        print STDERR "btst\n";
+#        print STDERR "size=", -s $file, "\n";
+        ok( defined( retrieve($file) ), "lockfree" );
+#        print STDERR "atst\n";
+        close($fh);
+
+        waitpid $pid, 0;
+    }
+    elsif ( defined $pid ) {
+        sysread $pchld[0], $b, 6;
+        print { $pmain[1] } "cont0\n";
+#        print STDERR "bst\n";
+        lock_store( $a, $file );
+#        print STDERR "ast\n";
+        exit 0;
+    }
+    else {
+        ok( 1, "skipped" );
+        1;
+    }
+}
+
+check_lock(\&Storable::AMF0::store, \&Storable::AMF0::retrieve, \&Storable::AMF0::lock_store);
+check_lock(\&Storable::AMF3::store, \&Storable::AMF3::retrieve, \&Storable::AMF3::lock_store);
+# cleanup
 unlink $file or die "Can't unlink $file: $!";
@@ -35,7 +35,7 @@ ok( is_amf_string (  $a ="4"  , $nop ),     'str var not changed');
 $a = 1;
 $b = "$a";
 $var = 'Int';
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+ok(    is_amf_string($a)			 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -45,7 +45,7 @@ ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
 $a = 1;
 $b = "".$a;
 $var = "Int++";
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+ok(    is_amf_string($a)			 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -55,7 +55,8 @@ $a = 1.0;
 $b = "$a";
 $var = "Double";
 
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+my %string_number=(0=>1,2=>1);
+ok(    $string_number{ byte_amf_string($a)} , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -65,7 +66,7 @@ ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
 $a = 1.0;
 $b = "".$a;
 $var = "Double++";
-ok(    is_amf_string($a)		 , "$var converted  is   a string"  );
+ok(    $string_number{ byte_amf_string($a)}, "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -104,3 +105,6 @@ ok(    is_amf_string(''.$a, )   ,  "$var ''.converted       is str" );
 sub is_amf_string{
 	ord( freeze( $_[0], $_[1]||0 )) == 2;
 }
+sub byte_amf_string{
+	ord( freeze( $_[0], $_[1]||0 ));
+}
@@ -35,7 +35,7 @@ ok( is_amf_string (  $a ="4"  , $nop ),     'str var not changed');
 $a = 1;
 $b = "$a";
 $var = 'Int';
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+ok(    is_amf_string($a)			 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -45,7 +45,7 @@ ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
 $a = 1;
 $b = "".$a;
 $var = "Int++";
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+ok(    is_amf_string($a)			 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -55,7 +55,7 @@ $a = 1.0;
 $b = "$a";
 $var = "Double";
 
-ok(   is_amf_string($a)			 , "$var converted  is   a string"  );
+ok(    is_double_string($a)		 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -65,7 +65,7 @@ ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
 $a = 1.0;
 $b = "".$a;
 $var = "Double++";
-ok(    is_amf_string($a)		 , "$var converted  is   a string"  );
+ok(    is_double_string($a)		 , "$var converted  is   a string"  );
 ok( !  is_amf_string(0+$a)		 , "$var 0+converted     is double" );
 ok( !  is_amf_string(0.0+$a,$nop), "$var 0.0+converted   is double" );
 ok( !  is_amf_string($a, $nop)   , "$var converted again is double" );
@@ -100,7 +100,14 @@ ok(    is_amf_string(''.$a, $nop), "$var ''.converted again is str" );
 ok(    is_amf_string(''.$a, )   ,  "$var ''.converted       is str" );
 
 
+is_double_string( ('a'));
+is_double_string( (1234));
+is_double_string( (1234.0));
 
+sub is_double_string{
+	# print STDERR Dumper(	ord( freeze( $_[0], $_[1]||0 )));
+	return scalar grep $_ == 6|| $_==5, ord( freeze( $_[0], $_[1]||0 ));
+}
 sub is_amf_string{
 	ord( freeze( $_[0], $_[1]||0 )) == 6;
 }
@@ -0,0 +1,35 @@
+#
+#===============================================================================
+#
+#         FILE:  74-amf-skip-bad.t
+#
+#  DESCRIPTION:  
+#
+#        FILES:  ---
+#         BUGS:  ---
+#        NOTES:  ---
+#       AUTHOR:  YOUR NAME (), 
+#      COMPANY:  
+#      VERSION:  1.0
+#      CREATED:  10/13/2011 10:30:12 PM
+#     REVISION:  ---
+#===============================================================================
+use strict;
+use Test::More no_plan => ();                      # last test to print
+use ExtUtils::testlib;
+use Storable::AMF qw(freeze0 freeze3 thaw0 thaw3);
+
+sub t0 { thaw0(do { my $s= freeze0( $_[0], 512 ); print STDERR $@ if $@; $s});}
+sub t3 { thaw3 freeze3( $_[0], 512 );}
+is( t0( sub {} ), undef, "sub (0)"); 
+is( t3( sub {} ), undef, "sub (3)"); 
+
+
+is( t0( *STDERR ), undef, "glob (0)"); 
+is( t3( *STDERR ), undef, "glob (3)"); 
+
+is( t0( \*STDERR ), undef, "ref-glob (0)"); 
+is( t3( \*STDERR ), undef, "ref-glob (3)"); 
+
+
+
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+# vim: ft=perl ts=4 shiftwidth=4 softtabstop=4 expandtab
+# space2tab: ok
+#===============================================================================
+#
+#         FILE:  74-devel-api.t
+#
+#         BUGS:  ---
+#        NOTES:  ---
+#       AUTHOR:  Anatoliy Grishaev (), grian@cpan.org
+#      CREATED:  02/19/2015 08:34:10 PM
+#  DESCRIPTION:  ---
+#
+#===============================================================================
+use strict;
+use warnings;
+use Test::More no_plan => ();                      # last test to print
+use ExtUtils::testlib;
+use Storable::AMF qw(freeze0 freeze3 thaw0_sv);
+use Storable::AMF3;
+
+my $s;
+$s = freeze0( { a=> 1, b=>2, c=>3} );
+$s = freeze0( { 0 => 1 , asdf=> 'asdf' });
+
+my $storage = Storable::AMF0::amf_tmp_storage();
+my $hash = {};
+
+for (0..4)
+{
+
+#    print length( freeze3(  { 0 => 1 , asdf=> 'asdf' }, $storage )), "\n";
+
+    thaw0_sv( $s =>  $hash , 0);
+#    print Dumper( $hash );
+
+}
+ok(1, "finished");
+
+
+
+
+