Pdfviewer: generate isAFoo() and getAsFoo() api for fields that can have multiple types.

Review URL: https://codereview.chromium.org/16968007

git-svn-id: http://skia.googlecode.com/svn/trunk@9646 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp
index 5a1fcc9..aa4417e 100644
--- a/experimental/PdfViewer/pdf_viewer_main.cpp
+++ b/experimental/PdfViewer/pdf_viewer_main.cpp
@@ -76,8 +76,104 @@
                         SkPdfObject** data);
 
 
+struct SkPdfFileSpec {};
+class SkPdfArray;
+struct SkPdfStream {};
+struct SkPdfDate {};
+struct SkPdfTree {};
+struct SkPdfFunction {};
+
+bool ArrayFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfArray* data);
+
+
+bool FileSpecFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfFileSpec* data);
+
+
+bool StreamFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfStream* data);
+
+bool TreeFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfTree** data);
+
+bool DateFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfDate* data);
+
+bool SkRectFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkRect* data);
+
+bool FunctionFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfFunction* data);
+
+
 #include "pdf_auto_gen.h"
 
+bool ArrayFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfArray* data) {return false;}
+
+bool FileSpecFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfFileSpec* data) {return false;}
+
+bool StreamFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfStream* data) {return false;}
+
+bool TreeFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfTree** data) {return false;}
+
+bool DateFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfDate* data) {return false;}
+
+bool SkRectFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkRect* data) {return false;}
+
+bool FunctionFromDictionary(const PdfMemDocument* pdfDoc,
+                        const PdfDictionary& dict,
+                        const char* key,
+                        const char* abr,
+                        SkPdfFunction* data) {return false;}
+
+
+
 /*
  * TODO(edisonn):
  * - encapsulate podofo in the pdf api so the skpdf does not know anything about podofo
@@ -1134,12 +1230,11 @@
     long bpc = image->BitsPerComponent();
     long width = image->Width();
     long height = image->Height();
-    SkPdfObject* colorSpaceDict = image->ColorSpace();
     std::string colorSpace = "DeviceRGB";
-    // TODO(edisonn): for multiple type fileds, generate code, like, isName(), isArray(), ...and fields like colorSpace_name(), colorSpace_array()
-    // so we do nto go to podofo anywhere in our cpp file
-    if (colorSpaceDict && colorSpaceDict->podofo() && colorSpaceDict->podofo()->IsName()) {
-        colorSpace = colorSpaceDict->podofo()->GetName().GetName();
+
+    // TODO(edisonn): color space can be an array too!
+    if (image->isColorSpaceAName()) {
+        colorSpace = image->getColorSpaceAsName();
     }
 
 /*