[waffle] [PATCH v2 07/10] nacl: untangle header inclusions

Emil Velikov emil.l.velikov at gmail.com
Wed Mar 25 06:56:46 PDT 2015


Use direct inclusion of the header providing the symbol. This improves
the overall readability and allows us to easily track which headers are
actually included via C++ files. This way we can add the proper notation.

v2: Do not use api_platform but context->display->platform.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/waffle/nacl/nacl_config.c      |  5 ++++-
 src/waffle/nacl/nacl_config.h      | 11 +++++++++++
 src/waffle/nacl/nacl_container.cpp |  4 ++++
 src/waffle/nacl/nacl_container.h   |  5 +++--
 src/waffle/nacl/nacl_context.c     | 14 +++++++-------
 src/waffle/nacl/nacl_context.h     |  5 ++---
 src/waffle/nacl/nacl_display.c     |  2 ++
 src/waffle/nacl/nacl_display.h     |  4 +++-
 src/waffle/nacl/nacl_platform.c    |  5 +++++
 src/waffle/nacl/nacl_platform.h    |  7 -------
 src/waffle/nacl/nacl_window.c      |  6 +++---
 src/waffle/nacl/nacl_window.h      |  4 ++--
 12 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/src/waffle/nacl/nacl_config.c b/src/waffle/nacl/nacl_config.c
index 16adc66..9017775 100644
--- a/src/waffle/nacl/nacl_config.c
+++ b/src/waffle/nacl/nacl_config.c
@@ -24,9 +24,12 @@
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "ppapi/c/pp_graphics_3d.h"
-#include "nacl_config.h"
+
+#include "wcore_config_attrs.h"
 #include "wcore_error.h"
 
