[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libredwg] Reply to review about proposal
From: |
gagan |
Subject: |
Re: [libredwg] Reply to review about proposal |
Date: |
Fri, 24 May 2013 21:24:07 +0530 |
On 5/24/13, Rodrigo Rodrigues da Silva <address@hidden> wrote:
<snip>
> As for low-level/high-level examples:
>
>
> Dwg_Object * should_be_layer = obj->tio.entity->layer->obj;
> Dwg_Object_LAYER * layer;
> unsigned int _type = should_be_layer->type;
> //dwg_print_object(should_be_layer);
> printf("type = %u ", _type);
> if (_type == 51)
> {
> layer = obj->tio.entity->layer->obj->tio.object->tio.LAYER; //low
> level struct access
>
> in a higher level c-ish way:
>
> Dwg_Object_LAYER * layer;
>
> int error = dwg_get_obj_layer(obj, &layer); //higher level c api
<snip>
> another example (I've implemented it already, I guess)
>
> int layer_count = dwg_get_layer_count(&dwg_data);
Reading these, I have created 2 examples, Please have a look at them
and tell me if we can consider them developed in high level C ?
My API code :-
Dwg_Object_LAYER ** extract_layers(Dwg_Data *dwg)
{
int i, a=0;
Dwg_Object_LAYER **layer = (Dwg_Object_LAYER **)malloc(
dwg_get_layer_count(dwg) * (sizeof (Dwg_Object_LAYER*) + 10));
for (i = 0; i < dwg->num_objects; i++)
{
if(DWG_TYPE_LAYER==dwg->object[i].type)
{
layer[a] = dwg->object[i].tio.object->tio.LAYER;
a++;
}
}
return layer;
}
Application code :-
extract_layers(&dwg);
My API code :-
unsigned char *
get_layer_name(Dwg_Object_Entity *entity, Dwg_Object_LAYER *layer)
{
layer = entity->layer->obj->tio.object->tio.LAYER;
return layer->entry_name;
}
Application code :-
Dwg_Object_LAYER *layer;
get_layer_name(entity, layer); //here entity can be any, user should
know how to get entity here.
--
Thanks
Gaganjyot