aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pugl/detail/cairo_gl.h (renamed from pugl/cairo_gl.h)0
-rw-r--r--pugl/detail/implementation.c (renamed from pugl/pugl_internal.h)14
-rw-r--r--pugl/detail/implementation.h46
-rw-r--r--pugl/detail/mac.m (renamed from pugl/pugl_osx.m)6
-rw-r--r--pugl/detail/types.h (renamed from pugl/pugl_internal_types.h)11
-rw-r--r--pugl/detail/win.c (renamed from pugl/pugl_win.c)6
-rw-r--r--pugl/detail/win.h (renamed from pugl/pugl_win.h)4
-rw-r--r--pugl/detail/win_cairo.c (renamed from pugl/pugl_win_cairo.c)6
-rw-r--r--pugl/detail/win_gl.c (renamed from pugl/pugl_win_gl.c)6
-rw-r--r--pugl/detail/x11.c (renamed from pugl/pugl_x11.c)6
-rw-r--r--pugl/detail/x11.h (renamed from pugl/pugl_x11.h)5
-rw-r--r--pugl/detail/x11_cairo.c (renamed from pugl/pugl_x11_cairo.c)6
-rw-r--r--pugl/detail/x11_gl.c (renamed from pugl/pugl_x11_gl.c)6
-rw-r--r--pugl/pugl.h2
-rw-r--r--pugl/pugl.hpp2
-rw-r--r--wscript29
16 files changed, 98 insertions, 57 deletions
diff --git a/pugl/cairo_gl.h b/pugl/detail/cairo_gl.h
index b6e8566..b6e8566 100644
--- a/pugl/cairo_gl.h
+++ b/pugl/detail/cairo_gl.h
diff --git a/pugl/pugl_internal.h b/pugl/detail/implementation.c
index 18d7a7a..5cd7ce5 100644
--- a/pugl/pugl_internal.h
+++ b/pugl/detail/implementation.c
@@ -15,21 +15,15 @@
*/
/**
- @file pugl_internal.h Platform-independent implementation.
-
- Note that this file contains function definitions, so it must be compiled
- into the final binary exactly once. Each platform specific implementation
- file including it once should achieve this.
+ @file implementation.c Platform-independent implementation.
*/
+#include "pugl/detail/implementation.h"
#include "pugl/pugl.h"
-#include "pugl/pugl_internal_types.h"
#include <stdlib.h>
#include <string.h>
-PuglInternals* puglInitInternals(void);
-
static PuglHints
puglDefaultHints(void)
{
@@ -222,7 +216,7 @@ puglSetEventFunc(PuglView* view, PuglEventFunc eventFunc)
}
/** Return the code point for buf, or the replacement character on error. */
-static inline uint32_t
+uint32_t
puglDecodeUTF8(const uint8_t* buf)
{
#define FAIL_IF(cond) do { if (cond) return 0xFFFD; } while (0)
@@ -255,7 +249,7 @@ puglDecodeUTF8(const uint8_t* buf)
return 0xFFFD;
}
-static void
+void
puglDispatchEvent(PuglView* view, const PuglEvent* event)
{
switch (event->type) {
diff --git a/pugl/detail/implementation.h b/pugl/detail/implementation.h
new file mode 100644
index 0000000..50f54f5
--- /dev/null
+++ b/pugl/detail/implementation.h
@@ -0,0 +1,46 @@
+/*
+ Copyright 2012-2019 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+/**
+ @file implementation.h Shared declarations for implementation.
+*/
+
+#ifndef PUGL_DETAIL_IMPLEMENTATION_H
+#define PUGL_DETAIL_IMPLEMENTATION_H
+
+#include "pugl/detail/types.h"
+#include "pugl/pugl.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Allocate and initialise internals (implemented once per platform) */
+PuglInternals* puglInitInternals(void);
+
+/** Return the Unicode code point for `buf` or the replacement character. */
+uint32_t puglDecodeUTF8(const uint8_t* buf);
+
+/** Dispatch `event` to `view`, optimising configure/expose if possible. */
+void puglDispatchEvent(PuglView* view, const PuglEvent* event);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif // PUGL_DETAIL_IMPLEMENTATION_H
diff --git a/pugl/pugl_osx.m b/pugl/detail/mac.m
index a5ec994..83adcd1 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/detail/mac.m
@@ -16,18 +16,18 @@
*/
/**
- @file pugl_osx.m MacOS implementation.
+ @file mac.m MacOS implementation.
*/
#define GL_SILENCE_DEPRECATION 1
+#include "pugl/detail/implementation.h"
#include "pugl/gl.h"
#include "pugl/pugl_gl_backend.h"
-#include "pugl/pugl_internal.h"
#ifdef PUGL_HAVE_CAIRO
+#include "pugl/detail/cairo_gl.h"
#include "pugl/pugl_cairo_backend.h"
-#include "pugl/cairo_gl.h"
#endif
#import <Cocoa/Cocoa.h>
diff --git a/pugl/pugl_internal_types.h b/pugl/detail/types.h
index 9a0bedc..0cf9a99 100644
--- a/pugl/pugl_internal_types.h
+++ b/pugl/detail/types.h
@@ -15,11 +15,11 @@
*/
/**
- @file pugl_internal_types.h Private platform-independent type definitions.
+ @file types.h Shared internal type definitions.
*/
-#ifndef PUGL_INTERNAL_TYPES_H
-#define PUGL_INTERNAL_TYPES_H
+#ifndef PUGL_DETAIL_TYPES_H
+#define PUGL_DETAIL_TYPES_H
#include "pugl/pugl.h"
@@ -38,6 +38,7 @@
/** Platform-specific internals. */
typedef struct PuglInternalsImpl PuglInternals;
+/** View hints. */
typedef struct {
int context_version_major;
int context_version_minor;
@@ -76,7 +77,7 @@ struct PuglViewImpl {
bool visible;
};
-/** Opaque surface used by draw context. */
+/** Opaque surface used by graphics backend. */
typedef void PuglSurface;
/** Graphics backend interface. */
@@ -103,4 +104,4 @@ struct PuglBackendImpl {
void* (*getContext)(PuglView*);
};
-#endif // PUGL_INTERNAL_TYPES_H
+#endif // PUGL_DETAIL_TYPES_H
diff --git a/pugl/pugl_win.c b/pugl/detail/win.c
index 2dd3fcc..953c620 100644
--- a/pugl/pugl_win.c
+++ b/pugl/detail/win.c
@@ -15,11 +15,11 @@
*/
/**
- @file pugl_win.c Windows implementation.
+ @file win.c Windows implementation.
*/
-#include "pugl/pugl_internal.h"
-#include "pugl/pugl_win.h"
+#include "pugl/detail/implementation.h"
+#include "pugl/detail/win.h"
#include <windows.h>
#include <windowsx.h>
diff --git a/pugl/pugl_win.h b/pugl/detail/win.h
index c2dba2a..9af5cbb 100644
--- a/pugl/pugl_win.h
+++ b/pugl/detail/win.h
@@ -15,10 +15,10 @@
*/
/**
- @file pugl_win.h Shared definitions for Windows implementation.
+ @file win.h Shared definitions for Windows implementation.
*/
-#include "pugl/pugl_internal_types.h"
+#include "pugl/detail/implementation.h"
#include <windows.h>
diff --git a/pugl/pugl_win_cairo.c b/pugl/detail/win_cairo.c
index 0d2fb5f..c322f25 100644
--- a/pugl/pugl_win_cairo.c
+++ b/pugl/detail/win_cairo.c
@@ -15,12 +15,12 @@
*/
/**
- @file pugl_win_cairo.c Cairo graphics backend for Windows.
+ @file win_cairo.c Cairo graphics backend for Windows.
*/
+#include "pugl/detail/types.h"
+#include "pugl/detail/win.h"
#include "pugl/pugl_cairo_backend.h"
-#include "pugl/pugl_internal_types.h"
-#include "pugl/pugl_win.h"
#include <cairo-win32.h>
#include <cairo.h>
diff --git a/pugl/pugl_win_gl.c b/pugl/detail/win_gl.c
index 17528d5..17ee68d 100644
--- a/pugl/pugl_win_gl.c
+++ b/pugl/detail/win_gl.c
@@ -15,12 +15,12 @@
*/
/**
- @file pugl_win_gl.c OpenGL graphics backend for Windows.
+ @file win_gl.c OpenGL graphics backend for Windows.
*/
+#include "pugl/detail/types.h"
+#include "pugl/detail/win.h"
#include "pugl/pugl_gl_backend.h"
-#include "pugl/pugl_internal_types.h"
-#include "pugl/pugl_win.h"
#include <windows.h>
diff --git a/pugl/pugl_x11.c b/pugl/detail/x11.c
index 5fcbd9f..70341ea 100644
--- a/pugl/pugl_x11.c
+++ b/pugl/detail/x11.c
@@ -17,13 +17,13 @@
*/
/**
- @file pugl_x11.c X11 implementation.
+ @file x11.c X11 implementation.
*/
#define _POSIX_C_SOURCE 199309L
-#include "pugl/pugl_internal.h"
-#include "pugl/pugl_x11.h"
+#include "pugl/detail/implementation.h"
+#include "pugl/detail/x11.h"
#include <X11/Xatom.h>
#include <X11/Xlib.h>
diff --git a/pugl/pugl_x11.h b/pugl/detail/x11.h
index e104a15..98f42b0 100644
--- a/pugl/pugl_x11.h
+++ b/pugl/detail/x11.h
@@ -15,11 +15,10 @@
*/
/**
- @file pugl_x11.h Shared definitions for X11 implementation.
+ @file x11.h Shared definitions for X11 implementation.
*/
-#include "pugl/pugl.h"
-#include "pugl/pugl_internal_types.h"
+#include "pugl/detail/implementation.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
diff --git a/pugl/pugl_x11_cairo.c b/pugl/detail/x11_cairo.c
index bcec626..97624a2 100644
--- a/pugl/pugl_x11_cairo.c
+++ b/pugl/detail/x11_cairo.c
@@ -15,12 +15,12 @@
*/
/**
- @file pugl_x11_cairo.c Cairo graphics backend for X11.
+ @file x11_cairo.c Cairo graphics backend for X11.
*/
+#include "pugl/detail/types.h"
+#include "pugl/detail/x11.h"
#include "pugl/pugl_cairo_backend.h"
-#include "pugl/pugl_internal_types.h"
-#include "pugl/pugl_x11.h"
#include <X11/Xutil.h>
#include <cairo-xlib.h>
diff --git a/pugl/pugl_x11_gl.c b/pugl/detail/x11_gl.c
index 8ccc92d..7fcf169 100644
--- a/pugl/pugl_x11_gl.c
+++ b/pugl/detail/x11_gl.c
@@ -15,12 +15,12 @@
*/
/**
- @file pugl_x11_gl.c OpenGL graphics backend for X11.
+ @file x11_gl.c OpenGL graphics backend for X11.
*/
+#include "pugl/detail/implementation.h"
+#include "pugl/detail/x11.h"
#include "pugl/pugl_gl_backend.h"
-#include "pugl/pugl_internal_types.h"
-#include "pugl/pugl_x11.h"
#include <GL/gl.h>
#include <GL/glx.h>
diff --git a/pugl/pugl.h b/pugl/pugl.h
index fab2b2b..903f1cb 100644
--- a/pugl/pugl.h
+++ b/pugl/pugl.h
@@ -15,7 +15,7 @@
*/
/**
- @file pugl.h Public API.
+ @file pugl.h Public Pugl API.
*/
#ifndef PUGL_H_INCLUDED
diff --git a/pugl/pugl.hpp b/pugl/pugl.hpp
index ec96889..c2602dd 100644
--- a/pugl/pugl.hpp
+++ b/pugl/pugl.hpp
@@ -15,7 +15,7 @@
*/
/**
- @file pugl.hpp C++ wrapper for API.
+ @file pugl.hpp Public Pugl C++ API wrapper.
*/
#ifndef PUGL_HPP_INCLUDED
diff --git a/wscript b/wscript
index bbaeff6..e239f36 100644
--- a/wscript
+++ b/wscript
@@ -93,29 +93,30 @@ def build(bld):
autowaf.build_pc(bld, 'PUGL', PUGL_VERSION, PUGL_MAJOR_VERSION, [],
{'PUGL_MAJOR_VERSION': PUGL_MAJOR_VERSION})
- libflags = ['-fvisibility=hidden']
- framework = []
- libs = []
+ libflags = ['-fvisibility=hidden']
+ framework = []
+ libs = []
+ lib_source = ['pugl/detail/implementation.c']
if bld.env.TARGET_PLATFORM == 'win32':
- lib_source = ['pugl/pugl_win.c']
- libs = ['gdi32', 'user32']
+ lib_source += ['pugl/detail/win.c']
+ libs = ['gdi32', 'user32']
if bld.is_defined('HAVE_GL'):
- lib_source += ['pugl/pugl_win_gl.c']
+ lib_source += ['pugl/detail/win_gl.c']
libs += ['opengl32']
if bld.is_defined('HAVE_CAIRO'):
- lib_source += ['pugl/pugl_win_cairo.c']
+ lib_source += ['pugl/detail/win_cairo.c']
libs += ['cairo']
elif bld.env.TARGET_PLATFORM == 'darwin':
- lib_source = ['pugl/pugl_osx.m']
- framework = ['Cocoa', 'OpenGL']
+ lib_source += ['pugl/detail/mac.m']
+ framework = ['Cocoa', 'OpenGL']
else:
- lib_source = ['pugl/pugl_x11.c']
- libs = ['X11']
+ lib_source += ['pugl/detail/x11.c']
+ libs = ['X11']
if bld.is_defined('HAVE_GL'):
- lib_source += ['pugl/pugl_x11_gl.c']
+ lib_source += ['pugl/detail/x11_gl.c']
libs += ['GL']
if bld.is_defined('HAVE_CAIRO'):
- lib_source += ['pugl/pugl_x11_cairo.c']
+ lib_source += ['pugl/detail/x11_cairo.c']
if bld.env['MSVC_COMPILER']:
libflags = []
else:
@@ -212,7 +213,7 @@ def lint(ctx):
"-misc-unused-parameters," +
"-hicpp-signed-bitwise," + # FIXME?
"-readability-else-after-return\" " +
- "../pugl/*.c ../*.c")
+ "../pugl/detail/*.c ../test/*.c")
subprocess.call(cmd, cwd='build', shell=True)
# Alias .m files to be compiled like .c files, gcc will do the right thing.