Browse Source

NativeFunction class >> isNativeFunction:

Herbert Vojčík 1 year 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 @@
 
 * Remove class Thenable, add trait TThenable.
 
++ NativeFunction class >>
+  + isNativeFunction:
+
 
 0.18.3:
 

+ 24 - 0
src/Kernel-Methods.js

@@ -3144,6 +3144,30 @@ $globals.NativeFunction.klass);
 
 $core.addMethod(
 $core.method({
+selector: "isNativeFunction:",
+protocol: "testing",
+fn: function (anObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return typeof anObject === "function";
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"isNativeFunction:",{anObject:anObject},$globals.NativeFunction.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject"],
+source: "isNativeFunction: anObject\x0a\x09<inlineJS: 'return typeof anObject === \x22function\x22'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.NativeFunction.klass);
+
+$core.addMethod(
+$core.method({
 selector: "methodOf:this:",
 protocol: "method calling",
 fn: function (nativeFunc,thisObject){

+ 4 - 0
src/Kernel-Methods.st

@@ -854,6 +854,10 @@ methodOf: nativeFunc this: thisObject valueWithArgs: args
 
 exists: aString
 	^ Smalltalk existsJsGlobal: aString
+!
+
+isNativeFunction: anObject
+	<inlineJS: 'return typeof anObject === "function"'>
 ! !
 
 Object subclass: #Timeout