VM Maker: FileAttributesPlugin.oscog-eem.57.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: FileAttributesPlugin.oscog-eem.57.mcz

commits-2
 
Eliot Miranda uploaded a new version of FileAttributesPlugin to project VM Maker:
http://source.squeak.org/VMMaker/FileAttributesPlugin.oscog-eem.57.mcz

==================== Summary ====================

Name: FileAttributesPlugin.oscog-eem.57
Author: eem
Time: 6 September 2020, 8:11:15.189519 pm
UUID: 6f82e8ad-42c9-484c-8b96-2c7b400f9208
Ancestors: FileAttributesPlugin.oscog-eem.56

Recind the rush of blood to the head.  Since the specialObjectsArray was only changed in Squeak in January make primitiveFileMasks use WordArrya only when available.  Also, thanks to Pierce, fix the regression in forgetting to export the first switch-hitting version.

Use common code for string return.

=============== Diff against FileAttributesPlugin.oscog-eem.56 ===============

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveFileMasks (in category 'file primitives') -----
  primitiveFileMasks
  "Answer an array (or word array) of well known file masks"
+ <export: true>
+ | maybeClassWordArray |
+ maybeClassWordArray := interpreterProxy classWordArray.
+ maybeClassWordArray = interpreterProxy nilObject
-
- self cppIf: PharoVM
  ifTrue: [self primitiveFileMasksAsArray]
+ ifFalse: [self primitiveFileMasksAsWordArrayUsing: maybeClassWordArray]!
- ifFalse: [self primitiveFileMasksAsWordArray]!

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveFileMasksAsArray (in category 'file primitives') -----
  primitiveFileMasksAsArray
  "Answer an array of well known file masks"
 
