-
Notifications
You must be signed in to change notification settings - Fork 53
Incorrect SetFoldLevel signature #70
Comments
@Ekopalypse , There are auto generated enums in GatewayDomain.cs file, this was intentional to have more meaning to the flag grouping.
Why don't you try using it instead, if you still face issue re-open this issue. If you strongly feel it should be int/uint as per the official interface doc of Scintilla, then please open a new issue as question because it covers more fields than the FOLDFLAG alone and needs to be dealt separately. |
@mahee96 |
Oops sorry for the confusion, I meant to refer you to FoldLevel enum in the Gatewaydomain.cs, Could you please check that enum satisfies your request |
@Ekopalypse checkout this
|
No, these are the flags which need to be used in combination with additional integers. public enum FoldLevel
{
BASE = 0x400,
WHITEFLAG = 0x1000,
HEADERFLAG = 0x2000,
NUMBERMASK = 0x0FFF
}
To set the respective flags you would set to line Now scintilla knows where to put the folding markers and how many lines to collapse or fold. |
Maybe this example is more descriptive
The lines need to be set like |
okay there is a slight discrepancy in Scintilla.iface file and the official documentation which we have to fix. The documentation states:
whereas the Scintilla.iface file states:
I think while updating the converter, we missed some info which states the obvious for types and enumerations. So essentially those enumerations if in C/C++ would be not typed but plain integers which could be combined using plain pipe/or operation. But in C# it needs to be of int type as the document states. |
@Ekopalypse , a quick fix can be made for this particular field for now, but the inventory of affected fields will be performed later some time and a fix will be given. |
@Ekopalypse, The fix is created as a pull request, review the commit and see if the issue will be resolved after this merge. Thanks. |
@mahee96 - just to be clear, I am a C# noob. |
I agree, we should use an enum |
@Ekopalypse, That's great finding, I for once, forgot about the .NET runtime being managed and the standard int size(32-bit signed) is limiting when the actual data is a pointer type value. In unmanaged code the int datatype is 32-bit signed on both x86/x64 but a Pointer type is dependent on the addressability ie, 32-bit unsigned on x86, 64-bit unsigned on x64. IntPtr size is machine dependent, also it is a signed integer containers which can hold unsigned pointers from unmanaged code. So as you said, the IntPtr is the appropriate one to be used here, because even scintilla document states the same. This should be the reason for the issue #68 where the type of the underlying marshalled call to C++ application code returns a pointer type of 8bytes on x64 which doesn't fit on the 32-bit signed integer and overflowed data is lost. Long cannot be used since it would essentially work for 64 bit space but in 32-bit space it would again cause the same issue where the structures/layout no longer maps to the underlying data structure in memory. This is because in 64 bit space the struct size would be 8(int*)+4(int) = 12 bytes but on 32-bit space it will be 4(int*)+4(int) = 8 bytes. Hence this data when interpreted in managed code based on 8(long)+4(int) will always map to 12 bytes and will break the 32-bit plugin. Reverse happens when using struct A{ int var; int data; } where 32-bit space plugins will work fine and 64-bit space plugins will break. So using a IntPtr should take care of automatic pointer size space allocation in structs which should then provide correct mappings of layouts. The other part to using IntPtr would be the pointer arithmetic, there is no direct pointer arithmetic such as +,- etc when dealing with IntPtr. static methods such as IntPtr.Add(ptr, off)...etc is present to handle these situations, but is not sufficient. We need to manually write the wrapper classes which perform pointer arithmetic if in case.
|
@kbilsted, I don't think its about enum anymore, its about the underlying struct mappings that are now causing problems due to mismatch in the types to be used, ex: using int is incorrect when scintilla says to use intptr_t whose equivalent in C# is IntPtr. Let me know your thoughts on these. |
+1 using IntPtr would only increase burden on the developer who is using this template, since for arithmetic they have to perform cast to long/ulong/int/uint (considering fact that pointers are unsigned) even for 32-bit (putting 4 byte pointers into 8-byte containers doesn't hurt). |
Just for my understanding, there are no open issues that concern me, meaning where I should/can help or provide information? |
we are aware of this issue and will fix if it resurfaces to prevent regression. Closing issue. |
SetFoldLevel needs to have an integer type as its second parameter instead of the FoldLevel enum.
The text was updated successfully, but these errors were encountered: