summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/poppler/Object.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/poppler/Object.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/poppler/Object.cc80
1 files changed, 42 insertions, 38 deletions
diff --git a/Build/source/libs/poppler/poppler-src/poppler/Object.cc b/Build/source/libs/poppler/poppler-src/poppler/Object.cc
index d06bb39fb6d..d3adc4473ab 100644
--- a/Build/source/libs/poppler/poppler-src/poppler/Object.cc
+++ b/Build/source/libs/poppler/poppler-src/poppler/Object.cc
@@ -13,7 +13,7 @@
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
-// Copyright (C) 2008, 2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2008, 2010, 2012, 2017 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
//
// To see a description of the changes please see the Changelog file that
@@ -54,47 +54,48 @@ static const char *objTypeNames[numObjTypes] = {
"error",
"eof",
"none",
- "integer64"
+ "integer64",
+ "dead"
};
#ifdef DEBUG_MEM
int Object::numAlloc[numObjTypes] =
- {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
#endif
-Object *Object::initArray(XRef *xref) {
- initObj(objArray);
- array = new Array(xref);
- return this;
+Object::Object(Object&& other)
+{
+ type = other.type;
+ real = other.real; // this is the biggest of the union so it's enough
+ other.type = objDead;
}
-Object *Object::initDict(XRef *xref) {
- initObj(objDict);
- dict = new Dict(xref);
- return this;
+Object& Object::operator=(Object&& other)
+{
+ free();
+ type = other.type;
+ real = other.real; // this is the biggest of the union so it's enough
+ other.type = objDead;
+ return *this;
}
-Object *Object::initDict(Dict *dictA) {
- initObj(objDict);
- dict = dictA;
- dict->incRef();
- return this;
+Object::~Object()
+{
+ free();
}
-Object *Object::initStream(Stream *streamA) {
- initObj(objStream);
- stream = streamA;
- return this;
-}
+Object Object::copy() const {
+ CHECK_NOT_DEAD;
-Object *Object::copy(Object *obj) {
- *obj = *this;
+ Object obj;
+ obj.type = type;
+ obj.real = real; // this is the biggest of the union so it's enough
switch (type) {
case objString:
- obj->string = string->copy();
+ obj.string = string->copy();
break;
case objName:
- obj->name = copyString(name);
+ obj.cString = copyString(cString);
break;
case objArray:
array->incRef();
@@ -106,7 +107,7 @@ Object *Object::copy(Object *obj) {
stream->incRef();
break;
case objCmd:
- obj->cmd = copyString(cmd);
+ obj.cString = copyString(cString);
break;
default:
break;
@@ -117,9 +118,11 @@ Object *Object::copy(Object *obj) {
return obj;
}
-Object *Object::fetch(XRef *xref, Object *obj, int recursion) {
+Object Object::fetch(XRef *xref, int recursion) const {
+ CHECK_NOT_DEAD;
+
return (type == objRef && xref) ?
- xref->fetch(ref.num, ref.gen, obj, recursion) : copy(obj);
+ xref->fetch(ref.num, ref.gen, recursion) : copy();
}
void Object::free() {
@@ -128,7 +131,7 @@ void Object::free() {
delete string;
break;
case objName:
- gfree(name);
+ gfree(cString);
break;
case objArray:
if (!array->decRef()) {
@@ -146,7 +149,7 @@ void Object::free() {
}
break;
case objCmd:
- gfree(cmd);
+ gfree(cString);
break;
default:
break;
@@ -157,11 +160,11 @@ void Object::free() {
type = objNone;
}
-const char *Object::getTypeName() {
+const char *Object::getTypeName() const {
return objTypeNames[type];
}
-void Object::print(FILE *f) {
+void Object::print(FILE *f) const {
Object obj;
int i;
@@ -181,7 +184,7 @@ void Object::print(FILE *f) {
fprintf(f, ")");
break;
case objName:
- fprintf(f, "/%s", name);
+ fprintf(f, "/%s", cString);
break;
case objNull:
fprintf(f, "null");
@@ -191,9 +194,8 @@ void Object::print(FILE *f) {
for (i = 0; i < arrayGetLength(); ++i) {
if (i > 0)
fprintf(f, " ");
- arrayGetNF(i, &obj);
+ obj = arrayGetNF(i);
obj.print(f);
- obj.free();
}
fprintf(f, "]");
break;
@@ -201,9 +203,8 @@ void Object::print(FILE *f) {
fprintf(f, "<<");
for (i = 0; i < dictGetLength(); ++i) {
fprintf(f, " /%s ", dictGetKey(i));
- dictGetValNF(i, &obj);
+ obj = dictGetValNF(i);
obj.print(f);
- obj.free();
}
fprintf(f, " >>");
break;
@@ -214,7 +215,7 @@ void Object::print(FILE *f) {
fprintf(f, "%d %d R", ref.num, ref.gen);
break;
case objCmd:
- fprintf(f, "%s", cmd);
+ fprintf(f, "%s", cString);
break;
case objError:
fprintf(f, "<error>");
@@ -225,6 +226,9 @@ void Object::print(FILE *f) {
case objNone:
fprintf(f, "<none>");
break;
+ case objDead:
+ fprintf(f, "<dead>");
+ break;
case objInt64:
fprintf(f, "%lld", int64g);
break;