Compare commits

..

3 Commits

7 changed files with 9062 additions and 10 deletions

View File

@ -387,7 +387,7 @@ void gds_parse_date(const char *buffer, int length, struct gds_time_field *mod_d
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;
int read; int read;
int i; int i;
int run = 1; int run = 1;
@ -404,6 +404,12 @@ int parse_gds_from_file(const char *filename, GList **library_list)
lib_list = *library_list; lib_list = *library_list;
/* Allocate working buffer */
workbuff = (char *)malloc(sizeof(char)*128*1024);
if(!workbuff)
return -100;
/* open File */ /* open File */
gds_file = fopen(filename, "r"); gds_file = fopen(filename, "r");
if (gds_file == NULL) { if (gds_file == NULL) {
@ -428,8 +434,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
break; break;
} }
rec_data_length = (uint16_t)((((uint16_t)(workbuff[0])) << 8) | rec_data_length = gds_convert_unsigend_int16(workbuff);
(uint16_t)(workbuff[1]));
if (rec_data_length < 4) { if (rec_data_length < 4) {
/* Possible Zero-Padding: */ /* Possible Zero-Padding: */
@ -452,8 +457,7 @@ int parse_gds_from_file(const char *filename, GList **library_list)
GDS_ERROR("Unexpected end of file"); GDS_ERROR("Unexpected end of file");
break; break;
} }
rec_type = (uint16_t)((((uint16_t)(workbuff[0])) << 8) | rec_type = gds_convert_unsigend_int16(workbuff);
(uint16_t)(workbuff[1]));
/* if begin: Allocate structures */ /* if begin: Allocate structures */
switch (rec_type) { switch (rec_type) {
@ -595,7 +599,8 @@ int parse_gds_from_file(const char *filename, GList **library_list)
read = fread(workbuff, sizeof(char), rec_data_length, gds_file); read = fread(workbuff, sizeof(char), rec_data_length, gds_file);
if (read != rec_data_length) { if (read != rec_data_length) {
GDS_ERROR("Could not read enough data"); GDS_ERROR("Could not read enough data: requested: %u, read: %u | Type: %04x\n",
(unsigned int)rec_data_length, (unsigned int)read, (unsigned int)rec_type);
run = -5; run = -5;
break; break;
} }
@ -696,10 +701,15 @@ int parse_gds_from_file(const char *filename, GList **library_list)
fclose(gds_file); fclose(gds_file);
if (!run) {
/* Iterate and find references to cells */ /* Iterate and find references to cells */
g_list_foreach(lib_list, scan_library_references, NULL); g_list_foreach(lib_list, scan_library_references, NULL);
}
*library_list = lib_list; *library_list = lib_list;
free(workbuff);
return run; return run;
} }

View File

@ -164,6 +164,16 @@ void render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_fi
/* 10 kB Line working buffer should be enough */ /* 10 kB Line working buffer should be enough */
working_line = g_string_new_len(NULL, LATEX_LINE_BUFFER_KB*1024); working_line = g_string_new_len(NULL, LATEX_LINE_BUFFER_KB*1024);
/* standalone foo */
g_string_printf(working_line, "\\newif\\iftestmode\n\\testmodefalse %% Change to true for standalone rendering\n");
WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\iftestmode\n");
WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\documentclass[tikz]{standalone}\n\\usepackage{xcolor}\n\\usetikzlibrary{ocgx}\n\\begin{document}\n");
WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\fi\n");
WRITEOUT_BUFFER(working_line);
/* Write layer definitions */ /* Write layer definitions */
write_layer_definitions(tex_file, layer_infos, working_line); write_layer_definitions(tex_file, layer_infos, working_line);
@ -178,6 +188,13 @@ void render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_fi
g_string_printf(working_line, "\\end{tikzpicture}\n"); g_string_printf(working_line, "\\end{tikzpicture}\n");
WRITEOUT_BUFFER(working_line); WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\iftestmode\n");
WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\end{document}\n");
WRITEOUT_BUFFER(working_line);
g_string_printf(working_line, "\\fi\n");
WRITEOUT_BUFFER(working_line);
fflush(tex_file); fflush(tex_file);
g_string_free(working_line, TRUE); g_string_free(working_line, TRUE);
} }

View File

@ -1,2 +1,2 @@
layout.tex *.log
toplevel.pdf *.aux

View File

@ -0,0 +1,2 @@
2,0.203922,0.396078,0.643137,1.000000,1,BOTTOM-Layer
1,0.450980,0.823529,0.086275,1.000000,1,TOP-Layer

BIN
test-data/test.gds Normal file

Binary file not shown.

BIN
test-data/test.pdf Normal file

Binary file not shown.

9023
test-data/test.tex Normal file

File diff suppressed because one or more lines are too long