[Freeciv-Dev] [bug #13868] [patch 02/07] use an union in the struct setting

2009-09-26 Thread pepeto

Follow-up Comment #2, bug #13868 (project freeciv):

'const' flags could be added to the values, like 'bool *const pbval' to be
sure that pointer won't be modified.

I'm not totally conviced by the names.  If you do a struct boolean, you don't
need to have 'b' in every other variables.

You can also using a anonymous union to use directly what is inside.

I would suggest:
union {
  /*** bool part ***/
  struct {
bool *const pvalue;
const bool default;
const bool_validate_func_t validate;
  } boolean;
  /*** int part ***/
struct {
int *const pvalue;
const int default;
const int min;
const int max;
const int_validate_func_t validate;
  } integer;
  /*** string part ***/
  struct {
char *const value;
const char *const default;
const size_t size;
const string_validate_func_t validate;
  } string;
};

So the bool value would be '*pset-boolean.pvalue' which looks enough clear
for me.


___

Reply to this item at:

  http://gna.org/bugs/?13868

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #13868] [patch 02/07] use an union in the struct setting

2009-09-13 Thread Matthias Pfafferodt

Follow-up Comment #1, bug #13868 (project freeciv):

rebased version of the patch:

use an union in the struct setting

* change the wrapper functions
* protect the union by asserts

(file #6682)
___

Additional Item Attachment:

File name: 0002-use-an-union-in-the-struct-setting.diff Size:12 KB


___

Reply to this item at:

  http://gna.org/bugs/?13868

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #13868] [patch 02/07] use an union in the struct setting

2009-07-05 Thread Matthias Pfafferodt

URL:
  http://gna.org/bugs/?13868

 Summary: [patch 02/07] use an union in the struct setting
 Project: Freeciv
Submitted by: syntron
Submitted on: Sonntag 05.07.2009 um 22:15
Category: general
Severity: 2 - Minor
Priority: 5 - Normal
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any
 Release: 
Operating System: None

___

Details:

use an union in the struct setting

* change the wrapper functions
* protect the union by asserts

Are the asserts needed or can we trust all callers?




___

File Attachments:


---
Date: Sonntag 05.07.2009 um 22:15  Name:
02-use-an-union-in-the-struct-setting.patch  Size: 11kB   By: syntron

http://gna.org/bugs/download.php?file_id=6136

___

Reply to this item at:

  http://gna.org/bugs/?13868

___
  Nachricht geschickt von/durch Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev