Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

[x64 fix]: Scintilla structures required correction for x64 #75

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ UpgradeLog*.XML
*.pyc

Visual Studio Project Template C#/$projectname$.sln
.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def ReadFromFile(self, name):
currentCategory = ""
currentComment = []
currentCommentFinished = 0
import os, os.path, inspect
if '__file__' not in locals():
__file__ = inspect.getframeinfo(inspect.currentframe())[0]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set cwd to script path for traversing relative file paths correctly such as ../../ etc

os.chdir(os.path.dirname(os.path.realpath(__file__)))
file = open(name)
for line in file.readlines():
line = sanitiseLine(line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def isTypeUnsupported(t):
if t in ["formatrange"]: return True
return False

def translateType(t):
def translateType(t:str):
if t == "cells": return "Cells"
if t == "colour": return "Colour"
if t == "line": return "int"
if t == "line": return "long"
Copy link
Collaborator Author

@mahee96 mahee96 May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line and position types need to be atleast 64-bit wide which can accommodate both 32-bit data in x86 execution and 64-bit data in x64 execution.
Hence long is used instead of int.

IntPtr could have been used as suggested, but that complicates things with arithmetic operations.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the correct assumption if you build a 32bit and a64 bit version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, there is a potential issue for set operations, if we allow the long to be used and user supplies a long value but the execution env is x86. This might result in overflow/truncation.

I was just focusing on get operation where the system returned type can fit on the target container for both x86 and x64.

So we are again left with only option of using IntPtr to make it work for both environment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have suggested alternative fix for this: see my reply below

if t == "pointer": return "IntPtr"
if t == "position": return "int"
if t == "position": return "long"
if t == "textrange": return "TextRange"
if t == "findtext": return "TextToFind"
if t == "keymod": return "KeyModifier"
Expand Down Expand Up @@ -81,7 +81,7 @@ def getUnsafeModifier(returnType, param1Type, param2Type):
def translateReturnType(v, param1Type, param2Type):
if param1Type == "stringresult" or param2Type == "stringresult":
return "string"
else:
else:
return translateType(v["ReturnType"])

def getParameterList(param1Type, param1Name, param2Type, param2Name):
Expand All @@ -100,6 +100,7 @@ def printEnumDefinitions(f):
if v["FeatureType"] in ["enu"] and name not in ["Keys"]: # for all except excluded enums [conflicting]
appendComment(indent, out, v)
prefix = v["Value"]
out.append(indent + "[Flags]")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enums now have the [Flags] Attribute which makes them combinable with other constants of same enum type.

out.append(indent + "public enum " + name)
out.append(indent + "{")
for ename in f.order:
Expand Down Expand Up @@ -189,10 +190,6 @@ def printLexGatewayFile(f):
out.append(iindent + "return 1 == (int)" +res+ ";")
elif returnType == "Colour":
out.append(iindent + "return new Colour((int) " +res+ ");")
# elif returnType == "Line":
# out.append(iindent + "return new Line((int) " +res+ ");")
# elif returnType == "Position":
# out.append(iindent + "return new Position((int) " +res+ ");")
elif returnType == "string":
out.append(iindent + res + ";")
out.append(iindent + "return Encoding.UTF8.GetString("+bufferVariableName+").TrimEnd('\\0');")
Expand Down
Loading