summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2017-05-09 00:38:07 +0200
committerAlbert Astals Cid <aacid@kde.org>2017-05-09 01:09:35 +0200
commit9773c1534668d84b8267c3e5c9d612076fa231a5 (patch)
tree2690337133883e3de8c65283c3342f9a8bf8d4f5 /test
parent3c29ded4bee5eadb829ed46af2ec92be57b0077b (diff)
New Object API
Implement the move operators and copy construtor Almost all the init() functions are gone and we just have simple constructors now Also made free() public since you're not supposed to call it anymore, unless you're being evil and malloc'ing Objects like Array/Dict/XRef This has a huge reaction chain, most importantly we don't get objects by passing a pointer Object parameter, we just get the object as a return value, which is a much clearer API - aobj->copy(&obj); + obj = aobj->copy(); before I was never sure what was being copied into what Comes with a huge diff, I probably made some mistake in the porting since there was lots of copy & paste involved
Diffstat (limited to 'test')
-rw-r--r--test/pdf-fullrewrite.cc21
1 files changed, 6 insertions, 15 deletions
diff --git a/test/pdf-fullrewrite.cc b/test/pdf-fullrewrite.cc
index 81083723..1f8fcc4c 100644
--- a/test/pdf-fullrewrite.cc
+++ b/test/pdf-fullrewrite.cc
@@ -124,14 +124,11 @@ static GBool compareDictionaries(Dict *dictA, Dict *dictB)
* contain the same number of entries, we don't need to check that every key
* in dictB is also contained in dictA */
for (int i = 0; i < length; ++i) {
- Object valA, valB;
const char *key = dictA->getKey(i);
- dictA->getValNF(i, &valA);
- dictB->lookupNF(key, &valB);
+ Object valA = dictA->getValNF(i);
+ Object valB = dictB->lookupNF(key);
if (!compareObjects(&valA, &valB))
return gFalse;
- valA.free();
- valB.free();
}
return gTrue;
@@ -200,14 +197,11 @@ static GBool compareObjects(Object *objA, Object *objB)
return gFalse;
} else {
for (int i = 0; i < length; ++i) {
- Object elemA, elemB;
- arrayA->getNF(i, &elemA);
- arrayB->getNF(i, &elemB);
+ Object elemA = arrayA->getNF(i);
+ Object elemB = arrayB->getNF(i);
if (!compareObjects(&elemA, &elemB)) {
return gFalse;
}
- elemA.free();
- elemB.free();
}
return gTrue;
}
@@ -348,15 +342,12 @@ static GBool compareDocuments(PDFDoc *origDoc, PDFDoc *newDoc)
}
// Compare contents
- Object origObj, newObj;
- origXRef->fetch(i, origGenNum, &origObj);
- newXRef->fetch(i, newGenNum, &newObj);
+ Object origObj = origXRef->fetch(i, origGenNum);
+ Object newObj = newXRef->fetch(i, newGenNum);
if (!compareObjects(&origObj, &newObj)) {
fprintf(stderr, "XRef entry %u: contents differ\n", i);
result = gFalse;
}
- origObj.free();
- newObj.free();
}
return result;