@@ -75,7 +75,8 @@ typedef struct __ArrayItem
7575 Item item ;
7676 ArrayEntry * head ;
7777 ArrayEntry * tail ;
78- } ArrayItem ;
78+ int length ;
79+ } ArrayItem ;
7980
8081typedef struct __LongValue
8182{
@@ -229,6 +230,7 @@ static void arrayAddItem(void* context, JSOBJ obj, JSOBJ value)
229230 }
230231 ai -> tail = ae ;
231232
233+ ai -> length ++ ;
232234}
233235
234236static JSOBJ newTrue (void * context )
@@ -272,6 +274,7 @@ static JSOBJ newArray(void *context)
272274 ArrayItem * ai = (ArrayItem * ) alloc (ds , sizeof (ArrayItem ));
273275 ai -> head = NULL ;
274276 ai -> tail = NULL ;
277+ ai -> length = 0 ;
275278 ai -> item .type = UJT_Array ;
276279 return (JSOBJ ) ai ;
277280}
@@ -473,6 +476,15 @@ int UJIterArray(void **iter, UJObject *outObj)
473476 return 1 ;
474477}
475478
479+ int UJLengthArray (UJObject arrObj )
480+ {
481+ switch ( ((Item * ) arrObj )-> type )
482+ {
483+ case UJT_Array : return ((ArrayItem * ) arrObj )-> length ;
484+ default : return -1 ;
485+ }
486+ }
487+
476488void * UJBeginObject (UJObject objObj )
477489{
478490 switch ( ((Item * ) objObj )-> type )
@@ -688,7 +700,6 @@ int UJObjectUnpack(UJObject objObj, int keys, const char *format, const wchar_t
688700 const wchar_t * keyNames [64 ];
689701 UJObject * outValues [64 ];
690702 va_list args ;
691- UJObject * outValue ;
692703
693704
694705 if (!UJIsObject (objObj ))
@@ -707,8 +718,7 @@ int UJObjectUnpack(UJObject objObj, int keys, const char *format, const wchar_t
707718 for (ki = 0 ; ki < keys ; ki ++ )
708719 {
709720 keyNames [ki ] = _keyNames [ki ];
710- outValue = va_arg (args , UJObject * );
711- outValues [ki ] = outValue ;
721+ outValues [ki ] = va_arg (args , UJObject * );
712722 }
713723 va_end (args );
714724
0 commit comments