Skip to content

Commit

Permalink
Rename the type for HeaderComments
Browse files Browse the repository at this point in the history
  • Loading branch information
furuame committed Aug 5, 2024
1 parent 2d4634e commit a4a0c8f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions stfpy/stfpy/stf_inst_reader.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

from cython.operator cimport dereference
from stfpy.stf_lib.stf_inst_reader cimport STFInstReader as _STFInstReader
from stfpy.stf_lib.stf_inst_reader cimport StringVector as _StringVector, StringVectorIterator as _StringVectorIterator
from stfpy.stf_lib.stf_inst_reader cimport HeaderCommentsType as _HeaderCommentsType, HeaderCommentsTypeIterator as _HeaderCommentsTypeIterator

ctypedef _STFInstReader.iterator _STFInstReaderIterator

cdef class StringVectorIterator:
cdef _StringVectorIterator c_it
cdef _StringVectorIterator c_end_it
cdef class HeaderCommentsTypeIterator:
cdef _HeaderCommentsTypeIterator c_it
cdef _HeaderCommentsTypeIterator c_end_it

@staticmethod
cdef inline StringVectorIterator _construct(const _StringVector* vec):
it = StringVectorIterator()
cdef inline HeaderCommentsTypeIterator _construct(const _HeaderCommentsType* vec):
it = HeaderCommentsTypeIterator()
it.c_it = dereference(vec).begin()
it.c_end_it = dereference(vec).end()
return it

cdef class StringVector:
cdef const _StringVector* c_vec
cdef class HeaderCommentsType:
cdef const _HeaderCommentsType* c_vec

@staticmethod
cdef inline StringVector _construct(const _StringVector& vec):
new_vec = StringVector()
cdef inline HeaderCommentsType _construct(const _HeaderCommentsType& vec):
new_vec = HeaderCommentsType()
new_vec.c_vec = &vec
return new_vec

Expand Down
8 changes: 4 additions & 4 deletions stfpy/stfpy/stf_inst_reader.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ from stfpy.stf_inst import STFInst
from cython.operator cimport dereference, preincrement
include "stfpy/stf_lib/stf_reader_constants.pxi"

cdef class StringVectorIterator:
cdef class HeaderCommentsTypeIterator:
def __next__(self):
if self.c_it == self.c_end_it:
raise StopIteration
value = dereference(self.c_it)
preincrement(self.c_it)
return value

cdef class StringVector:
cdef class HeaderCommentsType:
def __iter__(self):
return StringVectorIterator._construct(self.c_vec)
return HeaderCommentsTypeIterator._construct(self.c_vec)

def __len__(self):
return dereference(self.c_vec).size()
Expand Down Expand Up @@ -73,4 +73,4 @@ cdef class STFInstReader:
return self.c_reader.minor()

def getHeaderComments(self):
return StringVector._construct(dereference(self.c_reader).getHeaderCommentsString())
return HeaderCommentsType._construct(dereference(self.c_reader).getHeaderCommentsString())
6 changes: 3 additions & 3 deletions stfpy/stfpy/stf_lib/stf_inst_reader.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ from libcpp.vector cimport vector
from cython.cimports.libcpp.string import string
from stfpy.stf_lib.stf_inst cimport STFInst

ctypedef vector[string] StringVector
ctypedef vector[string].const_iterator StringVectorIterator
ctypedef vector[string] HeaderCommentsType
ctypedef vector[string].const_iterator HeaderCommentsTypeIterator

cdef extern from "stf_inst_reader.hpp" namespace "stf":
cdef cppclass STFInstReader:
Expand All @@ -25,4 +25,4 @@ cdef extern from "stf_inst_reader.hpp" namespace "stf":
iterator end()
uint32_t major()
uint32_t minor()
const StringVector& getHeaderCommentsString()
const HeaderCommentsType& getHeaderCommentsString()

0 comments on commit a4a0c8f

Please sign in to comment.