pTitSeb's glshim renamed to gl4es
This commit is contained in:
8
project/jni/gl4es/spec/template/base/base.j2
Executable file
8
project/jni/gl4es/spec/template/base/base.j2
Executable file
@@ -0,0 +1,8 @@
|
||||
{% if ifdef %}#ifdef {{ ifdef }}
|
||||
{% endif %}
|
||||
{% if ifndef %}#ifndef {{ ifndef }}
|
||||
{% endif %}
|
||||
{% block main %}{% endblock %}
|
||||
{% block content %}{% endblock %}
|
||||
{% if ifdef %}#endif{% endif %}
|
||||
{% if ifndef %}#endif{% endif %}
|
||||
5
project/jni/gl4es/spec/template/base/fprint.j2
Normal file
5
project/jni/gl4es/spec/template/base/fprint.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
{% if func.args %}
|
||||
printf("{{ func.name }}({{ func.args|printf }});\n", {{ func.args|args(0) }});
|
||||
{% else %}
|
||||
printf("{{ func.name }}();\n");
|
||||
{% endif %}
|
||||
10
project/jni/gl4es/spec/template/base/header.j2
Normal file
10
project/jni/gl4es/spec/template/base/header.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "base/base.j2" %}
|
||||
{% block main %}
|
||||
{% include "base/headers.j2" %}
|
||||
|
||||
{% set guard = name.upper().replace('.', '_') -%}
|
||||
#ifndef {{ guard }}
|
||||
#define {{ guard }}
|
||||
{% block content %}{% endblock %}
|
||||
#endif
|
||||
{% endblock %}
|
||||
9
project/jni/gl4es/spec/template/base/headers.j2
Executable file
9
project/jni/gl4es/spec/template/base/headers.j2
Executable file
@@ -0,0 +1,9 @@
|
||||
{% block headers %}
|
||||
{% for header in headers %}
|
||||
{% if "<" in header %}
|
||||
#include {{ header }}
|
||||
{% else %}
|
||||
#include "{{ header }}"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
22
project/jni/gl4es/spec/template/base/indexed_call.j2
Normal file
22
project/jni/gl4es/spec/template/base/indexed_call.j2
Normal file
@@ -0,0 +1,22 @@
|
||||
void glIndexedCall(const indexed_call_t *packed, void *ret_v) {
|
||||
switch (packed->func) {
|
||||
{% for f in functions %}
|
||||
#ifndef skip_index_{{ f.name }}
|
||||
case {{ f.name }}_INDEX: {
|
||||
INDEXED_{{ f.types }} *unpacked = (INDEXED_{{ f.types }} *)packed;
|
||||
{% if f.args %}
|
||||
ARGS_{{ f.types }} args = unpacked->args;
|
||||
{% endif %}
|
||||
{% if not f.void %}
|
||||
{{ f.return }} *ret = ({{ f.return }} *)ret_v;
|
||||
*ret =
|
||||
{% endif %}
|
||||
{{ f.name }}({% for arg in f.args -%}
|
||||
args.a{{ loop.index }}{% if not arg.last %}, {% endif %}
|
||||
{% endfor %});
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
{% endfor %}
|
||||
}
|
||||
}
|
||||
16
project/jni/gl4es/spec/template/base/packed_call.j2
Normal file
16
project/jni/gl4es/spec/template/base/packed_call.j2
Normal file
@@ -0,0 +1,16 @@
|
||||
void glPackedCall(const packed_call_t *packed) {
|
||||
switch (packed->format) {
|
||||
{% for f in formats %}
|
||||
case FORMAT_{{ f.types }}: {
|
||||
PACKED_{{ f.types }} *unpacked = (PACKED_{{ f.types }} *)packed;
|
||||
{% if f.args %}
|
||||
ARGS_{{ f.types }} args = unpacked->args;
|
||||
{% endif %}
|
||||
unpacked->func({% for arg in f.args -%}
|
||||
args.a{{ loop.index }}{% if not arg.last %}, {% endif %}
|
||||
{% endfor %});
|
||||
break;
|
||||
}
|
||||
{% endfor %}
|
||||
}
|
||||
}
|
||||
15
project/jni/gl4es/spec/template/base/wrap.c.j2
Executable file
15
project/jni/gl4es/spec/template/base/wrap.c.j2
Executable file
@@ -0,0 +1,15 @@
|
||||
{% extends "base/base.j2" %}
|
||||
{% block main %}
|
||||
{% include "base/headers.j2" %}
|
||||
{% for func in functions %}
|
||||
{% block definition scoped %}
|
||||
{{ func.return }} glshim_{{ func.name }}({{ func.args|args }}) {
|
||||
{% block load scoped %}{% endblock %}
|
||||
{% block call scoped %}
|
||||
{% if not func.void %}return {% endif %}{% block prefix %}wrap{% endblock %}_{{ func.name }}({{ func.args|args(0) }});
|
||||
{%- endblock %}
|
||||
}
|
||||
{{ func.return }} {{ func.name }}({{ func.args|args }}) __attribute__((alias("glshim_{{ func.name }}"))) __attribute__((visibility("default")));
|
||||
{% endblock %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
64
project/jni/gl4es/spec/template/base/wrap.h.j2
Executable file
64
project/jni/gl4es/spec/template/base/wrap.h.j2
Executable file
@@ -0,0 +1,64 @@
|
||||
{% extends "base/header.j2" %}
|
||||
{% block content %}
|
||||
|
||||
typedef struct {
|
||||
int format;
|
||||
void *func;
|
||||
void *args;
|
||||
} packed_call_t;
|
||||
|
||||
typedef struct {
|
||||
int func;
|
||||
void *args;
|
||||
} indexed_call_t;
|
||||
|
||||
enum FORMAT {
|
||||
{% for f in formats %}
|
||||
FORMAT_{{ f.types }},
|
||||
{% endfor %}
|
||||
};
|
||||
|
||||
{% for f in formats %}
|
||||
typedef {{ f.return }} (*FUNC_{{ f.types }})({{ f.args|args }});
|
||||
{% if f.args %}
|
||||
typedef struct {
|
||||
{% for arg in f.args %}
|
||||
{{ arg.type|unconst }} a{{ loop.index }}{% if arg.type == 'GLdouble' %} __attribute__ ((aligned(8))){% endif %};
|
||||
{% endfor %}
|
||||
} ARGS_{{ f.types }};
|
||||
{% endif %}
|
||||
typedef struct {
|
||||
int format;
|
||||
FUNC_{{ f.types }} func;
|
||||
{% if f.args %}
|
||||
ARGS_{{ f.types }} args;
|
||||
{% endif %}
|
||||
} PACKED_{{ f.types }};
|
||||
typedef struct {
|
||||
int func;
|
||||
{% if f.args %}
|
||||
ARGS_{{ f.types }} args;
|
||||
{% endif %}
|
||||
} INDEXED_{{ f.types }};
|
||||
{% endfor %}
|
||||
|
||||
extern void glPushCall(void *data);
|
||||
void glPackedCall(const packed_call_t *packed);
|
||||
void glIndexedCall(const indexed_call_t *packed, void *ret_v);
|
||||
|
||||
{% for func in functions %}
|
||||
#define {{ func.name }}_INDEX {{ loop.index }}
|
||||
#define {{ func.name }}_RETURN {{ func.return }}
|
||||
#define {{ func.name }}_ARG_NAMES {{ func.args|args(0) }}
|
||||
#define {{ func.name }}_ARG_EXPAND {{ func.args|args }}
|
||||
#define {{ func.name }}_PACKED PACKED_{{ func.types }}
|
||||
#define {{ func.name }}_INDEXED INDEXED_{{ func.types }}
|
||||
#define {{ func.name }}_FORMAT FORMAT_{{ func.types }}
|
||||
{% endfor %}
|
||||
|
||||
{% for func in functions %}
|
||||
{{ func.return }} glshim_{{ func.name }}({{ func.name }}_ARG_EXPAND);
|
||||
typedef {{ func.return }} (*{{ func.name }}_PTR)({{ func.name }}_ARG_EXPAND);
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user