Menu

#99 textValidatorSetIncludes should pass an array of strings

confirmed
open
nobody
None
5
2015-04-11
2015-04-11
Mike Jones
No

The type signature of wxWidgets SetIncludes is an wxArrayString. The textValidatorGetIncludes is coded for an array of strings, but textValidatorSetIncludes passes a pointer to a single string. The result is the validator does not work. Changing it to an array of strings fixes the problem.

This code was tested in an application and it works. There might be a better way to allocate and free the array using a with... FFI statement that I am unaware of. But as long as it has the same effect as the code supplied here it should work.

This code appears to be auto generated, because when I changed it in the classes file, it was overwritten. I had to put it in my application code with a different name to test it.

If there is an easy way to change wxc or whatever is feeding the wxdirect, I am willing to attempt a real solution if I am given guidance and an example. I don't have time to learn all about wxdirect, etc.

Working version:

textValidatorSetIncludes :: TextValidator  a -> String -> Int ->  IO ()
textValidatorSetIncludes _obj list count 
  = withObjectRef "textValidatorSetIncludes" _obj $ \cobj__obj -> do
      let s = map (\ch -> ch:"") list
      print s
      ss <- mapM (\s -> newCWString s) s
      sa <- newArray ss
      wxTextValidator_SetIncludes cobj__obj  sa  (fromIntegral count)  
      mapM_ (\s -> free s) ss
      free sa
foreign import ccall "wxTextValidator_SetIncludes" wxTextValidator_SetIncludes :: Ptr (TTextValidator a) -> Ptr CWString -> CInt -> IO ()

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.