GAPII: Initialize global fields on spy construction. automerge: 7ca0792
automerge: a552067

* commit 'a5520673fbed47676132b95b4f21742e3eb37db5':
  GAPII: Initialize global fields on spy construction.
diff --git a/cc/gapii/gles_spy.h b/cc/gapii/gles_spy.h
index 455dec9..7d354e1 100644
--- a/cc/gapii/gles_spy.h
+++ b/cc/gapii/gles_spy.h
@@ -342,6 +342,13 @@
 inline void GlesSpy::init(std::shared_ptr<gapic::Encoder> encoder) {
     SpyBase::init(encoder);
     mImports.Resolve();
+    NextContextID = 0;
+    CurrentThread = 0;
+    Contexts = ThreadIDToContext__R();
+    EGLContexts = EGLContextToContext__R();
+    GLXContexts = GLXContextToContext__R();
+    WGLContexts = HGLRCToContext__R();
+    CGLContexts = CGLContextObjToContext__R();
 }
 
 inline int GlesSpy::eglInitialize(void* dpy, int* major, int* minor) {
diff --git a/gfxapi/templates/api_spy.h.tmpl b/gfxapi/templates/api_spy.h.tmpl
index ab3eee6..2c58746 100644
--- a/gfxapi/templates/api_spy.h.tmpl
+++ b/gfxapi/templates/api_spy.h.tmpl
@@ -73,6 +73,14 @@
   inline void {{$spyname}}::init(std::shared_ptr<gapic::Encoder> encoder) {
     SpyBase::init(encoder);
     mImports.Resolve();
+    {{range $g := $.Globals}}
+      {{$g.Name}} = §
+        {{if $g.Default}}
+          {{Macro "C++.Read" $g.Default}};
+        {{else}}
+          {{Macro "C++.Null" (TypeOf $g)}};
+        {{end}}
+    {{end}}
   }

   {{ForEach (AllCommands $) "MethodImplementation" | JoinWith "\n¶"}}
diff --git a/gfxapi/templates/cpp_common.tmpl b/gfxapi/templates/cpp_common.tmpl
index 7992cac..0a674e9 100644
--- a/gfxapi/templates/cpp_common.tmpl
+++ b/gfxapi/templates/cpp_common.tmpl
@@ -123,9 +123,10 @@
   {{else if IsPseudonym  $}}{{Template "C++.Null" $.To}}
   {{else if IsClass      $}}{{Template "C++.Type" $}}()
   {{else if IsSlice      $}}{{Template "C++.Type" $}}()
+  {{else if IsMap        $}}{{Template "C++.Type" $}}()
   {{else if IsPointer    $}}nullptr
   {{else if IsReference  $}}{{Template "C++.Type" $}}()
-  {{else}}{{Error "macro Type called with unsupported type: %s" $.Name}}
+  {{else}}{{Error "macro Null called with unsupported type: %s" $.Name}}
   {{end}}
 {{end}}