+#include "nacl_config.h"
+
 bool
 nacl_config_destroy(struct wcore_config *wc_self)
 {
diff --git a/src/waffle/nacl/nacl_config.h b/src/waffle/nacl/nacl_config.h
index 47fa252..d461d43 100644
--- a/src/waffle/nacl/nacl_config.h
+++ b/src/waffle/nacl/nacl_config.h
@@ -25,9 +25,16 @@
 
 #pragma once
 
+#include <stdbool.h>
+#include <stdint.h>
+
 #include "wcore_config.h"
 #include "wcore_util.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct wcore_config_attrs;
 struct wcore_platform;
 
@@ -48,3 +55,7 @@ nacl_config_choose(struct wcore_platform *wc_plat,
 
 bool
 nacl_config_destroy(struct wcore_config *wc_self);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/waffle/nacl/nacl_container.cpp b/src/waffle/nacl/nacl_container.cpp
index 524d1d9..e3d89fd 100644
--- a/src/waffle/nacl/nacl_container.cpp
+++ b/src/waffle/nacl/nacl_container.cpp
@@ -29,6 +29,10 @@
 #include "ppapi/cpp/instance.h"
 #include "ppapi/cpp/module.h"
 #include "ppapi/c/pp_errors.h"
+
+#include "wcore_error.h"
+
+#include "nacl_config.h"
 #include "nacl_container.h"
 #include "nacl_swap_thread.h"
 
diff --git a/src/waffle/nacl/nacl_container.h b/src/waffle/nacl/nacl_container.h
index 6a864a4..055928a 100644
--- a/src/waffle/nacl/nacl_container.h
+++ b/src/waffle/nacl/nacl_container.h
@@ -23,8 +23,8 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include "nacl_config.h"
-#include "wcore_error.h"
+#include <stdbool.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -33,6 +33,7 @@ extern "C" {
 #define NACL_GLES2_LIBRARY "libppapi_gles2.so"
 
 struct nacl_container;
+struct nacl_config;
 
 struct nacl_container *nacl_container_init();
 void nacl_container_teardown(struct nacl_container *nc);
diff --git a/src/waffle/nacl/nacl_context.c b/src/waffle/nacl/nacl_context.c
index e67a913..52015c2 100644
--- a/src/waffle/nacl/nacl_context.c
+++ b/src/waffle/nacl/nacl_context.c
@@ -23,24 +23,24 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include "nacl_config.h"
+#include "nacl_container.h"
 #include "nacl_context.h"
-#include "api_priv.h"
+#include "nacl_platform.h"
 
 bool
 nacl_context_destroy(struct wcore_context *wc_self)
 {
-    struct nacl_context *self;
+    struct nacl_context *self = nacl_context(wc_self);
+    struct nacl_platform *plat;
     bool ok = true;
 
     if (!wc_self)
         return ok;
 
-    struct nacl_platform *nacl_plat =
-        nacl_platform(api_platform);
-
-    self = nacl_context(wc_self);
+    plat = nacl_platform(wc_self->display->platform);
 
-    nacl_container_context_fini(nacl_plat->nacl);
+    nacl_container_context_fini(plat->nacl);
 
     ok &= wcore_context_teardown(wc_self);
     free(self);
diff --git a/src/waffle/nacl/nacl_context.h b/src/waffle/nacl/nacl_context.h
index bb4481a..1330e27 100644
--- a/src/waffle/nacl/nacl_context.h
+++ b/src/waffle/nacl/nacl_context.h
@@ -25,12 +25,11 @@
 
 #pragma once
 
+#include <stdbool.h>
+
 #include "wcore_context.h"
 #include "wcore_util.h"
 
-#include "nacl_display.h"
-#include "nacl_platform.h"
-
 struct wcore_config;
 struct wcore_platform;
 
diff --git a/src/waffle/nacl/nacl_display.c b/src/waffle/nacl/nacl_display.c
index d1906fe..7e18ba3 100644
--- a/src/waffle/nacl/nacl_display.c
+++ b/src/waffle/nacl/nacl_display.c
@@ -23,6 +23,8 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include "wcore_error.h"
+
 #include "nacl_display.h"
 
 bool
diff --git a/src/waffle/nacl/nacl_display.h b/src/waffle/nacl/nacl_display.h
index 34eee21..9ae3b0a 100644
--- a/src/waffle/nacl/nacl_display.h
+++ b/src/waffle/nacl/nacl_display.h
@@ -25,8 +25,10 @@
 
 #pragma once
 
+#include <stdbool.h>
+#include <stdint.h>
+
 #include "wcore_display.h"
-#include "wcore_error.h"
 #include "wcore_util.h"
 
 struct wcore_platform;
diff --git a/src/waffle/nacl/nacl_platform.c b/src/waffle/nacl/nacl_platform.c
index b506113..a3d7625 100644
--- a/src/waffle/nacl/nacl_platform.c
+++ b/src/waffle/nacl/nacl_platform.c
@@ -26,8 +26,13 @@
 #include <dlfcn.h>
 #include <stdio.h>
 
+#include "nacl_config.h"
+#include "nacl_container.h"
+#include "nacl_context.h"
+#include "nacl_display.h"
 #include "nacl_dl.h"
 #include "nacl_platform.h"
+#include "nacl_window.h"
 
 static const struct wcore_platform_vtbl nacl_platform_vtbl;
 
diff --git a/src/waffle/nacl/nacl_platform.h b/src/waffle/nacl/nacl_platform.h
index 1a54697..259bea9 100644
--- a/src/waffle/nacl/nacl_platform.h
+++ b/src/waffle/nacl/nacl_platform.h
@@ -26,15 +26,8 @@
 #pragma once
 
 #include "wcore_platform.h"
-#include "wcore_error.h"
 #include "wcore_util.h"
 
-#include "nacl_config.h"
-#include "nacl_container.h"
-#include "nacl_context.h"
-#include "nacl_display.h"
-#include "nacl_window.h"
-
 struct nacl_platform {
     struct wcore_platform wcore;
     struct nacl_container *nacl;
diff --git a/src/waffle/nacl/nacl_window.c b/src/waffle/nacl/nacl_window.c
index 2ec583b..dc8d49c 100644
--- a/src/waffle/nacl/nacl_window.c
+++ b/src/waffle/nacl/nacl_window.c
@@ -23,10 +23,10 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#include "wcore_error.h"
 #include "wcore_attrib_list.h"
-#include "nacl_config.h"
-#include "nacl_display.h"
+#include "wcore_error.h"
+
+#include "nacl_container.h"
 #include "nacl_window.h"
 #include "nacl_platform.h"
 
diff --git a/src/waffle/nacl/nacl_window.h b/src/waffle/nacl/nacl_window.h
index d3465f3..c3e9957 100644
--- a/src/waffle/nacl/nacl_window.h
+++ b/src/waffle/nacl/nacl_window.h
@@ -25,10 +25,10 @@
 
 #pragma once
 
+#include <stdbool.h>
+
 #include "wcore_window.h"
 #include "wcore_util.h"
-#include "nacl_container.h"
-#include "nacl_platform.h"
 
 struct wcore_platform;
 
-- 
2.3.1



More information about the waffle mailing list