Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: experimental/PdfViewer/pdfparser/native/SkPdfNativeObject.h

Issue 26700002: remove tracking code, as it polutes the code readability. Should be added back, in a less eficient … (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkPdfNativeObject_DEFINED 8 #ifndef SkPdfNativeObject_DEFINED
9 #define SkPdfNativeObject_DEFINED 9 #define SkPdfNativeObject_DEFINED
10 10
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 static SkPdfFileSpec nyi; 250 static SkPdfFileSpec nyi;
251 return nyi; 251 return nyi;
252 } 252 }
253 253
254 // TODO(edisonn): NYI 254 // TODO(edisonn): NYI
255 SkPdfTree& treeValue() const { 255 SkPdfTree& treeValue() const {
256 static SkPdfTree nyi; 256 static SkPdfTree nyi;
257 return nyi; 257 return nyi;
258 } 258 }
259 259
260 static void makeBoolean(bool value, SkPdfNativeObject* obj GET_TRACK_PARAMET ERS) { 260 // TODO(edisonn) impl store
261 STORE_TRACK_PARAMETERS(obj); 261 //STORE_TRACK_PARAMETERS(obj);
262
263 static void makeBoolean(bool value, SkPdfNativeObject* obj) {
262 264
263 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 265 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
264 266
265 obj->fObjectType = kBoolean_PdfObjectType; 267 obj->fObjectType = kBoolean_PdfObjectType;
266 obj->fBooleanValue = value; 268 obj->fBooleanValue = value;
267 } 269 }
268 270
269 static SkPdfNativeObject makeBoolean(bool value GET_TRACK_PARAMETERS) { 271 static SkPdfNativeObject makeBoolean(bool value) {
270 SkPdfNativeObject obj; 272 SkPdfNativeObject obj;
271 273
272 STORE_TRACK_PARAMETERS(&obj);
273
274 obj.fObjectType = kBoolean_PdfObjectType; 274 obj.fObjectType = kBoolean_PdfObjectType;
275 obj.fBooleanValue = value; 275 obj.fBooleanValue = value;
276 return obj; 276 return obj;
277 } 277 }
278 278
279 static void makeInteger(int64_t value, SkPdfNativeObject* obj GET_TRACK_PARA METERS) { 279 static void makeInteger(int64_t value, SkPdfNativeObject* obj) {
280 STORE_TRACK_PARAMETERS(obj);
281
282 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 280 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
283 281
284 obj->fObjectType = kInteger_PdfObjectType; 282 obj->fObjectType = kInteger_PdfObjectType;
285 obj->fIntegerValue = value; 283 obj->fIntegerValue = value;
286 } 284 }
287 285
288 static void makeReal(double value, SkPdfNativeObject* obj GET_TRACK_PARAMETE RS) { 286 static void makeReal(double value, SkPdfNativeObject* obj) {
289 STORE_TRACK_PARAMETERS(obj);
290
291 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 287 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
292 288
293 obj->fObjectType = kReal_PdfObjectType; 289 obj->fObjectType = kReal_PdfObjectType;
294 obj->fRealValue = value; 290 obj->fRealValue = value;
295 } 291 }
296 292
297 static void makeNull(SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 293 static void makeNull(SkPdfNativeObject* obj) {
298 STORE_TRACK_PARAMETERS(obj);
299
300 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 294 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
301 295
302 obj->fObjectType = kNull_PdfObjectType; 296 obj->fObjectType = kNull_PdfObjectType;
303 } 297 }
304 298
305 static SkPdfNativeObject makeNull(GET_TRACK_PARAMETERS0) { 299 static SkPdfNativeObject makeNull() {
306 SkPdfNativeObject obj; 300 SkPdfNativeObject obj;
307 301
308 STORE_TRACK_PARAMETERS(&obj);
309
310 obj.fObjectType = kNull_PdfObjectType; 302 obj.fObjectType = kNull_PdfObjectType;
311 return obj; 303 return obj;
312 } 304 }
313 305
314 static SkPdfNativeObject kNull; 306 static SkPdfNativeObject kNull;
315 307
316 static void makeNumeric(const unsigned char* start, const unsigned char* end , SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 308 static void makeNumeric(const unsigned char* start, const unsigned char* end , SkPdfNativeObject* obj) {
317 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 309 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
318 310
319 // TODO(edisonn): NYI properly 311 // TODO(edisonn): NYI properly
320 // if has dot (impl), or exceeds max int, is real, otherwise is int 312 // if has dot (impl), or exceeds max int, is real, otherwise is int
321 bool isInt = true; 313 bool isInt = true;
322 for (const unsigned char* current = start; current < end; current++) { 314 for (const unsigned char* current = start; current < end; current++) {
323 if (*current == '.') { 315 if (*current == '.') {
324 isInt = false; 316 isInt = false;
325 break; 317 break;
326 } 318 }
327 // TODO(edisonn): report parse issue with numbers like "24asdasd123" 319 // TODO(edisonn): report parse issue with numbers like "24asdasd123"
328 } 320 }
329 if (isInt) { 321 if (isInt) {
330 makeInteger(atol((const char*)start), obj PUT_TRACK_PARAMETERS); 322 makeInteger(atol((const char*)start), obj);
331 } else { 323 } else {
332 makeReal(atof((const char*)start), obj PUT_TRACK_PARAMETERS); 324 makeReal(atof((const char*)start), obj);
333 } 325 }
334 } 326 }
335 327
336 static void makeReference(unsigned int id, unsigned int gen, SkPdfNativeObje ct* obj GET_TRACK_PARAMETERS) { 328 static void makeReference(unsigned int id, unsigned int gen, SkPdfNativeObje ct* obj) {
337 STORE_TRACK_PARAMETERS(obj);
338
339 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 329 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
340 330
341 obj->fObjectType = kReference_PdfObjectType; 331 obj->fObjectType = kReference_PdfObjectType;
342 obj->fRef.fId = id; 332 obj->fRef.fId = id;
343 obj->fRef.fGen = gen; 333 obj->fRef.fGen = gen;
344 } 334 }
345 335
346 static void resetAndMakeReference(unsigned int id, unsigned int gen, SkPdfNa tiveObject* obj GET_TRACK_PARAMETERS) { 336 static void resetAndMakeReference(unsigned int id, unsigned int gen, SkPdfNa tiveObject* obj) {
347 obj->reset(); 337 obj->reset();
348 makeReference(id, gen, obj PUT_TRACK_PARAMETERS); 338 makeReference(id, gen, obj);
349 } 339 }
350 340
351 341
352 static void makeString(const unsigned char* start, SkPdfNativeObject* obj GE T_TRACK_PARAMETERS) { 342 static void makeString(const unsigned char* start, SkPdfNativeObject* obj) {
353 makeStringCore(start, strlen((const char*)start), obj, kString_PdfObject Type PUT_TRACK_PARAMETERS); 343 makeStringCore(start, strlen((const char*)start), obj, kString_PdfObject Type);
354 } 344 }
355 345
356 static void makeString(const unsigned char* start, const unsigned char* end, SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 346 static void makeString(const unsigned char* start, const unsigned char* end, SkPdfNativeObject* obj) {
357 makeStringCore(start, end - start, obj, kString_PdfObjectType PUT_TRACK_ PARAMETERS); 347 makeStringCore(start, end - start, obj, kString_PdfObjectType);
358 } 348 }
359 349
360 static void makeString(const unsigned char* start, size_t bytes, SkPdfNative Object* obj GET_TRACK_PARAMETERS) { 350 static void makeString(const unsigned char* start, size_t bytes, SkPdfNative Object* obj) {
361 makeStringCore(start, bytes, obj, kString_PdfObjectType PUT_TRACK_PARAME TERS); 351 makeStringCore(start, bytes, obj, kString_PdfObjectType);
362 } 352 }
363 353
364 354
365 static void makeHexString(const unsigned char* start, SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 355 static void makeHexString(const unsigned char* start, SkPdfNativeObject* obj ) {
366 makeStringCore(start, strlen((const char*)start), obj, kHexString_PdfObj ectType PUT_TRACK_PARAMETERS); 356 makeStringCore(start, strlen((const char*)start), obj, kHexString_PdfObj ectType);
367 } 357 }
368 358
369 static void makeHexString(const unsigned char* start, const unsigned char* e nd, SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 359 static void makeHexString(const unsigned char* start, const unsigned char* e nd, SkPdfNativeObject* obj) {
370 makeStringCore(start, end - start, obj, kHexString_PdfObjectType PUT_TRA CK_PARAMETERS); 360 makeStringCore(start, end - start, obj, kHexString_PdfObjectType);
371 } 361 }
372 362
373 static void makeHexString(const unsigned char* start, size_t bytes, SkPdfNat iveObject* obj GET_TRACK_PARAMETERS) { 363 static void makeHexString(const unsigned char* start, size_t bytes, SkPdfNat iveObject* obj) {
374 makeStringCore(start, bytes, obj, kHexString_PdfObjectType PUT_TRACK_PAR AMETERS); 364 makeStringCore(start, bytes, obj, kHexString_PdfObjectType);
375 } 365 }
376 366
377 367
378 static void makeName(const unsigned char* start, SkPdfNativeObject* obj GET_ TRACK_PARAMETERS) { 368 static void makeName(const unsigned char* start, SkPdfNativeObject* obj) {
379 makeStringCore(start, strlen((const char*)start), obj, kName_PdfObjectTy pe PUT_TRACK_PARAMETERS); 369 makeStringCore(start, strlen((const char*)start), obj, kName_PdfObjectTy pe);
380 } 370 }
381 371
382 static void makeName(const unsigned char* start, const unsigned char* end, S kPdfNativeObject* obj GET_TRACK_PARAMETERS) { 372 static void makeName(const unsigned char* start, const unsigned char* end, S kPdfNativeObject* obj) {
383 makeStringCore(start, end - start, obj, kName_PdfObjectType PUT_TRACK_PA RAMETERS); 373 makeStringCore(start, end - start, obj, kName_PdfObjectType);
384 } 374 }
385 375
386 static void makeName(const unsigned char* start, size_t bytes, SkPdfNativeOb ject* obj GET_TRACK_PARAMETERS) { 376 static void makeName(const unsigned char* start, size_t bytes, SkPdfNativeOb ject* obj) {
387 makeStringCore(start, bytes, obj, kName_PdfObjectType PUT_TRACK_PARAMETE RS); 377 makeStringCore(start, bytes, obj, kName_PdfObjectType);
388 } 378 }
389 379
390 380
391 static void makeKeyword(const unsigned char* start, SkPdfNativeObject* obj G ET_TRACK_PARAMETERS) { 381 static void makeKeyword(const unsigned char* start, SkPdfNativeObject* obj) {
392 makeStringCore(start, strlen((const char*)start), obj, kKeyword_PdfObjec tType PUT_TRACK_PARAMETERS); 382 makeStringCore(start, strlen((const char*)start), obj, kKeyword_PdfObjec tType);
393 } 383 }
394 384
395 static void makeKeyword(const unsigned char* start, const unsigned char* end , SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 385 static void makeKeyword(const unsigned char* start, const unsigned char* end , SkPdfNativeObject* obj) {
396 makeStringCore(start, end - start, obj, kKeyword_PdfObjectType PUT_TRACK _PARAMETERS); 386 makeStringCore(start, end - start, obj, kKeyword_PdfObjectType);
397 } 387 }
398 388
399 static void makeKeyword(const unsigned char* start, size_t bytes, SkPdfNativ eObject* obj GET_TRACK_PARAMETERS) { 389 static void makeKeyword(const unsigned char* start, size_t bytes, SkPdfNativ eObject* obj) {
400 makeStringCore(start, bytes, obj, kKeyword_PdfObjectType PUT_TRACK_PARAM ETERS); 390 makeStringCore(start, bytes, obj, kKeyword_PdfObjectType);
401 } 391 }
402 392
403 393
404 394
405 // TODO(edisonn): make the functions to return SkPdfArray, move these functi ons in SkPdfArray 395 // TODO(edisonn): make the functions to return SkPdfArray, move these functi ons in SkPdfArray
406 static void makeEmptyArray(SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 396 static void makeEmptyArray(SkPdfNativeObject* obj) {
407 STORE_TRACK_PARAMETERS(obj);
408
409 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 397 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
410 398
411 obj->fObjectType = kArray_PdfObjectType; 399 obj->fObjectType = kArray_PdfObjectType;
412 obj->fArray = new SkTDArray<SkPdfNativeObject*>(); 400 obj->fArray = new SkTDArray<SkPdfNativeObject*>();
413 // return (SkPdfArray*)obj; 401 // return (SkPdfArray*)obj;
414 } 402 }
415 403
416 bool appendInArray(SkPdfNativeObject* obj) { 404 bool appendInArray(SkPdfNativeObject* obj) {
417 SkASSERT(fObjectType == kArray_PdfObjectType); 405 SkASSERT(fObjectType == kArray_PdfObjectType);
418 if (fObjectType != kArray_PdfObjectType) { 406 if (fObjectType != kArray_PdfObjectType) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 const SkPdfNativeObject* operator[](int i) const { 457 const SkPdfNativeObject* operator[](int i) const {
470 SkPdfMarkObjectUsed(); 458 SkPdfMarkObjectUsed();
471 459
472 SkASSERT(fObjectType == kArray_PdfObjectType); 460 SkASSERT(fObjectType == kArray_PdfObjectType);
473 461
474 return (*fArray)[i]; 462 return (*fArray)[i];
475 } 463 }
476 464
477 465
478 // TODO(edisonn): make the functions to return SkPdfDictionary, move these f unctions in SkPdfDictionary 466 // TODO(edisonn): make the functions to return SkPdfDictionary, move these f unctions in SkPdfDictionary
479 static void makeEmptyDictionary(SkPdfNativeObject* obj GET_TRACK_PARAMETERS) { 467 static void makeEmptyDictionary(SkPdfNativeObject* obj) {
480 STORE_TRACK_PARAMETERS(obj);
481
482 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 468 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
483 469
484 obj->fObjectType = kDictionary_PdfObjectType; 470 obj->fObjectType = kDictionary_PdfObjectType;
485 obj->fMap = new SkTDict<SkPdfNativeObject*>(1); 471 obj->fMap = new SkTDict<SkPdfNativeObject*>(1);
486 obj->fStr.fBuffer = NULL; 472 obj->fStr.fBuffer = NULL;
487 obj->fStr.fBytes = 0; 473 obj->fStr.fBytes = 0;
488 } 474 }
489 475
490 // TODO(edisonn): get all the possible names from spec, and compute a hash f unction 476 // TODO(edisonn): get all the possible names from spec, and compute a hash f unction
491 // that would create no overlaps in the same dictionary 477 // that would create no overlaps in the same dictionary
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1174
1189 default: 1175 default:
1190 str = "Error"; 1176 str = "Error";
1191 break; 1177 break;
1192 } 1178 }
1193 1179
1194 return str; 1180 return str;
1195 } 1181 }
1196 1182
1197 private: 1183 private:
1198 static void makeStringCore(const unsigned char* start, SkPdfNativeObject* ob j, ObjectType type GET_TRACK_PARAMETERS) { 1184 static void makeStringCore(const unsigned char* start, SkPdfNativeObject* ob j, ObjectType type) {
1199 makeStringCore(start, strlen((const char*)start), obj, type PUT_TRACK_PA RAMETERS); 1185 makeStringCore(start, strlen((const char*)start), obj, type);
1200 } 1186 }
1201 1187
1202 static void makeStringCore(const unsigned char* start, const unsigned char* end, SkPdfNativeObject* obj, ObjectType type GET_TRACK_PARAMETERS) { 1188 static void makeStringCore(const unsigned char* start, const unsigned char* end, SkPdfNativeObject* obj, ObjectType type) {
1203 makeStringCore(start, end - start, obj, type PUT_TRACK_PARAMETERS); 1189 makeStringCore(start, end - start, obj, type);
1204 } 1190 }
1205 1191
1206 static void makeStringCore(const unsigned char* start, size_t bytes, SkPdfNa tiveObject* obj, ObjectType type GET_TRACK_PARAMETERS) { 1192 static void makeStringCore(const unsigned char* start, size_t bytes, SkPdfNa tiveObject* obj, ObjectType type) {
1207 STORE_TRACK_PARAMETERS(obj);
1208 1193
1209 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType); 1194 SkASSERT(obj->fObjectType == kInvalid_PdfObjectType);
1210 1195
1211 obj->fObjectType = type; 1196 obj->fObjectType = type;
1212 obj->fStr.fBuffer = start; 1197 obj->fStr.fBuffer = start;
1213 obj->fStr.fBytes = bytes; 1198 obj->fStr.fBytes = bytes;
1214 } 1199 }
1215 1200
1216 bool applyFilter(const char* name); 1201 bool applyFilter(const char* name);
1217 bool applyFlateDecodeFilter(); 1202 bool applyFlateDecodeFilter();
1218 bool applyDCTDecodeFilter(); 1203 bool applyDCTDecodeFilter();
1219 }; 1204 };
1220 1205
1221 class SkPdfStream : public SkPdfNativeObject {}; 1206 class SkPdfStream : public SkPdfNativeObject {};
1222 class SkPdfArray : public SkPdfNativeObject {}; 1207 class SkPdfArray : public SkPdfNativeObject {};
1223 class SkPdfString : public SkPdfNativeObject {}; 1208 class SkPdfString : public SkPdfNativeObject {};
1224 class SkPdfHexString : public SkPdfNativeObject {}; 1209 class SkPdfHexString : public SkPdfNativeObject {};
1225 class SkPdfInteger : public SkPdfNativeObject {}; 1210 class SkPdfInteger : public SkPdfNativeObject {};
1226 class SkPdfReal : public SkPdfNativeObject {}; 1211 class SkPdfReal : public SkPdfNativeObject {};
1227 class SkPdfNumber : public SkPdfNativeObject {}; 1212 class SkPdfNumber : public SkPdfNativeObject {};
1228 1213
1229 class SkPdfName : public SkPdfNativeObject { 1214 class SkPdfName : public SkPdfNativeObject {
1230 SkPdfName() : SkPdfNativeObject() { 1215 SkPdfName() : SkPdfNativeObject() {
1231 SkPdfNativeObject::makeName((const unsigned char*)"", this PUT_TRACK_PAR AMETERS_SRC); 1216 SkPdfNativeObject::makeName((const unsigned char*)"", this);
1232 } 1217 }
1233 public: 1218 public:
1234 SkPdfName(char* name) : SkPdfNativeObject() { 1219 SkPdfName(char* name) : SkPdfNativeObject() {
1235 this->makeName((const unsigned char*)name, this PUT_TRACK_PARAMETERS_SRC ); 1220 this->makeName((const unsigned char*)name, this);
1236 } 1221 }
1237 }; 1222 };
1238 1223
1239 #endif // SkPdfNativeObject 1224 #endif // SkPdfNativeObject
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698