- <notOption: #PharoVM>
  <inline: #always>
  | masksArray masks nilObj |
  masksArray := interpreterProxy instantiateClass: interpreterProxy classArray indexableSize: 8.
  masksArray ifNil: [^interpreterProxy primitiveFailFor: PrimErrNoMemory].
 
  masks := self cCoerceSimple: (interpreterProxy firstIndexableField: masksArray) to: #'sqInt *'.
  nilObj := interpreterProxy nilObject.
 
  self cppIf: #S_IFSOCK defined
  ifTrue: [masks at: 1 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFSOCK] inSmalltalk: [16rC000]))]
  ifFalse: [masks at: 1 put: nilObj].
 
  self cppIf: #S_IFLNK defined
  ifTrue: [masks at: 2 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFLNK] inSmalltalk: [16rA000]))]
  ifFalse: [masks at: 1 put: nilObj].
 
  masks at: 3 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFREG] inSmalltalk: [16r8000])).
 
  self cppIf: #S_IFBLK defined
  ifTrue: [masks at: 4 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFBLK] inSmalltalk: [16r6000]))]
  ifFalse: [masks at: 1 put: nilObj].
 
  masks at: 5 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFDIR] inSmalltalk: [16r4000])).
 
  masks at: 6 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFCHR] inSmalltalk: [16r2000])).
 
  self cppIf: #S_IFIFO defined
  ifTrue: [masks at: 7 put: (interpreterProxy integerObjectOf: (self cCode: [#S_IFIFO] inSmalltalk: [16r1000]))]
  ifFalse: [masks at: 1 put: nilObj].
 
  interpreterProxy methodReturnValue: masksArray!

Item was removed:
- ----- Method: FileAttributesPlugin>>primitiveFileMasksAsWordArray (in category 'file primitives') -----
- primitiveFileMasksAsWordArray
- "Answer an array of well known file masks"
-
- <notOption: #PharoVM>
- <inline: #always>
- | masksObj masks  |
- masksObj := interpreterProxy instantiateClass: interpreterProxy classWordArray indexableSize: 8.
- masksObj ifNil: [^interpreterProxy primitiveFailFor: PrimErrNoMemory].
- masks := self cCoerceSimple: (interpreterProxy firstIndexableField: masksObj) to: #'int *'.
- masks at: 0 put: (self cCode: [#S_IFMT] inSmalltalk: [16rF000]).
-
- self cppIf: #S_IFSOCK defined ifTrue:
- [masks at: 1 put: (self cCode: [#S_IFSOCK] inSmalltalk: [16rC000])].
-
- self cppIf: #S_IFLNK defined ifTrue:
- [masks at: 2 put: (self cCode: [#S_IFLNK] inSmalltalk: [16rA000])].
-
- masks at: 3 put: (self cCode: [#S_IFREG] inSmalltalk: [16r8000]).
-
- self cppIf: #S_IFBLK defined ifTrue:
- [masks at: 4 put: (self cCode: [#S_IFBLK] inSmalltalk: [16r6000])].
-
- masks at: 5 put: (self cCode: [#S_IFDIR] inSmalltalk: [16r4000]).
-
- masks at: 6 put: (self cCode: [#S_IFCHR] inSmalltalk: [16r2000]).
-
- self cppIf: #S_IFIFO defined ifTrue:
- [masks at: 7 put: (self cCode: [#S_IFIFO] inSmalltalk: [16r1000])].
-
- interpreterProxy methodReturnValue: masksObj!

Item was added:
+ ----- Method: FileAttributesPlugin>>primitiveFileMasksAsWordArrayUsing: (in category 'file primitives') -----
+ primitiveFileMasksAsWordArrayUsing: classWordArray
+ "Answer an array of well known file masks"
+
+ <inline: #always>
+ | masksObj masks  |
+ masksObj := interpreterProxy instantiateClass: classWordArray indexableSize: 8.
+ masksObj ifNil: [^interpreterProxy primitiveFailFor: PrimErrNoMemory].
+ masks := self cCoerceSimple: (interpreterProxy firstIndexableField: masksObj) to: #'int *'.
+ masks at: 0 put: (self cCode: [#S_IFMT] inSmalltalk: [16rF000]).
+
+ self cppIf: #S_IFSOCK defined ifTrue:
+ [masks at: 1 put: (self cCode: [#S_IFSOCK] inSmalltalk: [16rC000])].
+
+ self cppIf: #S_IFLNK defined ifTrue:
+ [masks at: 2 put: (self cCode: [#S_IFLNK] inSmalltalk: [16rA000])].
+
+ masks at: 3 put: (self cCode: [#S_IFREG] inSmalltalk: [16r8000]).
+
+ self cppIf: #S_IFBLK defined ifTrue:
+ [masks at: 4 put: (self cCode: [#S_IFBLK] inSmalltalk: [16r6000])].
+
+ masks at: 5 put: (self cCode: [#S_IFDIR] inSmalltalk: [16r4000]).
+
+ masks at: 6 put: (self cCode: [#S_IFCHR] inSmalltalk: [16r2000]).
+
+ self cppIf: #S_IFIFO defined ifTrue:
+ [masks at: 7 put: (self cCode: [#S_IFIFO] inSmalltalk: [16r1000])].
+
+ interpreterProxy methodReturnValue: masksObj!

Item was changed:
  ----- Method: FileAttributesPlugin>>primitiveVersionString (in category 'file primitives') -----
  primitiveVersionString
  "Answer a string containing the version string for this plugin."
 
  <export: true>
+ interpreterProxy methodReturnString: self versionString!
- interpreterProxy pop: 1 thenPush: (self stringFromCString: self versionString)
- !

Item was removed:
- ----- Method: FileAttributesPlugin>>stringFromCString: (in category 'private') -----
- stringFromCString: aCString
- "Answer a new String copied from a null-terminated C string.
- Caution: This may invoke the garbage collector."
-
- | len newString |
- <var: 'aCString' type: #'const char *'>
- len := self strlen: aCString.
- newString := interpreterProxy
- instantiateClass: interpreterProxy classString
- indexableSize: len.
- newString ifNil: [^interpreterProxy primitiveFailFor: PrimErrNoMemory].
- self strncpy: (interpreterProxy arrayValueOf: newString)
- _: aCString
- _: len. "(char *)strncpy()"
- ^ newString
- !