Changeset 2089

Show
Ignore:
Timestamp:
06/03/09 16:45:17 (15 months ago)
Author:
drobilla
Message:

Kludge around broken raptor_sequence_set_at.

Location:
trunk/slv2
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/slv2/src/plugin.c

    r2087 r2089  
    4949        plugin->storage = NULL; 
    5050        plugin->rdf = NULL; 
     51        plugin->num_ports = 0; 
    5152 
    5253        return plugin; 
     
    6768        p->binary_uri = NULL; 
    6869 
    69         if (p->ports) 
    70                 raptor_free_sequence(p->ports); 
    71         p->ports = NULL; 
     70        if (p->ports) { 
     71                for (uint32_t i = 0; i < p->num_ports; ++i) 
     72                        slv2_port_free(p->ports[i]); 
     73                free(p->ports); 
     74                p->ports = NULL; 
     75        } 
    7276 
    7377        if (p->rdf) { 
     
    123127 
    124128        if (!p->ports) { 
    125                 p->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free, NULL); 
     129                p->ports = malloc(sizeof(SLV2Port*)); 
     130                p->ports[0] = NULL; 
    126131 
    127132                const unsigned char* query = (const unsigned char*) 
     
    144149                        librdf_node* index_node = librdf_query_results_get_binding_value(results, 2); 
    145150 
    146                         if (librdf_node_is_literal(symbol_node) &&librdf_node_is_literal(index_node)) { 
     151                        if (librdf_node_is_literal(symbol_node) && librdf_node_is_literal(index_node)) { 
    147152                                const char* symbol = (const char*)librdf_node_get_literal_value(symbol_node); 
    148153                                const char* index = (const char*)librdf_node_get_literal_value(index_node); 
    149154 
    150155                                const int this_index = atoi(index); 
    151                                 SLV2Port  this_port  = raptor_sequence_get_at(p->ports, this_index); 
    152  
    153                                 // Havn't seen this port yet, add it to sequence 
     156                                SLV2Port  this_port  = NULL; 
     157 
     158                                assert(this_index >= 0); 
     159 
     160                                if (p->num_ports > (unsigned)this_index) { 
     161                                        this_port = p->ports[this_index]; 
     162                                } else { 
     163                                        p->ports = realloc(p->ports, (this_index + 1) * sizeof(SLV2Port*)); 
     164                                        memset(p->ports + p->num_ports, '\0', 
     165                                                        (this_index - p->num_ports) * sizeof(SLV2Port)); 
     166                                        p->num_ports = this_index + 1; 
     167                                } 
     168 
     169                                // Havn't seen this port yet, add it to array 
    154170                                if (!this_port) { 
    155171                                        this_port = slv2_port_new(p->world, this_index, symbol); 
    156                                         raptor_sequence_set_at(p->ports, this_index, this_port); 
     172                                        p->ports[this_index] = this_port; 
    157173                                } 
    158174 
     
    498514{ 
    499515        slv2_plugin_load_ports_if_necessary(p); 
    500         return raptor_sequence_size(p->ports); 
     516        return p->num_ports; 
    501517} 
    502518 
     
    509525        slv2_plugin_load_ports_if_necessary(p); 
    510526 
    511         for (int i = 0; i < raptor_sequence_size(p->ports); ++i) 
     527        for (uint32_t i = 0; i < p->num_ports; ++i) 
    512528                values[i] = NAN; 
    513529 
     
    571587        va_list  args; 
    572588 
    573         for (unsigned i=0; i < slv2_plugin_get_num_ports(p); ++i) { 
    574                 SLV2Port port = raptor_sequence_get_at(p->ports, i); 
     589        for (unsigned i=0; i < p->num_ports; ++i) { 
     590                SLV2Port port = p->ports[i]; 
    575591                if (!slv2_port_is_a(p, port, class_1)) 
    576592                        continue; 
     
    692708{ 
    693709        slv2_plugin_load_ports_if_necessary(p); 
    694         return raptor_sequence_get_at(p->ports, (int)index); 
     710        if (index < p->num_ports) 
     711                return p->ports[index]; 
     712        else 
     713                return NULL; 
    695714} 
    696715 
     
    701720{ 
    702721        slv2_plugin_load_ports_if_necessary(p); 
    703         for (int i=0; i < raptor_sequence_size(p->ports); ++i) { 
    704                 SLV2Port port = raptor_sequence_get_at(p->ports, i); 
     722        for (uint32_t i=0; i < p->num_ports; ++i) { 
     723                SLV2Port port = p->ports[i]; 
    705724                if (slv2_value_equals(port->symbol, symbol)) 
    706725                        return port; 
  • trunk/slv2/src/port.c

    r2007 r2089  
    3939        port->symbol = slv2_value_new(world, SLV2_VALUE_STRING, symbol); 
    4040        port->classes = slv2_values_new(); 
    41         //port->node_id = strdup(node_id); 
    4241        return port; 
    4342} 
  • trunk/slv2/src/slv2_internal.h

    r2086 r2089  
    6262        SLV2PluginClass      plugin_class; 
    6363        raptor_sequence*     data_uris;  ///< rdfs::seeAlso 
    64         raptor_sequence*     ports; 
     64        SLV2Port*            ports; 
    6565        librdf_storage*      storage; 
    6666        librdf_model*        rdf; 
     67        uint32_t             num_ports; 
    6768}; 
    6869 
  • trunk/slv2/test/slv2_test.c

    r2000 r2089  
    555555                        PLUGIN_NAME("Test plugin") " ; " 
    556556                        LICENSE_GPL " ; " 
    557                 "lv2:optionalFeature lv2:hardRtCapable ; " 
     557                        "lv2:optionalFeature lv2:hardRtCapable ; " 
    558558                    "lv2:requiredFeature <http://lv2plug.in/ns/ext/event> ; " 
    559559                        ":foo 1.6180 ; "