Commit 33efc7fe authored by Michael Büsch's avatar Michael Büsch

common: Add Cython declarations for isInteger() and isString()

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent 95d1d3ed
......@@ -25,6 +25,7 @@ from awlsim.common.compat import *
from awlsim.common.exceptions import *
from awlsim.common.util import *
from awlsim.common.datatypehelpers import * #+cimport
from awlsim.common.xmlfactory import *
from awlsim.awloptimizer.base import *
......
......@@ -131,3 +131,12 @@ cdef inline uint32_t intDivRoundUp(uint32_t n, uint32_t d):
return (n + d - 1u) // d
cdef uint32_t getMSB(uint32_t value)
cdef inline _Bool isInteger(object value):
#@cy3 return isinstance(value, int)
#@cy2 return isinstance(value, (int, long))
cdef inline _Bool isString(object value):
#@cy3 return isinstance(value, str)
#@cy2 return isinstance(value, (unicode, str))
......@@ -48,6 +48,8 @@ __all__ = [
"roundUp",
"intDivRoundUp",
"getMSB",
"isInteger",
"isString",
]
......@@ -264,3 +266,21 @@ def getMSB(value): #@nocy
value |= value >> 8
value |= value >> 16
return value ^ (value >> 1)
def __isInteger_python2(value): #@nocy #@nocov
return isinstance(value, (int, long)) #@nocy
def __isInteger_python3(value): #@nocy #@nocov
return isinstance(value, int) #@nocy
isInteger = py23(__isInteger_python2, #@nocy
__isInteger_python3) #@nocy
def __isString_python2(value): #@nocy #@nocov
return isinstance(value, (unicode, str)) #@nocy
def __isString_python3(value): #@nocy #@nocov
return isinstance(value, str) #@nocy
isString = py23(__isString_python2, #@nocy
__isString_python3) #@nocy
......@@ -23,6 +23,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
#from awlsim.common.cython_support cimport * #@cy
from awlsim.common.compat import *
from awlsim.common.datatypehelpers import * #+cimport
from awlsim.common.enumeration import *
from awlsim.common.exceptions import *
......@@ -59,8 +60,6 @@ __all__ = [
"bytesToHexStr",
"toUnixEol",
"toDosEol",
"isInteger",
"isString",
"strEqual",
"isiterable",
"getfirst",
......@@ -284,24 +283,6 @@ def toDosEol(string):
"""
return toUnixEol(string).replace("\n", "\r\n")
def __isInteger_python2(value): #@nocov
return isinstance(value, (int, long))
def __isInteger_python3(value): #@nocov
return isinstance(value, int)
isInteger = py23(__isInteger_python2,
__isInteger_python3)
def __isString_python2(value): #@nocov
return isinstance(value, (unicode, str))
def __isString_python3(value): #@nocov
return isinstance(value, str)
isString = py23(__isString_python2,
__isString_python3)
def strEqual(string0, string1, caseSensitive=True):
"""Compare string0 to string1.
If caseSensitive is False, case is ignored.
......
......@@ -23,6 +23,7 @@ from __future__ import division, absolute_import, print_function, unicode_litera
#from awlsim.common.cython_support cimport * #@cy
from awlsim.common.compat import *
from awlsim.common.datatypehelpers import * #+cimport
from awlsim.common.exceptions import *
from awlsim.common.cpuconfig import *
......
......@@ -32,6 +32,7 @@ from awlsim.common.env import *
from awlsim.common.util import *
from awlsim.common.exceptions import *
from awlsim.common.monotonic import * #+cimport
from awlsim.common.datatypehelpers import * #+cimport
from awlsim.core.main import * #+cimport
from awlsim.core.symbolparser import *
......
......@@ -25,6 +25,7 @@ from awlsim_loader.common import *
from awlsim_loader.coreclient import *
import awlsim_loader.cython_helper as cython_helper
from awlsim.common.monotonic import monotonic_time #+cimport
from awlsim.common.datatypehelpers import * #+cimport
import sys
import traceback
......
......@@ -27,6 +27,7 @@ from awlsim.common.enumeration import *
from awlsim.common.wordpacker import *
from awlsim.common.xmlfactory import *
from awlsim.common.util import *
from awlsim.common.datatypehelpers import * #+cimport
import hashlib
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment