ObjectivelyMVC 0.1.0
Object oriented MVC framework for OpenGL, SDL2 and GNU C
View+JSON.h
Go to the documentation of this file.
1/*
2 * ObjectivelyMVC: Object oriented MVC framework for OpenGL, SDL2 and GNU C.
3 * Copyright (C) 2014 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
27
36typedef enum {
37
42
47
53
58
63
68
76
81
86
91
96
101
106
111
117
123
140
146
147} InletType;
148
149typedef struct Inlet Inlet;
150
155struct Inlet {
156
160 const char *name;
161
166
170 ident dest;
171
175 ident data;
176};
177
186typedef void (*InletBinding)(const Inlet *inlet, ident obj);
187
192
193typedef struct Outlet Outlet;
194
200struct Outlet {
201
205 const char *identifier;
206
211};
212
216#define MakeInlet(name, type, dest, data) (Inlet) { (name), (type), (dest), (ident) (data) }
217
221#define MakeInlets(...) \
222 { \
223 __VA_ARGS__, \
224 MakeInlet(NULL, InitTypeEnd, NULL, NULL) \
225 }
226
230#define MakeOutlet(identifier, view) (Outlet) { (identifier), (View **) (view) }
231
235#define MakeOutlets(...) \
236 { \
237 __VA_ARGS__, \
238 MakeOutlet(NULL, NULL) \
239 }
240
244#define BindInlet(inlet, obj) (inletBindings[(inlet)->type])(inlet, (ident) obj)
245
252OBJECTIVELYMVC_EXPORT _Bool bindInlets(const Inlet *inlets, const Dictionary *dictionary);
ObjectivelyMVC base types.
#define OBJECTIVELYMVC_EXPORT
Definition: Types.h:39
InletType
Inlet type constants.
Definition: View+JSON.h:36
@ InletTypeSubviews
Definition: View+JSON.h:122
@ InletTypeStyle
Definition: View+JSON.h:116
@ InletTypeImage
Definition: View+JSON.h:90
@ InletTypeDouble
Definition: View+JSON.h:67
@ InletTypeEnum
Definition: View+JSON.h:75
@ InletTypePoint
Definition: View+JSON.h:100
@ InletTypeCharacters
Definition: View+JSON.h:52
@ InletTypeBool
Definition: View+JSON.h:46
@ InletTypeClassNames
Definition: View+JSON.h:57
@ InletTypeFont
Definition: View+JSON.h:85
@ InletTypeInteger
Definition: View+JSON.h:95
@ InletTypeApplicationDefined
Definition: View+JSON.h:145
@ InletTypeColor
Definition: View+JSON.h:62
@ InletTypeView
Definition: View+JSON.h:139
@ InletTypeSize
Definition: View+JSON.h:110
@ InletTypeFloat
Definition: View+JSON.h:80
@ InletTypeRectangle
Definition: View+JSON.h:105
@ InitTypeEnd
Definition: View+JSON.h:41
void(* InletBinding)(const Inlet *inlet, ident obj)
A function pointer for Inlet binding.
Definition: View+JSON.h:186
OBJECTIVELYMVC_EXPORT const InletBinding inletBindings[]
The Array of InletBindings, indexed by InletType.
Definition: View+JSON.h:191
OBJECTIVELYMVC_EXPORT _Bool bindInlets(const Inlet *inlets, const Dictionary *dictionary)
Binds each Inlet specified in inlets to the data provided in dictionary.
Definition: View+JSON.c:326
Inlets enable inbound data binding of View attributes through JSON.
Definition: View+JSON.h:155
const char * name
The Inlet name, e.g. "alignment".
Definition: View+JSON.h:160
InletType type
The InletType, e.g. InletTypeEnum.
Definition: View+JSON.h:165
ident data
Type-specific data, e.g. an array of EnumNames.
Definition: View+JSON.h:175
ident dest
The Inlet destination.
Definition: View+JSON.h:170
Outlets enable outbound data binding of Views through JSON.
Definition: View+JSON.h:200
const char * identifier
The View identifier.
Definition: View+JSON.h:205
View ** view
The output storage for the resolved View.
Definition: View+JSON.h:210
Views are the fundamental building blocks of ObjectivelyMVC user interfaces.
Definition: View.h:133