* updated XPT_Do code to match in-memory structs
This commit is contained in:
coop%netscape.com 1999-01-18 17:26:04 +00:00
Родитель 9836a9165b
Коммит d557721c1f
2 изменённых файлов: 220 добавлений и 330 удалений

Просмотреть файл

@ -27,14 +27,32 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
XPTMode mode = cursor->state->mode;
XPTCursor my_cursor;
XPTHeader *header;
uint16 annotation_size;
uint16 xpt_header_size;
if (mode == XPT_DECODE) {
if !((*headerp = header = PR_NEWZAP(XPTHedaer)))
if (!(*headerp = header = PR_NEWZAP(XPTHeader)))
goto error;
} else {
header = *headerp;
}
if (mode == XPT_ENCODE) {
if !(annotation_size = XPT_GetAnnotationSize(&my_cursor,
&header->annotations)) {
goto error;
}
xpt_header_size = XPT_HEADER_BASE_SIZE + annotation_size;
} else {
xpt_header_size = XPT_HEADER_BASE_SIZE;
}
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, xpt_header_size,
&my_cursor)) {
goto error;
}
for (i=0, i<16; i++) {
if (!XPT_Do8(&my_cursor, &header->magic[i]))
goto error;
@ -47,10 +65,10 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
!XPT_DoInterfaceDirectoryEntry(&my_cursor,
&header->interface_directory) ||
!XPT_Do8(&my_cursor, &header->data_pool) ||
!XPT_DoAnnotation(&my_cursor, &header->annotations))
{
goto error;
}
!XPT_DoAnnotation(&my_cursor, &header->annotations)) {
goto error;
}
return PR_TRUE;
@ -65,7 +83,7 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
/* InterfaceDirectoryEntry records go in the header */
PRBool
XPT_DoInterfaceDirectoryEntry(XPTCursor *cursor,
XPTInterfaceDirectoryEntry **idep)
XPTInterfaceDirectoryEntry **idep)
{
XPTMode mode = cursor->state->mode;
XPTCursor my_cursor;
@ -110,16 +128,20 @@ XPT_DoInterfaceDirectoryEntry(XPTCursor *cursor,
/* write the IID in our cursor space */
!XPT_DoIID(&my_cursor, &ide->iid) ||
/* write the string in the data pool, and the offset in our
/* write the name string in the data pool, and the offset in our
cursor space */
!XPT_DoCString(&my_cursor, &ide->name) ||
/* write the namespace string in the data pool, and the offset in our
cursor space */
!XPT_DoCString(&my_cursor, &ide->namespace) ||
/* write the InterfaceDescriptor in the data pool, and the offset
in our cursor space */
!XPT_DoInterfaceDescriptor(&my_cursor, &ide->interface_descriptor))
{
goto error;
}
!XPT_DoInterfaceDescriptor(&my_cursor, &ide->interface_descriptor)) {
goto error;
}
return PR_TRUE;
@ -145,20 +167,24 @@ XPT_DoInterfaceDescriptor(XPTCursor *cursor, XPTInterfaceDescriptor **idp)
if(!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_ID_SIZE, &my_cursor) ||
!XPT_DoInterfaceDirectoryEntry(&my_cursor, &id->parent_interface) ||
!XPT_Do16(&my_cursor, &id->num_methods))
!XPT_Do16(&my_cursor, &id->num_methods)) {
goto error;
}
for (i = 0; i < id->num_methods; i++) {
if (!XPT_DoMethodDescriptor(&my_cursor, &id->method_descriptors[i]))
goto error;
}
if (!XPT_Do16(&my_cursor, &id->num_constants))
if (!XPT_Do16(&my_cursor, &id->num_constants)) {
goto error;
}
for (i = 0; i < id->num_constants; i++) {
if (!XPT_DoConstDescriptor(&my_cursor, &id->constant_descriptors[i]))
if (!XPT_DoConstDescriptor(&my_cursor, &id->constant_descriptors[i])) {
goto error;
}
}
return PR_TRUE;
@ -176,58 +202,57 @@ XPT_DoConstDescriptor(XPTCursor *cursor, XPTConstDescriptor **cdp)
{
XPTMode mode = cursor->state->mode;
XPTConstDescriptor cd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
cd = PR_NEWZAP(XPTConstDescriptor);
else
cd = *cdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_CD_SIZE, &my_cursor) ||
!XPT_DoCString(&my_cursor, &cd->name) ||
!XPT_DoTypeDescriptor(&my_cursor, &cd->type))
{
goto error;
}
if (!XPT_DoCString(&cursor, &cd->name) ||
!XPT_DoTypeDescriptor(&cursor, &cd->type)) {
goto error;
}
switch(cd->type->prefix->tag) {
case '0':
XPT_Do8(&my_cursor, &cd->value->i8);
XPT_Do8(&cursor, &cd->value->i8);
break;
case '1':
XPT_Do16(&my_cursor, &cd->value->i16);
XPT_Do16(&cursor, &cd->value->i16);
break;
case '2':
XPT_Do32(&my_cursor, &cd->value->i32);
XPT_Do32(&cursor, &cd->value->i32);
break;
case '3':
XPT_Do64(&my_cursor, &cd->value->i64);
XPT_Do64(&cursor, &cd->value->i64);
break;
case '4':
XPT_Do8(&my_cursor, &cd->value->ui8);
XPT_Do8(&cursor, &cd->value->ui8);
break;
case '5':
XPT_Do16(&my_cursor, &cd->value->ui16);
XPT_Do16(&cursor, &cd->value->ui16);
break;
case '6':
XPT_Do32(&my_cursor, &cd->value->ui32);
XPT_Do32(&cursor, &cd->value->ui32);
break;
case '7':
XPT_Do64(&my_cursor, &cd->value->ui64);
XPT_Do64(&cursor, &cd->value->ui64);
break;
case '11':
XPT_Do8(&my_cursor, &cd->value->ch);
XPT_Do8(&cursor, &cd->value->ch);
break;
case '12':
XPT_Do16(&my_cursor, &cd->value->wch);
XPT_Do16(&cursor, &cd->value->wch);
break;
case '15':
if (cd->type->prefix->is_pointer == 1) {
XPT_DoString(&my_cursor, &cd->value->string);
XPT_DoString(&cursor, &cd->value->string);
break;
}
goto error;
default:
goto error;
goto error;
}
return PR_TRUE;
@ -245,7 +270,6 @@ XPT_DoMethodDescriptor(XPTCursor *cursor, XPTMethodDescriptor **mdp)
{
XPTMode mode = cursor->state->mode;
XPTConstDescriptor md;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -253,19 +277,19 @@ XPT_DoMethodDescriptor(XPTCursor *cursor, XPTMethodDescriptor **mdp)
else
md = *mdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_MD_SIZE, &my_cursor) ||
!XPT_DO_BITS(&my_cursor, &md->is_getter, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_setter, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_varargs, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_constructor, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->reserved, 4, scratch) ||
!XPT_DoCString(&my_cursor, &md->name) ||
!XPT_Do8(&my_cursor, &md->num_args) ||
!XPT_DoParamDescriptor(&my_cursor, &md->params) ||
!XPT_DoParamDescriptor(&my_cursor, &md->result))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &md->is_getter, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_setter, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_varargs, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_constructor, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_hidden, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->reserved, 3, scratch) ||
!XPT_DoCString(&cursor, &md->name) ||
!XPT_Do8(&cursor, &md->num_args) ||
!XPT_DoParamDescriptor(&cursor, &md->params) ||
!XPT_DoParamDescriptor(&cursor, &md->result)) {
goto error;
}
return PR_TRUE;
@ -282,7 +306,6 @@ XPT_DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor **pdp)
{
XPTMode mode = cursor->state->mode;
XPTParamDescriptor pd;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -290,15 +313,14 @@ XPT_DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor **pdp)
else
pd = *pdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_PD_SIZE, &my_cursor) ||
!XPT_DO_BITS(&my_cursor, &pd->in, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->out, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->retval, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->reserved, 5, scratch) ||
!XPT_DoTypeDescriptor(&my_cursor, &pd->type))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &pd->in, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->out, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->retval, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->reserved, 5, scratch) ||
!XPT_DoTypeDescriptor(&cursor, &pd->type)) {
goto error;
}
return PR_TRUE;
@ -315,7 +337,6 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
{
XPTMode mode = cursor->state->mode;
XPTTypeDescriptorPrefix tdp;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -323,16 +344,14 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
else
tdp = *tdpp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_TDP_SIZE,
&my_cursor) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_pointer, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_unique_pointer, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_reference, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->tag, 5, scratch))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &tdp->is_pointer, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->is_unique_pointer, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->is_reference, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->tag, 5, scratch)) {
goto error;
}
return PR_TRUE;
error:
@ -343,91 +362,27 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
return PR_FALSE;
}
PRBool
XPT_DoInterfaceTypeDescriptor(XPTCursor *cursor,
XPTInterfaceTypeDescriptor **itdp)
{
XPTMode mode = cursor->state->mode;
XPTIntefaceTypeDescriptor itd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
itd = PR_NEWZAP(XPTInterfaceTypeDescriptor);
else
itd = *itdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_ITD_SIZE,
&my_cursor) ||
!XPT_DoInterfaceDirectoryEntry(&my_cursor, &itd->interface))
{
goto error;
}
return PR_TRUE;
error:
if (mode == XPT_DECODE) {
PR_FREE(itd);
*itdp = 0;
}
return PR_FALSE;
}
PRBool
XPT_DoInterfaceIsTypeDescriptor(XPTCursor *cursor,
XPTInterfaceIsTypeDescriptor **iitdp)
{
XPTMode mode = cursor->state->mode;
XPTIntefaceTypeDescriptor iitd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
iitd = PR_NEWZAP(XPTInterfaceIsTypeDescriptor);
else
iitd = *iitdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_IITD_SIZE,
&my_cursor) ||
!XPT_Do8(&my_cursor, &iitd->argnum))
{
goto error;
}
return PR_TRUE;
error:
if (mode == XPT_DECODE) {
PR_FREE(iitd);
*iitdp = 0;
}
return PR_FALSE;
}
PRBool
XPT_DoTypeDescriptor(XPTCursor *cursor, XPTSimpleTypeDescriptor **tdp)
{
XPTMode mode = cursor->state->mode;
XPTSimpleTypeDescriptor td;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
td = PR_NEWZAP(XPTTypeDescriptor);
else
td = *tdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_TD_SIZE, &my_cursor) ||
!XPT_DoTypeDescriptorPrefix(&my_cursor, &td->prefix))
{
goto error;
}
if (!XPT_DoTypeDescriptorPrefix(&cursor, &td->prefix)) {
goto error;
}
if (td->prefix->tag == 16) {
if (!XPT_DoInterfaceTypeDescriptor(&my_cursor, &td->type->interface))
if (td->prefix->tag == TD_INTERFACE_TYPE) {
if (!XPT_DoInterfaceDirectoryEntry(&cursor, &td->type->interface))
goto error;
} else {
if (td->prefix->tag == 17) {
if (!XPT_DoInterfaceIsTypeDescriptor(&my_cursor,
&td->type->interface_is))
if (td->prefix->tag == TD_INTERFACE_IS_TYPE) {
if (!XPT_Do8(&cursor, &td->type->argnum))
goto error;
}
}
@ -442,13 +397,11 @@ XPT_DoTypeDescriptor(XPTCursor *cursor, XPTSimpleTypeDescriptor **tdp)
return PR_FALSE;
}
PRBool
XPT_DoAnnotationPrefix(XPTCursor *cursor, XPTAnnotationPrefix **app)
{
XPTMode mode = cursor->state->mode;
XPTAnnotationPrefix ap;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -456,13 +409,11 @@ XPT_DoAnnotationPrefix(XPTCursor *cursor, XPTAnnotationPrefix **app)
else
ap = *app;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_AP_SIZE,
&my_cursor) ||
!XPT_DO_BITS(&my_cursor, &ap->is_last, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &ap->tag, 7, scratch))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &ap->is_last, 1, scratch) ||
!XPT_DO_BITS(&cursor, &ap->tag, 7, scratch)) {
goto error;
}
return PR_TRUE;
@ -479,20 +430,17 @@ XPT_DoPrivateAnnotation(XPTCursor *cursor, XPTPrivateAnnotation **pap)
{
XPTMode mode = cursor->state->mode;
XPTPrivateAnnotation pa;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
pa = PR_NEWZAP(XPTPrivateAnnotation);
else
pa = *pap;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_AP_SIZE,
&my_cursor) ||
!XPT_DoString(&my_cursor, &pa->creator) ||
!XPT_DoString(&my_cursor, &pa->private_data))
{
goto error;
}
if (!XPT_DoString(&cursor, &pa->creator) ||
!XPT_DoString(&cursor, &pa->private_data)) {
goto error;
}
return PR_TRUE;
@ -509,23 +457,20 @@ XPT_DoAnnotation(XPTCursor *cursor, XPTAnnotation **ap)
{
XPTMode mode = cursor->state->mode;
XPTAnnotation a;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
a = PR_NEWZAP(XPTPrivateAnnotation);
else
a = *ap;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_A_SIZE,
&my_cursor) ||
!XPT_DoAnnotationPrefix(&my_cursor, &a->prefix))
{
if (!XPT_DoAnnotationPrefix(&cursor, &a->prefix)) {
goto error;
}
if (a->prefix->tag == PRIVATE_ANNOTATION) {
if (!XPT_DoPrivateAnnotation(&cursor, &a->private)) {
goto error;
}
if (a->prefix->tag == 1) {
if (!XPT_DoPrivateAnnotation(&my_cursor, &a->private))
goto error;
}
return PR_TRUE;

Просмотреть файл

@ -27,14 +27,32 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
XPTMode mode = cursor->state->mode;
XPTCursor my_cursor;
XPTHeader *header;
uint16 annotation_size;
uint16 xpt_header_size;
if (mode == XPT_DECODE) {
if !((*headerp = header = PR_NEWZAP(XPTHedaer)))
if (!(*headerp = header = PR_NEWZAP(XPTHeader)))
goto error;
} else {
header = *headerp;
}
if (mode == XPT_ENCODE) {
if !(annotation_size = XPT_GetAnnotationSize(&my_cursor,
&header->annotations)) {
goto error;
}
xpt_header_size = XPT_HEADER_BASE_SIZE + annotation_size;
} else {
xpt_header_size = XPT_HEADER_BASE_SIZE;
}
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, xpt_header_size,
&my_cursor)) {
goto error;
}
for (i=0, i<16; i++) {
if (!XPT_Do8(&my_cursor, &header->magic[i]))
goto error;
@ -47,10 +65,10 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
!XPT_DoInterfaceDirectoryEntry(&my_cursor,
&header->interface_directory) ||
!XPT_Do8(&my_cursor, &header->data_pool) ||
!XPT_DoAnnotation(&my_cursor, &header->annotations))
{
goto error;
}
!XPT_DoAnnotation(&my_cursor, &header->annotations)) {
goto error;
}
return PR_TRUE;
@ -65,7 +83,7 @@ XPT_DoHeader(XPTCursor *cursor, XPTHeader **headerp)
/* InterfaceDirectoryEntry records go in the header */
PRBool
XPT_DoInterfaceDirectoryEntry(XPTCursor *cursor,
XPTInterfaceDirectoryEntry **idep)
XPTInterfaceDirectoryEntry **idep)
{
XPTMode mode = cursor->state->mode;
XPTCursor my_cursor;
@ -110,16 +128,20 @@ XPT_DoInterfaceDirectoryEntry(XPTCursor *cursor,
/* write the IID in our cursor space */
!XPT_DoIID(&my_cursor, &ide->iid) ||
/* write the string in the data pool, and the offset in our
/* write the name string in the data pool, and the offset in our
cursor space */
!XPT_DoCString(&my_cursor, &ide->name) ||
/* write the namespace string in the data pool, and the offset in our
cursor space */
!XPT_DoCString(&my_cursor, &ide->namespace) ||
/* write the InterfaceDescriptor in the data pool, and the offset
in our cursor space */
!XPT_DoInterfaceDescriptor(&my_cursor, &ide->interface_descriptor))
{
goto error;
}
!XPT_DoInterfaceDescriptor(&my_cursor, &ide->interface_descriptor)) {
goto error;
}
return PR_TRUE;
@ -145,20 +167,24 @@ XPT_DoInterfaceDescriptor(XPTCursor *cursor, XPTInterfaceDescriptor **idp)
if(!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_ID_SIZE, &my_cursor) ||
!XPT_DoInterfaceDirectoryEntry(&my_cursor, &id->parent_interface) ||
!XPT_Do16(&my_cursor, &id->num_methods))
!XPT_Do16(&my_cursor, &id->num_methods)) {
goto error;
}
for (i = 0; i < id->num_methods; i++) {
if (!XPT_DoMethodDescriptor(&my_cursor, &id->method_descriptors[i]))
goto error;
}
if (!XPT_Do16(&my_cursor, &id->num_constants))
if (!XPT_Do16(&my_cursor, &id->num_constants)) {
goto error;
}
for (i = 0; i < id->num_constants; i++) {
if (!XPT_DoConstDescriptor(&my_cursor, &id->constant_descriptors[i]))
if (!XPT_DoConstDescriptor(&my_cursor, &id->constant_descriptors[i])) {
goto error;
}
}
return PR_TRUE;
@ -176,58 +202,57 @@ XPT_DoConstDescriptor(XPTCursor *cursor, XPTConstDescriptor **cdp)
{
XPTMode mode = cursor->state->mode;
XPTConstDescriptor cd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
cd = PR_NEWZAP(XPTConstDescriptor);
else
cd = *cdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_CD_SIZE, &my_cursor) ||
!XPT_DoCString(&my_cursor, &cd->name) ||
!XPT_DoTypeDescriptor(&my_cursor, &cd->type))
{
goto error;
}
if (!XPT_DoCString(&cursor, &cd->name) ||
!XPT_DoTypeDescriptor(&cursor, &cd->type)) {
goto error;
}
switch(cd->type->prefix->tag) {
case '0':
XPT_Do8(&my_cursor, &cd->value->i8);
XPT_Do8(&cursor, &cd->value->i8);
break;
case '1':
XPT_Do16(&my_cursor, &cd->value->i16);
XPT_Do16(&cursor, &cd->value->i16);
break;
case '2':
XPT_Do32(&my_cursor, &cd->value->i32);
XPT_Do32(&cursor, &cd->value->i32);
break;
case '3':
XPT_Do64(&my_cursor, &cd->value->i64);
XPT_Do64(&cursor, &cd->value->i64);
break;
case '4':
XPT_Do8(&my_cursor, &cd->value->ui8);
XPT_Do8(&cursor, &cd->value->ui8);
break;
case '5':
XPT_Do16(&my_cursor, &cd->value->ui16);
XPT_Do16(&cursor, &cd->value->ui16);
break;
case '6':
XPT_Do32(&my_cursor, &cd->value->ui32);
XPT_Do32(&cursor, &cd->value->ui32);
break;
case '7':
XPT_Do64(&my_cursor, &cd->value->ui64);
XPT_Do64(&cursor, &cd->value->ui64);
break;
case '11':
XPT_Do8(&my_cursor, &cd->value->ch);
XPT_Do8(&cursor, &cd->value->ch);
break;
case '12':
XPT_Do16(&my_cursor, &cd->value->wch);
XPT_Do16(&cursor, &cd->value->wch);
break;
case '15':
if (cd->type->prefix->is_pointer == 1) {
XPT_DoString(&my_cursor, &cd->value->string);
XPT_DoString(&cursor, &cd->value->string);
break;
}
goto error;
default:
goto error;
goto error;
}
return PR_TRUE;
@ -245,7 +270,6 @@ XPT_DoMethodDescriptor(XPTCursor *cursor, XPTMethodDescriptor **mdp)
{
XPTMode mode = cursor->state->mode;
XPTConstDescriptor md;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -253,19 +277,19 @@ XPT_DoMethodDescriptor(XPTCursor *cursor, XPTMethodDescriptor **mdp)
else
md = *mdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_MD_SIZE, &my_cursor) ||
!XPT_DO_BITS(&my_cursor, &md->is_getter, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_setter, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_varargs, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->is_constructor, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &md->reserved, 4, scratch) ||
!XPT_DoCString(&my_cursor, &md->name) ||
!XPT_Do8(&my_cursor, &md->num_args) ||
!XPT_DoParamDescriptor(&my_cursor, &md->params) ||
!XPT_DoParamDescriptor(&my_cursor, &md->result))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &md->is_getter, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_setter, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_varargs, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_constructor, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->is_hidden, 1, scratch) ||
!XPT_DO_BITS(&cursor, &md->reserved, 3, scratch) ||
!XPT_DoCString(&cursor, &md->name) ||
!XPT_Do8(&cursor, &md->num_args) ||
!XPT_DoParamDescriptor(&cursor, &md->params) ||
!XPT_DoParamDescriptor(&cursor, &md->result)) {
goto error;
}
return PR_TRUE;
@ -282,7 +306,6 @@ XPT_DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor **pdp)
{
XPTMode mode = cursor->state->mode;
XPTParamDescriptor pd;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -290,15 +313,14 @@ XPT_DoParamDescriptor(XPTCursor *cursor, XPTParamDescriptor **pdp)
else
pd = *pdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_PD_SIZE, &my_cursor) ||
!XPT_DO_BITS(&my_cursor, &pd->in, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->out, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->retval, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &pd->reserved, 5, scratch) ||
!XPT_DoTypeDescriptor(&my_cursor, &pd->type))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &pd->in, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->out, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->retval, 1, scratch) ||
!XPT_DO_BITS(&cursor, &pd->reserved, 5, scratch) ||
!XPT_DoTypeDescriptor(&cursor, &pd->type)) {
goto error;
}
return PR_TRUE;
@ -315,7 +337,6 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
{
XPTMode mode = cursor->state->mode;
XPTTypeDescriptorPrefix tdp;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -323,16 +344,14 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
else
tdp = *tdpp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_TDP_SIZE,
&my_cursor) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_pointer, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_unique_pointer, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->is_reference, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &tdp->tag, 5, scratch))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &tdp->is_pointer, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->is_unique_pointer, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->is_reference, 1, scratch) ||
!XPT_DO_BITS(&cursor, &tdp->tag, 5, scratch)) {
goto error;
}
return PR_TRUE;
error:
@ -343,91 +362,27 @@ XPT_DoTypeDescriptorPrefix(XPTCursor *cursor, XPTTypeDescriptorPrefix **tdpp)
return PR_FALSE;
}
PRBool
XPT_DoInterfaceTypeDescriptor(XPTCursor *cursor,
XPTInterfaceTypeDescriptor **itdp)
{
XPTMode mode = cursor->state->mode;
XPTIntefaceTypeDescriptor itd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
itd = PR_NEWZAP(XPTInterfaceTypeDescriptor);
else
itd = *itdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_ITD_SIZE,
&my_cursor) ||
!XPT_DoInterfaceDirectoryEntry(&my_cursor, &itd->interface))
{
goto error;
}
return PR_TRUE;
error:
if (mode == XPT_DECODE) {
PR_FREE(itd);
*itdp = 0;
}
return PR_FALSE;
}
PRBool
XPT_DoInterfaceIsTypeDescriptor(XPTCursor *cursor,
XPTInterfaceIsTypeDescriptor **iitdp)
{
XPTMode mode = cursor->state->mode;
XPTIntefaceTypeDescriptor iitd;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
iitd = PR_NEWZAP(XPTInterfaceIsTypeDescriptor);
else
iitd = *iitdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_IITD_SIZE,
&my_cursor) ||
!XPT_Do8(&my_cursor, &iitd->argnum))
{
goto error;
}
return PR_TRUE;
error:
if (mode == XPT_DECODE) {
PR_FREE(iitd);
*iitdp = 0;
}
return PR_FALSE;
}
PRBool
XPT_DoTypeDescriptor(XPTCursor *cursor, XPTSimpleTypeDescriptor **tdp)
{
XPTMode mode = cursor->state->mode;
XPTSimpleTypeDescriptor td;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
td = PR_NEWZAP(XPTTypeDescriptor);
else
td = *tdp;
if (!XPT_CreateCursor(cursor->state, XPT_DATA, XPT_TD_SIZE, &my_cursor) ||
!XPT_DoTypeDescriptorPrefix(&my_cursor, &td->prefix))
{
goto error;
}
if (!XPT_DoTypeDescriptorPrefix(&cursor, &td->prefix)) {
goto error;
}
if (td->prefix->tag == 16) {
if (!XPT_DoInterfaceTypeDescriptor(&my_cursor, &td->type->interface))
if (td->prefix->tag == TD_INTERFACE_TYPE) {
if (!XPT_DoInterfaceDirectoryEntry(&cursor, &td->type->interface))
goto error;
} else {
if (td->prefix->tag == 17) {
if (!XPT_DoInterfaceIsTypeDescriptor(&my_cursor,
&td->type->interface_is))
if (td->prefix->tag == TD_INTERFACE_IS_TYPE) {
if (!XPT_Do8(&cursor, &td->type->argnum))
goto error;
}
}
@ -442,13 +397,11 @@ XPT_DoTypeDescriptor(XPTCursor *cursor, XPTSimpleTypeDescriptor **tdp)
return PR_FALSE;
}
PRBool
XPT_DoAnnotationPrefix(XPTCursor *cursor, XPTAnnotationPrefix **app)
{
XPTMode mode = cursor->state->mode;
XPTAnnotationPrefix ap;
XPTCursor my_cursor;
uintn scratch;
if (mode == XPT_DECODE)
@ -456,13 +409,11 @@ XPT_DoAnnotationPrefix(XPTCursor *cursor, XPTAnnotationPrefix **app)
else
ap = *app;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_AP_SIZE,
&my_cursor) ||
!XPT_DO_BITS(&my_cursor, &ap->is_last, 1, scratch) ||
!XPT_DO_BITS(&my_cursor, &ap->tag, 7, scratch))
{
goto error;
}
if (!XPT_DO_BITS(&cursor, &ap->is_last, 1, scratch) ||
!XPT_DO_BITS(&cursor, &ap->tag, 7, scratch)) {
goto error;
}
return PR_TRUE;
@ -479,20 +430,17 @@ XPT_DoPrivateAnnotation(XPTCursor *cursor, XPTPrivateAnnotation **pap)
{
XPTMode mode = cursor->state->mode;
XPTPrivateAnnotation pa;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
pa = PR_NEWZAP(XPTPrivateAnnotation);
else
pa = *pap;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_AP_SIZE,
&my_cursor) ||
!XPT_DoString(&my_cursor, &pa->creator) ||
!XPT_DoString(&my_cursor, &pa->private_data))
{
goto error;
}
if (!XPT_DoString(&cursor, &pa->creator) ||
!XPT_DoString(&cursor, &pa->private_data)) {
goto error;
}
return PR_TRUE;
@ -509,23 +457,20 @@ XPT_DoAnnotation(XPTCursor *cursor, XPTAnnotation **ap)
{
XPTMode mode = cursor->state->mode;
XPTAnnotation a;
XPTCursor my_cursor;
if (mode == XPT_DECODE)
a = PR_NEWZAP(XPTPrivateAnnotation);
else
a = *ap;
if (!XPT_CreateCursor(cursor->state, XPT_HEADER, XPT_A_SIZE,
&my_cursor) ||
!XPT_DoAnnotationPrefix(&my_cursor, &a->prefix))
{
if (!XPT_DoAnnotationPrefix(&cursor, &a->prefix)) {
goto error;
}
if (a->prefix->tag == PRIVATE_ANNOTATION) {
if (!XPT_DoPrivateAnnotation(&cursor, &a->private)) {
goto error;
}
if (a->prefix->tag == 1) {
if (!XPT_DoPrivateAnnotation(&my_cursor, &a->private))
goto error;
}
return PR_TRUE;