[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libredwg] Refactoring R2000

From: Avneet Kaur
Subject: [libredwg] Refactoring R2000
Date: Mon, 8 Jul 2013 11:38:07 +0530

Hello !

Implementation of R2000 version is complete. So I think I should start
refactoring of decode.c file for R2000 version.
The main function "dwg_decode_data ()" which decodes the DWG file
depending upon it's version, call other functions like
for R2000, call "decode_R13_R15 ()",
for R2004, call "decode_R2004 ()",
for R2007, call "decode_R2007 ()"

In main function definition, a little bit refactoring is also required.
To compare the DWG version, each and every time if statements are run
to get the single result.
So it's better to use if-else like


dwg->header.version = 0;
  if (!strcmp (version, version_codes[R_13]))
    dwg->header.version = R_13;
 else if (!strcmp (version, version_codes[R_14]))
    dwg->header.version = R_14;
  else if (!strcmp (version, version_codes[R_2000]))
    dwg->header.version = R_2000;
  else if (!strcmp (version, version_codes[R_2004]))
    dwg->header.version = R_2004;
  else if (!strcmp (version, version_codes[R_2007]))
    dwg->header.version = R_2007;
    printf (" Invalid or unimplemented version ");


Now Introducing a new thing, for every decoding version, there will a
separate decoding file.
We must define "decode_R13_R15 ()" in decode_r2000.c file.

To decode a R2000 version, there is a single function "decode_R13_R15
()" that is doing every thing consisting of 491 lines.
Hence, we should break this function into sub-smaller functions based
on sections like for
1. Unknown section 1
2. Picture (Pre-R13C3)
3. Header variables
4. Classes
5. Object map
6. Second header
7. Section measurement

Please give your views, suggestions on this and correct me where I am wrong.

Er. Avneet Kaur

"Coming together is a beginning; keeping together is progress; working
together is success."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]