@@ -75,6 +75,12 @@ extern "C"
75
75
[global::System.Runtime .InteropServices .DllImport (" $dllimport" , EntryPoint=" ByteVector_to" )]
76
76
public static extern global::System.IntPtr ByteVector_to (
77
77
[global::System.Runtime .InteropServices .MarshalAs (global::System.Runtime .InteropServices .UnmanagedType .LPArray )]byte[] data, int size);
78
+ public static byte[] To_ByteArray (global::System.IntPtr cPtr) {
79
+ byte[] result = new byte[$modulePINVOKE.ByteVector_size (cPtr)];
80
+ global::System.Runtime .InteropServices .Marshal .Copy ($modulePINVOKE.ByteVector_data (cPtr), result, 0 , result.Length );
81
+ $modulePINVOKE.ByteVector_free (cPtr);
82
+ return result;
83
+ }
78
84
%}
79
85
80
86
#ifdef SWIGJAVA
@@ -116,21 +122,15 @@ static std::vector<unsigned char>* SWIG_JavaArrayToVectorUnsignedChar(JNIEnv *je
116
122
%typemap(cstype) std::vector<unsigned char > " byte[]"
117
123
%typemap(cstype) digidoc::X509Cert " System.Security.Cryptography.X509Certificates.X509Certificate2"
118
124
%typemap(csin, pre= " global::System.IntPtr cPtr$csinput = digidocPINVOKE.ByteVector_to($csinput, $csinput.Length);
119
- var handleRef$csinput = new global::System.Runtime.InteropServices.HandleRef(this , cPtr$csinput);"
125
+ var handleRef$csinput = new global::System.Runtime.InteropServices.HandleRef($csinput , cPtr$csinput);"
120
126
) std::vector<unsigned char > " handleRef$csinput"
121
127
%typemap(csout, excode=SWIGEXCODE) std::vector<unsigned char > {
122
128
global::System.IntPtr cPtr = $imcall;$excode
123
- byte[] result = new byte[$modulePINVOKE.ByteVector_size (cPtr)];
124
- global::System.Runtime .InteropServices .Marshal .Copy ($modulePINVOKE.ByteVector_data (cPtr), result, 0 , result.Length );
125
- $modulePINVOKE.ByteVector_free (cPtr);
126
- return result;
129
+ return $modulePINVOKE.To_ByteArray (cPtr);
127
130
}
128
131
%typemap(csout, excode=SWIGEXCODE) digidoc::X509Cert {
129
132
global::System.IntPtr cPtr = $imcall;$excode
130
- byte[] der = new byte[$modulePINVOKE.ByteVector_size (cPtr)];
131
- global::System.Runtime .InteropServices .Marshal .Copy ($modulePINVOKE.ByteVector_data (cPtr), der, 0 , der.Length );
132
- $modulePINVOKE.ByteVector_free (cPtr);
133
- return new System.Security .Cryptography .X509Certificates .X509Certificate2 (der);
133
+ return new System.Security .Cryptography .X509Certificates .X509Certificate2 ($modulePINVOKE.To_ByteArray (cPtr));
134
134
}
135
135
%typemap(out) std::vector<unsigned char > %{ $result = new std::vector<unsigned char >(std::move ($1 )); %}
136
136
%typemap(out) digidoc::X509Cert %{ $result = new std::vector<unsigned char >($1 ); %}
0 commit comments