asn1: Expand decoration w/ C types
This commits allows `heim_object_t` as a type and causes the generated code to use the `heim_retain()` and `heim_release()` functions for copying and releasing values of such types. Also, now one can have more than one decoration per-type.
This commit is contained in:
@@ -1039,18 +1039,18 @@ static int
|
||||
test_decorated(void)
|
||||
{
|
||||
TESTNotDecorated tnd;
|
||||
TESTDecorated3 td3, td3_copy;
|
||||
TESTDecorated2 td2, td2_copy;
|
||||
TESTDecorated td, td_copy;
|
||||
size_t len, size;
|
||||
void *ptr;
|
||||
int ret;
|
||||
|
||||
memset(&td, 0, sizeof(td));
|
||||
memset(&td2, 0, sizeof(td2));
|
||||
memset(&tnd, 0, sizeof(tnd));
|
||||
|
||||
td.version = 3;
|
||||
td.version3.v = 5;
|
||||
td.privthing = &td;
|
||||
td.privobj = heim_string_create("foo");
|
||||
if ((td.version2 = malloc(sizeof(*td.version2))) == NULL)
|
||||
errx(1, "out of memory");
|
||||
*td.version2 = 5;
|
||||
@@ -1085,90 +1085,35 @@ test_decorated(void)
|
||||
warnx("copy_TESTDecorated() did not work correctly (2)");
|
||||
return 1;
|
||||
}
|
||||
if (td.version3.v != td_copy.version3.v) {
|
||||
warnx("copy_TESTDecorated() did not work correctly (3)");
|
||||
return 1;
|
||||
}
|
||||
if (td_copy.privthing != 0) {
|
||||
warnx("copy_TESTDecorated() did not work correctly (4)");
|
||||
return 1;
|
||||
}
|
||||
if (td_copy.privobj != td.privobj) {
|
||||
warnx("copy_TESTDecorated() did not work correctly (5)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_TESTDecorated(&td_copy);
|
||||
free_TESTDecorated(&td);
|
||||
if (td.version2) {
|
||||
warnx("free_TESTDecorated() did not work correctly");
|
||||
warnx("free_TESTDecorated() did not work correctly (1)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
td2.version = 3;
|
||||
td2.version2.v = 5;
|
||||
ASN1_MALLOC_ENCODE(TESTDecorated2, ptr, len, &td2, &size, ret);
|
||||
if (ret) {
|
||||
warnx("could not encode a TESTDecorated2 struct");
|
||||
if (td.version3.v != 0 || my_free_vers_called != 2) {
|
||||
warnx("free_TESTDecorated() did not work correctly (2)");
|
||||
return 1;
|
||||
}
|
||||
ret = decode_TESTNotDecorated(ptr, len, &tnd, &size);
|
||||
if (ret) {
|
||||
warnx("could not decode a TESTDecorated2 struct as TESTNotDecorated2");
|
||||
if (td.privthing != 0) {
|
||||
warnx("free_TESTDecorated() did not work correctly (3)");
|
||||
return 1;
|
||||
}
|
||||
free(ptr);
|
||||
if (size != len) {
|
||||
warnx("TESTDecorated2 encoded size mismatch");
|
||||
return 1;
|
||||
}
|
||||
if (td2.version != tnd.version) {
|
||||
warnx("TESTDecorated2 did not decode as a TESTNotDecorated correctly");
|
||||
return 1;
|
||||
}
|
||||
if (copy_TESTDecorated2(&td2, &td2_copy)) {
|
||||
warnx("copy_TESTDecorated2() failed");
|
||||
return 1;
|
||||
}
|
||||
if (td2.version != td2_copy.version || !my_copy_vers_called) {
|
||||
warnx("copy_TESTDecorated2() did not work correctly (1)");
|
||||
return 1;
|
||||
}
|
||||
if (td2.version2.v != td2_copy.version2.v) {
|
||||
warnx("copy_TESTDecorated2() did not work correctly (2)");
|
||||
return 1;
|
||||
}
|
||||
free_TESTDecorated2(&td2_copy);
|
||||
free_TESTDecorated2(&td2);
|
||||
if (td2.version2.v != 0 || my_free_vers_called != 2) {
|
||||
warnx("free_TESTDecorated2() did not work correctly");
|
||||
return 1;
|
||||
}
|
||||
|
||||
td3.version = 3;
|
||||
td3.privthing = &td;
|
||||
ASN1_MALLOC_ENCODE(TESTDecorated3, ptr, len, &td3, &size, ret);
|
||||
if (ret) {
|
||||
warnx("could not encode a TESTDecorated3 struct");
|
||||
return 1;
|
||||
}
|
||||
ret = decode_TESTNotDecorated(ptr, len, &tnd, &size);
|
||||
if (ret) {
|
||||
warnx("could not decode a TESTDecorated3 struct as TESTNotDecorated3");
|
||||
return 1;
|
||||
}
|
||||
free(ptr);
|
||||
if (size != len) {
|
||||
warnx("TESTDecorated3 encoded size mismatch");
|
||||
return 1;
|
||||
}
|
||||
if (td3.version != tnd.version) {
|
||||
warnx("TESTDecorated3 did not decode as a TESTNotDecorated correctly");
|
||||
return 1;
|
||||
}
|
||||
if (copy_TESTDecorated3(&td3, &td3_copy)) {
|
||||
warnx("copy_TESTDecorated3() failed");
|
||||
return 1;
|
||||
}
|
||||
if (td3.version != td3_copy.version) {
|
||||
warnx("copy_TESTDecorated3() did not work correctly (1)");
|
||||
return 1;
|
||||
}
|
||||
if (td3_copy.privthing != 0) {
|
||||
warnx("copy_TESTDecorated3() did not work correctly (2)");
|
||||
return 1;
|
||||
}
|
||||
free_TESTDecorated3(&td3_copy);
|
||||
free_TESTDecorated3(&td3);
|
||||
if (td3.privthing != 0) {
|
||||
warnx("free_TESTDecorated3() did not work correctly");
|
||||
if (td.privobj != 0) {
|
||||
warnx("free_TESTDecorated() did not work correctly (4)");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user