10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-11-19 04:22:25 +01:00

C support

This commit is contained in:
Anthony Scemama 2016-01-05 11:38:30 +01:00
parent 491c43afcc
commit 073767edcc
3 changed files with 40 additions and 1 deletions

0
C/.empty Normal file
View File

View File

@ -40,6 +40,9 @@ print >>file_py, """
version = property(fset=None,fget=get_version) version = property(fset=None,fget=get_version)
"""%(v) """%(v)
file_c = open("../C/ezfio.h","w")
print >>file_c, c_header
import sys import sys
for group in groups.keys(): for group in groups.keys():
@ -77,6 +80,7 @@ for group in groups.keys():
'group': group, 'group': group,
'dims': strdims} 'dims': strdims}
print attributes%d print attributes%d
print >>file_c, attributes_c%d
print >>file_py, attributes_py%d print >>file_py, attributes_py%d
else: else:
d = { 'type': type, d = { 'type': type,
@ -90,12 +94,14 @@ for group in groups.keys():
buffer = re.sub(r"at\((.*),(.*)\)",r'\1(\2)',buffer) buffer = re.sub(r"at\((.*),(.*)\)",r'\1(\2)',buffer)
print buffer print buffer
print >>file_py, calculated_py%d print >>file_py, calculated_py%d
print >>file_c, calculated_c%d
elif type == "buffered": elif type == "buffered":
d = { 'group': group, d = { 'group': group,
'var': var, 'var': var,
'dims_py': dims_py, 'dims_py': dims_py,
'dims': dims } 'dims': dims }
print buffered%d print buffered%d
print >>file_c, buffered_c%d
print >>file_py, buffered_py%d print >>file_py, buffered_py%d
else: else:
dims_loop = '' dims_loop = ''
@ -142,5 +148,9 @@ for group in groups.keys():
'declar_loop' : declar_loop} 'declar_loop' : declar_loop}
print attributes_arr%d print attributes_arr%d
print >>file_py, attributes_arr_py%d print >>file_py, attributes_arr_py%d
print >>file_c, attributes_arr_c%d
print >>file_c, c_footer
file_py.close() file_py.close()
file_c.close()

View File

@ -239,12 +239,41 @@ end
#--------- #---------
attributes_c = """ attributes_c = """
void ezfio_set_%(group)s_%(var)s(%(type)s %(var)s) void ezfio_set_%(group)s_%(var)s(%(ctype)s %(var)s)
{ {
ezfio_set_%(group)s_%(var)s_(&%(var)s); ezfio_set_%(group)s_%(var)s_(&%(var)s);
} }
void ezfio_get_%(group)s_%(var)s(%(ctype)s *%(var)s)
{
ezfio_get_%(group)s_%(var)s_(%(var)s);
}
bool ezfio_has_%(group)s_%(var)s()
{
ezfio_has_%(group)s_%(var)s_();
}
""" """
attributes_arr_c = """
void ezfio_set_%(group)s_%(var)s(%(ctype)s %(var)s)
{
ezfio_set_%(group)s_%(var)s_(&%(var)s, 1);
}
void ezfio_get_%(group)s_%(var)s(%(ctype)s *%(var)s)
{
ezfio_get_%(group)s_%(var)s_(%(var)s, 1);
}
bool ezfio_has_%(group)s_%(var)s()
{
ezfio_has_%(group)s_%(var)s_();
}
"""
calculated_c = attributes_c
c_header = """ c_header = """
#ifndef EZFIO_H #ifndef EZFIO_H
#define EZFIO_H #define EZFIO_H