Re: Connecting Nim with Python
I tried with c_wchar_p, as well as, with c_char_p. Either way, didn't work. mystring = c_char_p("robert james fischer") test_lib.AmericanSoundex.argtype = c_char_p test_lib.AmericanSoundex.restype = c_char_p soundex_res = test_lib.AmericanSoundex(mystring) print('The Soundex is: %s'%soundex_res) After converting the mystring to bytes I’m getting: The Soundex is: b'x04' Do you know what C type the nim code for AmericanSoundex is being converted into ?
Re: Connecting Nim with Python
Try inserting this before your function call: test_lib.AmericanSoundex.argtype = (c_wchar_p) test_lib.AmericanSoundex.restype = (c_wchar_p)
Connecting Nim with Python
Hello I made some experiences connecting Nim with Python. At this page [http://akehrer.github.io/posts/connecting-nim-to-python](http://forum.nim-lang.org///akehrer.github.io/posts/connecting-nim-to-python)/ there are some cool hints about how to do that. However, I got some issues interfacing with string types. How can I declare a string at Nim and how should I treat it in Python ? I have the following code in Nim ('nim2py.nim)': proc AmericanSoundexCode(ch: char): int = case ch: of 'B', 'F', 'P', 'V' : return 1 of 'C', 'G', 'J', 'K', 'Q', 'S', 'X', 'Z' : return 2 of 'D', 'T' : return 3 of 'L': return 4 of 'M', 'N' : return 5 of 'R': return 6 of 'A', 'E', 'I', 'O', 'U', 'Y' : return -1 else : return 0 proc AmericanSoundex*(word: string): string {. exportc, dynlib .} = var output = newString(4) var lastCode = 0 var i, j = 0 # Get the first character while i < word.len: var ch = word[i] inc i # Reduce a lowercase character to an uppercase character if ((ch.int >= 97) and (ch.int <= 122)): dec ch, 32 if ((ch.int >= 65) and (ch.int <= 90)): lastCode = AmericanSoundexCode(ch) if lastCode < 0: lastCode = 0 output[j] = ch inc j break # Now lets hash the rest of this stuff while i < word.len: var ch = word[i] inc i # Reduce a lowercase character to an uppercase character if ((ch.int >= 97) and (ch.int <= 122)): dec ch, 32 if ((ch.int >= 65) and (ch.int <= 90)): var code = AmericanSoundexCode(ch) case code: of 0: continue of -1: lastCode = 0 else: if code != lastCode: lastCode = code output[j] = char(code + 48) inc j if j == 4: break # Pad the remainder of the string with zeroes while j < 4: output[j] = '0' inc j # We are done return output In Python I'm doing the following: from ctypes import * def main(): test_lib = CDLL('nim2py') ... mystring = "robert james fischer" soundex_res = test_lib.AmericanSoundex(mystring) print('The Soundex is: %s'%soundex_res) if __name__ == '__main__': main() Here's the output I'm getting: Traceback (most recent call last): File "py_calling_nim.py", line 33, in main() File "py_calling_nim.py", line 29, in main soundex_res = test_lib.AmericanSoundex(mystring) ctypes.ArgumentError: argument 1: : wrong type After converting the mystring to bytes I’m getting: The Soundex is: b'x04' Sorry, but I’m not sure where to go next other...
Hydraulic Cone Crusher Becomes the Advantageous Product on the Market
The mining machinery industry has stepped into a new level with the constant innovation and progresses of science and technology. http://www.crusher-manufacturers.com/project/crushing-chamber-of-crusher.html](http://forum.nim-lang.org///www.crusher-manufacturers.com/project/crushing-chamber-of-crusher.html) " >crushing chamber of crusher And the crusher industry in our country also has achieved a number of breakthroughs. Based on the market demands, our crusher industry has formed a complete product chain, covering jaw crusher, impact crusher, cone crusher, sand maker, mobile crushing station, construction waste processing equipment, as well as the full set of sandstone production line and the matching products. Chinese cone crusher is very common in the international markets. Our hydraulic cone crusher combines with the latest research findings at home and abroad http://www.crusher-manufacturers.com/project/gold-ore-wet-plant.html](http://forum.nim-lang.org///www.crusher-manufacturers.com/project/gold-ore-wet-plant.html) ">gold ore wet plant and is able to meet the ever-increasing market requirements. China hydraulic cone crusher employs the spring safety device and hydraulic cleaning room, which is more economical and practical. When China hydraulic cone crusher is working, the motor drives the triangular belt, big pulley, transmission shaft and the eccentric straps of both bevel gear wheel and bevel pinion to rotate. The power of the crushing cone rotating the eccentric annulus makes the crushing wall leave the rolling mortar wall. After crushed by hydraulic cone crusher for several times and reaching to the desired particle size, the materials will be discharged from the bottom. ZENITH Machinery is a professional Chinese cone crusher manufacturer. We have optimized and modified our cone crusher machine from various aspects. The newly developed hydraulic cone crusher is characterized by strong crushing ability, good particle shape, long working life of spare parts, easy maintenance, low production cost, http://www.crusher-manufacturers.com/faq/mineral-dressing-ore-crusher.html](http://forum.nim-lang.org///www.crusher-manufacturers.com/faq/mineral-dressing-ore-crusher.html) ">mineral dressing ore crusher rational structure, reliable operation, progressive crushing principle and high working efficiency. Now China hydraulic cone crusher becomes the advantageous product on the market.
Re: Stream data type
There is a new [asyncstreams](https://github.com/vegansk/nimboost/blob/master/src/boost/io/asyncstreams.nim) module in nimboost. It provides API close to streams module in stdlib, so it's probably too low-level for your standards, though. As for a cleaner abstraction, you might want to look into [iteratees](https://en.wikipedia.org/wiki/Iteratee) for that - seems close to what you're talking about.