Skip to content

Instantly share code, notes, and snippets.

@elliottslaughter
Created August 20, 2019 17:51
Show Gist options
  • Save elliottslaughter/cd1340789e399e022010fa08da46bd98 to your computer and use it in GitHub Desktop.
Save elliottslaughter/cd1340789e399e022010fa08da46bd98 to your computer and use it in GitHub Desktop.
import "regent"
local C = regentlib.c
local SCHEMA = terralib.includecstring [[
#ifndef __CONFIG_SCHEMA_H__
#define __CONFIG_SCHEMA_H__
#include <stdbool.h>
#include <stdint.h>
typedef int TempProfile;
#define TempProfile_File 0
typedef int InflowProfile;
#define InflowProfile_File 0
#define InflowProfile_SuctionAndBlowing 1
struct Config {
struct {
struct {
int32_t type;
union {
struct {
int8_t FileDir[256];
} File;
} u;
} xBCLeftHeat;
struct {
int32_t type;
union {
struct {
double addedVelocity;
int8_t FileDir[256];
} File;
struct {
double sigma;
struct {
uint32_t length;
double values[10];
} beta;
double Zw;
struct {
uint32_t length;
double values[10];
} A;
struct {
uint32_t length;
double values[10];
} omega;
} SuctionAndBlowing;
} u;
} yBCLeftInflowProfile;
struct {
int32_t type;
union {
struct {
double addedVelocity;
int8_t FileDir[256];
} File;
struct {
double sigma;
struct {
uint32_t length;
double values[10];
} beta;
double Zw;
struct {
uint32_t length;
double values[10];
} A;
struct {
uint32_t length;
double values[10];
} omega;
} SuctionAndBlowing;
} u;
} xBCLeftInflowProfile;
} BC;
};
#endif // __CONFIG_SCHEMA_H__
]]
local Config = SCHEMA.Config
task out(config : Config)
C.printf("\nInside the task:\n")
C.printf("%s\n", config.BC.xBCLeftInflowProfile.u.File.FileDir)
C.printf("%s\n", config.BC.xBCLeftHeat.u.File.FileDir)
C.printf("\n")
end
task main()
var config : Config
C.snprintf(&(config.BC.xBCLeftInflowProfile.u.File.FileDir[0]), 256, "%s", "String1111111111111111111111111111111111111111")
C.snprintf(&(config.BC.xBCLeftHeat.u.File.FileDir[0]), 256, "%s", "String2222222222222222222222222222222222222222")
C.printf("Expect this ouput:\n")
C.printf("%s\n", config.BC.xBCLeftInflowProfile.u.File.FileDir)
C.printf("%s\n", config.BC.xBCLeftHeat.u.File.FileDir)
C.printf("\n")
out(config)
end
regentlib.start(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment