Browse Source

NativeFunction class >> isNativeFunction:

Herbert Vojčík 7 months ago
parent
commit
4d761426e5
3 changed files with 31 additions and 0 deletions
  1. 3 0
      API-CHANGES.txt
  2. 24 0
      src/Kernel-Methods.js
  3. 4 0
      src/Kernel-Methods.st

+ 3 - 0
API-CHANGES.txt

@@ -2,6 +2,9 @@
2 2
 
3 3
 * Remove class Thenable, add trait TThenable.
4 4
 
5
++ NativeFunction class >>
6
+  + isNativeFunction:
7
+
5 8
 
6 9
 0.18.3:
7 10
 

+ 24 - 0
src/Kernel-Methods.js

@@ -3144,6 +3144,30 @@ $globals.NativeFunction.klass);
3144 3144
 
3145 3145
 $core.addMethod(
3146 3146
 $core.method({
3147
+selector: "isNativeFunction:",
3148
+protocol: "testing",
3149
+fn: function (anObject){
3150
+var self=this;
3151
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3152
+return $core.withContext(function($ctx1) {
3153
+//>>excludeEnd("ctx");
3154
+return typeof anObject === "function";
3155
+return self;
3156
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
3157
+}, function($ctx1) {$ctx1.fill(self,"isNativeFunction:",{anObject:anObject},$globals.NativeFunction.klass)});
3158
+//>>excludeEnd("ctx");
3159
+},
3160
+//>>excludeStart("ide", pragmas.excludeIdeData);
3161
+args: ["anObject"],
3162
+source: "isNativeFunction: anObject\x0a\x09<inlineJS: 'return typeof anObject === \x22function\x22'>",
3163
+referencedClasses: [],
3164
+//>>excludeEnd("ide");
3165
+messageSends: []
3166
+}),
3167
+$globals.NativeFunction.klass);
3168
+
3169
+$core.addMethod(
3170
+$core.method({
3147 3171
 selector: "methodOf:this:",
3148 3172
 protocol: "method calling",
3149 3173
 fn: function (nativeFunc,thisObject){

+ 4 - 0
src/Kernel-Methods.st

@@ -854,6 +854,10 @@ methodOf: nativeFunc this: thisObject valueWithArgs: args
854 854
 
855 855
 exists: aString
856 856
 	^ Smalltalk existsJsGlobal: aString
857
+!
858
+
859
+isNativeFunction: anObject
860
+	<inlineJS: 'return typeof anObject === "function"'>
857 861
 ! !
858 862
 
859 863
 Object subclass: #Timeout