Changeset 494


Ignore:
Timestamp:
Sep 20, 2013 4:06:19 AM (4 years ago)
Author:
bjarni
Message:

Fixing marshalling for returning strings in CSharp Coinmp.cs wrapper functions for trunk 1.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CoinMP/examples/csharp/Coinmp.cs

    r377 r494  
    103103        [DllImport("coinmp.dll")] public static extern int CoinGetSolverNameBuf(StringBuilder solverName, int buflen);
    104104
    105         [DllImport("coinmp.dll")] public static extern string CoinGetVersionStr();
     105        [DllImport("coinmp.dll", EntryPoint = "CoinGetVersionStr")] public static extern IntPtr CoinGetVersionStrIntPtr();
     106        public static string CoinGetVersionStr() { return Marshal.PtrToStringAnsi(CoinGetVersionStrIntPtr()); }
    106107        [DllImport("coinmp.dll")] public static extern int CoinGetVersionStrBuf(StringBuilder versionStr, int buflen);
    107108        [DllImport("coinmp.dll")] public static extern double CoinGetVersion();
     
    187188        [DllImport("coinmp.dll")] public static extern int CoinCheckProblem(IntPtr hProb);
    188189
    189         [DllImport("coinmp.dll")] public static extern string CoinGetProblemName(IntPtr hProb);
    190         [DllImport("coinmp.dll")] public static extern int CoinGetProblemNameBuf(IntPtr hProb,
    191                         StringBuilder problemName, int buflen);
     190        [DllImport("coinmp.dll", EntryPoint = "CoinGetProblemName")] public static extern IntPtr CoinGetProblemNameIntPtr(IntPtr hProb);
     191        public static string CoinGetProblemName(IntPtr hProb) { return Marshal.PtrToStringAnsi(CoinGetProblemNameIntPtr(hProb)); }
     192        [DllImport("coinmp.dll")] public static extern int CoinGetProblemNameBuf(IntPtr hProb, StringBuilder problemName, int buflen);
    192193
    193194        [DllImport("coinmp.dll")] public static extern int CoinGetColCount(IntPtr hProb);
    194195        [DllImport("coinmp.dll")] public static extern int CoinGetRowCount(IntPtr hProb);
    195196
    196         [DllImport("coinmp.dll")] public static extern string CoinGetColName(IntPtr hProb, int col);
    197         [DllImport("coinmp.dll")] public static extern int CoinGetColNameBuf(IntPtr hProb, int col,
    198                         StringBuilder colName, int buflen);
    199 
    200         [DllImport("coinmp.dll")] public static extern string CoinGetRowName(IntPtr hProb, int row);
    201         [DllImport("coinmp.dll")] public static extern int CoinGetRowNameBuf(IntPtr hProb, int row,
    202                         StringBuilder rowName, int buflen);
     197        [DllImport("coinmp.dll", EntryPoint = "CoinGetColName")] public static extern IntPtr CoinGetColNameIntPtr(IntPtr hProb, int col);
     198        public static string CoinGetColName(IntPtr hProb, int col) { return Marshal.PtrToStringAnsi(CoinGetColNameIntPtr(hProb, col)); }
     199        [DllImport("coinmp.dll")] public static extern int CoinGetColNameBuf(IntPtr hProb, int col, StringBuilder colName, int buflen);
     200
     201        [DllImport("coinmp.dll", EntryPoint = "CoinGetRowName")] public static extern IntPtr CoinGetRowNameIntPtr(IntPtr hProb, int row);
     202        public static string CoinGetRowName(IntPtr hProb, int row) { return Marshal.PtrToStringAnsi(CoinGetRowNameIntPtr(hProb, row)); }
     203        [DllImport("coinmp.dll")] public static extern int CoinGetRowNameBuf(IntPtr hProb, int row, StringBuilder rowName, int buflen);
    203204
    204205        [DllImport("coinmp.dll")] public static extern int CoinSetMsgLogCallback(IntPtr hProb, MsgLogDelegate msgLogDelegate);
     
    215216        [DllImport("coinmp.dll")] public static extern int CoinGetSolutionStatus(IntPtr hProb);
    216217
    217         [DllImport("coinmp.dll")] public static extern string CoinGetSolutionText(IntPtr hProbs);
    218         [DllImport("coinmp.dll")] public static extern int CoinGetSolutionTextBuf(IntPtr hProbs,
    219                         StringBuilder solutionText, int buflen);
     218        [DllImport("coinmp.dll", EntryPoint = "CoinGetSolutionText")] public static extern IntPtr CoinGetSolutionTextIntPtr(IntPtr hProb);
     219        public static string CoinGetSolutionText(IntPtr hProb) { return Marshal.PtrToStringAnsi(CoinGetSolutionTextIntPtr(hProb)); }
     220        [DllImport("coinmp.dll")] public static extern int CoinGetSolutionTextBuf(IntPtr hProb, StringBuilder solutionText, int buflen);
    220221
    221222        [DllImport("coinmp.dll")] public static extern double CoinGetObjectValue(IntPtr hProb);
     
    256257                        StringBuilder optionName, StringBuilder shortName, int buflen);
    257258
    258 
     259                                               
    259260        [DllImport("coinmp.dll")] public static extern int CoinGetOptionGroup(IntPtr hProb, int optionID);
    260261        [DllImport("coinmp.dll")] public static extern int CoinGetOptionType(IntPtr hProb, int optionID);
     
    269270
    270271
    271         [DllImport("coinmp.dll")] public static extern string CoinGetOptionName(IntPtr hProb, int optionID);
    272         [DllImport("coinmp.dll")] public static extern int CoinGetOptionNameBuf(IntPtr hProb, int optionID,
    273                         StringBuilder optionName, int buflen);
    274 
    275         [DllImport("coinmp.dll")] public static extern string CoinGetOptionShortName(IntPtr hProb, int optionID);
    276         [DllImport("coinmp.dll")] public static extern int CoinGetOptionShortNameBuf(IntPtr hProb, int optionID,
    277                         StringBuilder shortName, int buflen);
     272        [DllImport("coinmp.dll", EntryPoint = "CoinGetOptionName")] public static extern IntPtr CoinGetOptionNameIntPtr(IntPtr hProb, int optionID);
     273        public static string CoinGetOptionName(IntPtr hProb, int optionID) { return Marshal.PtrToStringAnsi(CoinGetOptionNameIntPtr(hProb, optionID)); }
     274        [DllImport("coinmp.dll")] public static extern int CoinGetOptionNameBuf(IntPtr hProb, int optionID, StringBuilder optionName, int buflen);
     275
     276        [DllImport("coinmp.dll", EntryPoint = "CoinGetOptionShortName")] public static extern IntPtr CoinGetOptionShortNameIntPtr(IntPtr hProb, int optionID);
     277        public static string CoinGetOptionShortName(IntPtr hProb, int optionID) { return Marshal.PtrToStringAnsi(CoinGetOptionShortNameIntPtr(hProb, optionID)); }
     278        [DllImport("coinmp.dll")] public static extern int CoinGetOptionShortNameBuf(IntPtr hProb, int optionID, StringBuilder shortName, int buflen);
    278279
    279280        [DllImport("coinmp.dll")] public static extern int CoinGetOptionChanged(IntPtr hProb, int optionID);
     
    285286        [DllImport("coinmp.dll")] public static extern int CoinSetRealOption(IntPtr hProb, int optionID, double realValue);
    286287
    287         [DllImport("coinmp.dll")] public static extern string CoinGetStringOption(IntPtr hProb, int optionID);
    288         [DllImport("coinmp.dll")] public static extern int CoinGetStringOptionBuf(IntPtr hProb, int optionID,
    289                         StringBuilder stringValue, int buflen);
    290         [DllImport("coinmp.dll")] public static extern int CoinSetStringOption(IntPtr hProb, int optionID,
    291                         string stringValue);
     288        [DllImport("coinmp.dll", EntryPoint = "CoinGetStringOption")] public static extern IntPtr CoinGetStringOptionIntPtr(IntPtr hProb, int optionID);
     289        public static string CoinGetStringOption(IntPtr hProb, int optionID) { return Marshal.PtrToStringAnsi(CoinGetStringOptionIntPtr(hProb, optionID)); }
     290        [DllImport("coinmp.dll")] public static extern int CoinGetStringOptionBuf(IntPtr hProb, int optionID, StringBuilder stringValue, int buflen);
     291        [DllImport("coinmp.dll")] public static extern int CoinSetStringOption(IntPtr hProb, int optionID, string stringValue);
    292292    }
    293293}
Note: See TracChangeset for help on using the changeset viewer.