|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
Перевод h в pas файл
Добрый день!
Перевожу заголовочный файл и сталкнулся с проблемой, что разные типы данных имеют ссылку друг на друга pcg_field_desc имеет ссылку на pcg_message_desc и наоборот С++ Код:
struct cg_message_desc_t; /// Message field description struct cg_field_desc_t { /// pointer to the next value struct cg_field_desc_t* next; /// Field ID. May be 0 if not defined uint32_t id; /// Field name char* name; /// Field description /// May be NULL if not defined char* desc; /// field type char* type; /// size in bytes size_t size; /// offset from buffer beginning size_t offset; /// Pointer to default value of the field /// Points to the buffer of size "size" /// May be NULL if no default value is defined void* def_value; /// Number of values for the field values size_t num_values; /// Pointer to the list of values /// which can be taken by the field struct cg_field_value_desc_t* values; /// Field options struct cg_value_pair_t* hints; /// Maximum number of fields, 1 by default size_t max_count; /// Link to description of count field struct cg_field_desc_t * count_field; /// Pointer to message description for type = 'm' fields struct cg_message_desc_t * type_msg; }; // Index component description struct cg_indexfield_desc_t { // Pointer to the next value struct cg_indexfield_desc_t* next; // points to field of index struct cg_field_desc_t* field; // sort order (0 for asc, 1 for desc) uint32_t sort_order; }; // Index description struct cg_index_desc_t { // Pointer to the next index struct cg_index_desc_t * next; // Number of fields in the index size_t num_fields; // Pointer to the first index component struct cg_indexfield_desc_t* fields; // name char* name; // desc // may be NULL if not defined char* desc; // index hints struct cg_value_pair_t* hints; }; // Message description struct cg_message_desc_t { // Pointer to the next message struct cg_message_desc_t* next; // Message data block size size_t size; // Number of fields in the message size_t num_fields; // Pointer to the first message description struct cg_field_desc_t* fields; // Message unique ID // May be 0 if not defined uint32_t id; // Message name // May be NULL if not defined char *name; // Description // May be NULL if not defined char *desc; // Message hints // May be NULL if not defined struct cg_value_pair_t* hints; // Number of indices for the message size_t num_indices; // Pointer to the first index description struct cg_index_desc_t* indices; // Size of alignment size_t align; }; pascal Код:
// Message field description type pcg_field_desc = ^tcg_field_desc; tcg_field_desc = record next: pcg_field_desc; // Pointer to the next value id: uint32_t; // Field ID. May be 0 if not defined // May be NULL if not defined name: pAnsiChar; // Field name May be NULL if not defined desc: pAnsiChar; // Description May be NULL if not defined field_type: pAnsiChar; // Field type size: size_t; // Size in bytes offset: size_t; // Offset from beginning of data in bytes def_value: Pointer; // Pointer to default value of the field Points to the buffer of size "size" May be NULL if not defined num_values: size_t; // Number of values for the field values values: pcg_field_value_desc;// Pointer to the list of values which can be taken by the field hints: pcg_value_pair; // Field options max_count: size_t; // Maximum number of fields, 1 by default count_field: pcg_field_desc; // Link to description of count field type_msg: pcg_message_desc; // Pointer to message description for type = 'm' fields end; // Index component description type pcg_indexfield_desc = ^tcg_indexfield_desc; tcg_indexfield_desc = record next: pcg_indexfield_desc; // Pointer to the next value field: pcg_field_desc; // Points to field of index sort_order: uint32_t; // Sort order (0 for asc, 1 for desc) end; // Index description type pcg_index_desc = ^tcg_index_desc; tcg_index_desc = record next: pcg_index_desc; // Pointer to the next index num_fields: size_t; // Number of fields in the index fields: pcg_indexfield_desc; // Pointer to the first index component name: pAnsiChar; // Name desc: pAnsiChar; // Desc hints: pcg_value_pair; // index hints end; // Message description type pcg_message_desc = ^tcg_message_desc; tcg_message_desc = record next: pcg_message_desc; // Pointer to the next message size: size_t; // Message data block size num_fields: size_t; // Number of fields in the message fields: pcg_field_desc; // Pointer to the first message description id: uint32_t; // Message unique ID May be 0 if not defined name: pAnsiChar; // Message name May be NULL if not defined desc: pAnsiChar; // Description May be NULL if not defined hints: pcg_value_pair; // message hints (in string format) May be NULL if not defined num_indices: size_t; // Number of indices for the message indices: pcg_index_desc; // Pointer to the first index description align: size_t; // Size of alignment end; Помогите решить проблему Последний раз редактировалось Mikalas, 20.09.2016 в 04:06. |
#2
|
|||
|
|||
что мешает разнести декларацию указателей и самих записей?
Код:
type pcg_field_desc = ^tcg_field_desc; pcg_message_desc = ^tcg_message_desc; type tcg_field_desc = record ... type_msg: pcg_message_desc; end; tcg_message_desc = record ... fields: pcg_field_desc; ... end; |
#3
|
|||
|
|||
Надо их описывать в одном блоке type, вот так
Код:
type pcg_field_desc = ^tcg_field_desc; pcg_message_desc = ^tcg_message_desc; //type<- это убрать tcg_field_desc = record ... type_msg: pcg_message_desc; end; tcg_message_desc = record ... fields: pcg_field_desc; ... end; |
#4
|
|||
|
|||
Спасибо, получилось
|