style fixes
This commit is contained in:
parent
e8adee3197
commit
e469e614ab
79
gdsparse.c
79
gdsparse.c
@ -34,8 +34,8 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define GDS_ERROR(fmt, ...) printf("[PARSE_ERROR] " fmt "\n",## __VA_ARGS__)
|
#define GDS_ERROR(fmt, ...) printf("[PARSE_ERROR] " fmt "\n", ##__VA_ARGS__)
|
||||||
#define GDS_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n",## __VA_ARGS__)
|
#define GDS_WARN(fmt, ...) printf("[PARSE_WARNING] " fmt "\n", ##__VA_ARGS__)
|
||||||
|
|
||||||
enum record {
|
enum record {
|
||||||
INVALID = 0x0000,
|
INVALID = 0x0000,
|
||||||
@ -60,12 +60,12 @@ enum record {
|
|||||||
LAYER = 0x0D02,
|
LAYER = 0x0D02,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int name_cell_ref(struct gds_cell_instance *cell_inst, unsigned int bytes, char* data)
|
static int name_cell_ref(struct gds_cell_instance *cell_inst,
|
||||||
|
unsigned int bytes, char *data)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (cell_inst == NULL)
|
if (cell_inst == NULL) {
|
||||||
{
|
|
||||||
GDS_ERROR("Naming cell ref with no opened cell ref");
|
GDS_ERROR("Naming cell ref with no opened cell ref");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -74,12 +74,13 @@ static int name_cell_ref(struct gds_cell_instance *cell_inst, unsigned int bytes
|
|||||||
if (len > CELL_NAME_MAX-1) {
|
if (len > CELL_NAME_MAX-1) {
|
||||||
GDS_ERROR("Cell name '%s' too long: %d\n", data, len);
|
GDS_ERROR("Cell name '%s' too long: %d\n", data, len);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
/* else: */
|
||||||
strcpy(cell_inst->ref_name, data);
|
strcpy(cell_inst->ref_name, data);
|
||||||
printf("\tCell referenced: %s\n", cell_inst->ref_name);
|
printf("\tCell referenced: %s\n", cell_inst->ref_name);
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double gds_convert_double(char *data)
|
static double gds_convert_double(char *data)
|
||||||
@ -125,6 +126,7 @@ static double gds_convert_double(char *data)
|
|||||||
static signed int gds_convert_signed_int(char *data)
|
static signed int gds_convert_signed_int(char *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
GDS_ERROR("This should not happen");
|
GDS_ERROR("This should not happen");
|
||||||
return 0;
|
return 0;
|
||||||
@ -148,12 +150,12 @@ static int16_t gds_convert_signed_int16(char *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GList * append_library(GList *curr_list)
|
static GList *append_library(GList *curr_list)
|
||||||
{
|
{
|
||||||
struct gds_library *lib;
|
struct gds_library *lib;
|
||||||
|
|
||||||
lib = (struct gds_library *)malloc(sizeof(struct gds_library));
|
lib = (struct gds_library *)malloc(sizeof(struct gds_library));
|
||||||
if(lib) {
|
if (lib) {
|
||||||
lib->cells = NULL;
|
lib->cells = NULL;
|
||||||
lib->name[0] = 0;
|
lib->name[0] = 0;
|
||||||
lib->unit_to_meters = 1; // Default. Will be overwritten
|
lib->unit_to_meters = 1; // Default. Will be overwritten
|
||||||
@ -163,7 +165,7 @@ static GList * append_library(GList *curr_list)
|
|||||||
return g_list_append(curr_list, lib);
|
return g_list_append(curr_list, lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList * append_graphics(GList *curr_list, enum graphics_type type)
|
static GList *append_graphics(GList *curr_list, enum graphics_type type)
|
||||||
{
|
{
|
||||||
struct gds_graphics *gfx;
|
struct gds_graphics *gfx;
|
||||||
|
|
||||||
@ -177,12 +179,12 @@ static GList * append_graphics(GList *curr_list, enum graphics_type type)
|
|||||||
} else
|
} else
|
||||||
return NULL;
|
return NULL;
|
||||||
return g_list_append(curr_list, gfx);
|
return g_list_append(curr_list, gfx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList * append_vertex(GList *curr_list, int x, int y)
|
static GList *append_vertex(GList *curr_list, int x, int y)
|
||||||
{
|
{
|
||||||
struct gds_point *vertex;
|
struct gds_point *vertex;
|
||||||
|
|
||||||
vertex = (struct gds_point *)malloc(sizeof(struct gds_point));
|
vertex = (struct gds_point *)malloc(sizeof(struct gds_point));
|
||||||
if (vertex) {
|
if (vertex) {
|
||||||
vertex->x = x;
|
vertex->x = x;
|
||||||
@ -192,7 +194,7 @@ static GList * append_vertex(GList *curr_list, int x, int y)
|
|||||||
return g_list_append(curr_list, vertex);
|
return g_list_append(curr_list, vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList * append_cell(GList *curr_list)
|
static GList *append_cell(GList *curr_list)
|
||||||
{
|
{
|
||||||
struct gds_cell *cell;
|
struct gds_cell *cell;
|
||||||
|
|
||||||
@ -207,11 +209,12 @@ static GList * append_cell(GList *curr_list)
|
|||||||
return g_list_append(curr_list, cell);
|
return g_list_append(curr_list, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList * append_cell_ref(GList *curr_list)
|
static GList *append_cell_ref(GList *curr_list)
|
||||||
{
|
{
|
||||||
struct gds_cell_instance *inst;
|
struct gds_cell_instance *inst;
|
||||||
|
|
||||||
inst = (struct gds_cell_instance *)malloc(sizeof(struct gds_cell_instance));
|
inst = (struct gds_cell_instance *)
|
||||||
|
malloc(sizeof(struct gds_cell_instance));
|
||||||
if (inst) {
|
if (inst) {
|
||||||
inst->cell_ref = NULL;
|
inst->cell_ref = NULL;
|
||||||
inst->ref_name[0] = 0;
|
inst->ref_name[0] = 0;
|
||||||
@ -224,11 +227,12 @@ static GList * append_cell_ref(GList *curr_list)
|
|||||||
return g_list_append(curr_list, inst);
|
return g_list_append(curr_list, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int name_library(struct gds_library *current_library, unsigned int bytes, char* data) {
|
static int name_library(struct gds_library *current_library,
|
||||||
|
unsigned int bytes, char *data)
|
||||||
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (current_library == NULL)
|
if (current_library == NULL) {
|
||||||
{
|
|
||||||
GDS_ERROR("Naming cell with no opened library");
|
GDS_ERROR("Naming cell with no opened library");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -238,19 +242,20 @@ static int name_library(struct gds_library *current_library, unsigned int bytes,
|
|||||||
if (len > CELL_NAME_MAX-1) {
|
if (len > CELL_NAME_MAX-1) {
|
||||||
GDS_ERROR("Library name '%s' too long: %d\n", data, len);
|
GDS_ERROR("Library name '%s' too long: %d\n", data, len);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
strcpy(current_library->name, data);
|
strcpy(current_library->name, data);
|
||||||
printf("Named library: %s\n", current_library->name);
|
printf("Named library: %s\n", current_library->name);
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int name_cell(struct gds_cell *cell, unsigned int bytes, char* data, struct gds_library* lib) {
|
static int name_cell(struct gds_cell *cell, unsigned int bytes,
|
||||||
|
char *data, struct gds_library *lib)
|
||||||
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (cell == NULL)
|
if (cell == NULL) {
|
||||||
{
|
|
||||||
GDS_ERROR("Naming library with no opened library");
|
GDS_ERROR("Naming library with no opened library");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -259,18 +264,15 @@ static int name_cell(struct gds_cell *cell, unsigned int bytes, char* data, stru
|
|||||||
if (len > CELL_NAME_MAX-1) {
|
if (len > CELL_NAME_MAX-1) {
|
||||||
GDS_ERROR("Cell name '%s' too long: %d\n", data, len);
|
GDS_ERROR("Cell name '%s' too long: %d\n", data, len);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
strcpy(cell->name, data);
|
strcpy(cell->name, data);
|
||||||
printf("Named cell: %s\n", cell->name);
|
printf("Named cell: %s\n", cell->name);
|
||||||
|
|
||||||
/* Append cell name to lib's list of names */
|
/* Append cell name to lib's list of names */
|
||||||
lib->cell_names = g_list_append(lib->cell_names, cell->name);
|
lib->cell_names = g_list_append(lib->cell_names, cell->name);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -283,7 +285,9 @@ void parse_reference_list(gpointer gcell_ref, gpointer glibrary)
|
|||||||
|
|
||||||
printf("\t\t\tReference: %s: ", inst->ref_name);
|
printf("\t\t\tReference: %s: ", inst->ref_name);
|
||||||
/* Find cell */
|
/* Find cell */
|
||||||
for (cell_item = lib->cells; cell_item != NULL; cell_item = cell_item->next) {
|
for (cell_item = lib->cells; cell_item != NULL;
|
||||||
|
cell_item = cell_item->next) {
|
||||||
|
|
||||||
cell = (struct gds_cell *)cell_item->data;
|
cell = (struct gds_cell *)cell_item->data;
|
||||||
/* Check if cell is found */
|
/* Check if cell is found */
|
||||||
if (!strcmp(cell->name, inst->ref_name)) {
|
if (!strcmp(cell->name, inst->ref_name)) {
|
||||||
@ -296,13 +300,12 @@ void parse_reference_list(gpointer gcell_ref, gpointer glibrary)
|
|||||||
|
|
||||||
printf("MISSING!\n");
|
printf("MISSING!\n");
|
||||||
GDS_WARN("referenced cell could not be found in library");
|
GDS_WARN("referenced cell could not be found in library");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void scan_cell_reference_dependencies(gpointer gcell, gpointer library)
|
void scan_cell_reference_dependencies(gpointer gcell, gpointer library)
|
||||||
{
|
{
|
||||||
struct gds_cell *cell = (struct gds_cell *)gcell;
|
struct gds_cell *cell = (struct gds_cell *)gcell;
|
||||||
|
|
||||||
printf("\tScanning cell: %s\n", cell->name);
|
printf("\tScanning cell: %s\n", cell->name);
|
||||||
|
|
||||||
/* Scan all library references */
|
/* Scan all library references */
|
||||||
@ -310,7 +313,6 @@ void scan_cell_reference_dependencies(gpointer gcell, gpointer library)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void scan_library_references(gpointer library_list_item, gpointer user)
|
void scan_library_references(gpointer library_list_item, gpointer user)
|
||||||
{
|
{
|
||||||
struct gds_library *lib = (struct gds_library *)library_list_item;
|
struct gds_library *lib = (struct gds_library *)library_list_item;
|
||||||
@ -319,7 +321,6 @@ void scan_library_references(gpointer library_list_item, gpointer user)
|
|||||||
g_list_foreach(lib->cells, scan_cell_reference_dependencies, lib);
|
g_list_foreach(lib->cells, scan_cell_reference_dependencies, lib);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int parse_gds_from_file(const char *filename, GList **library_list)
|
int parse_gds_from_file(const char *filename, GList **library_list)
|
||||||
{
|
{
|
||||||
char workbuff[1024];
|
char workbuff[1024];
|
||||||
@ -401,7 +402,8 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
|||||||
|
|
||||||
}
|
}
|
||||||
printf("Entering Lib\n");
|
printf("Entering Lib\n");
|
||||||
current_lib = (struct gds_library *)g_list_last(lib_list)->data;
|
current_lib = (struct gds_library *)
|
||||||
|
g_list_last(lib_list)->data;
|
||||||
break;
|
break;
|
||||||
case ENDLIB:
|
case ENDLIB:
|
||||||
if (current_lib == NULL) {
|
if (current_lib == NULL) {
|
||||||
@ -427,7 +429,8 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("Entering Cell\n");
|
printf("Entering Cell\n");
|
||||||
current_cell = (struct gds_cell *)g_list_last(current_lib->cells)->data;
|
current_cell = (struct gds_cell *)
|
||||||
|
g_list_last(current_lib->cells)->data;
|
||||||
break;
|
break;
|
||||||
case ENDSTR:
|
case ENDSTR:
|
||||||
if (current_cell == NULL) {
|
if (current_cell == NULL) {
|
||||||
@ -623,8 +626,6 @@ int parse_gds_from_file(const char *filename, GList **library_list)
|
|||||||
|
|
||||||
*library_list = lib_list;
|
*library_list = lib_list;
|
||||||
return run;
|
return run;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delete_cell_inst_element(struct gds_cell_instance *cell_inst)
|
static void delete_cell_inst_element(struct gds_cell_instance *cell_inst)
|
||||||
|
Loading…
Reference in New Issue
Block a user