Check if function is extension - reflection

Given a KFunction how can I check if it's a extension function?
The only way I know is to check if function.extensionReceiverParameter returns null. Is there any other or a recommended way?

Currently, the only way to check this is to use:
function.extensionReceiverParameter.
If it returns null it's not an extension function. If it returns a non-null value that function is a extension function

Related

How do I omit a parameter in a JScript ADO/ASP classic method call?

How do I omit a parameter in a JScript ADO/ASP classic method call?
For example, a RecordSet object has a GetString method (e.g. recordset.GetString(StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr), where all parameters but the first are optional.
If I want to skip a parameter in VBScript (e.g., use the default for one parameter) I can do recordset.GetString 2, , "|", or use named parameters.
However, it doesn't seem like I can do the same with JScript. I've tried using null for the optional parameter, using an empty string (''), omitting it entirely (as with VBScript), and using JSON-style named parameters, with no luck.
Am I missing something, or is this not possible?
If you believe this statement
In VBScript, it is legal to omit parameters to function calls, by
writing a comma only, as in:
adoCmd.Execute , , adExecuteStream
In JavaScript, this is not legal, but in all cases so far, we have
been able to work around that in some way, mostly by specifying null
or zero in place of the missing parameters.
you can avoid to mix languages, if you come up with a specific strategy for each ADO method call. For your .GetString() case, the appropriate zilch value is -1. My evidence for the correctnes of this (specific) solution:
-1 'works' in VBScript too
other funny numerical values (0, -10) - and (surprisingly) undefined - throw 'Operation is not allowed' errors
"" and null throw a type error
This is not possible in pure JScript. To use the default parameter values, you need to explicitly specify these values in the method call (provided, of course, that you know what these values are).
A possible option is to use a mix of JScript and VBScript code, e.g. call the GetString function from VBScript and return its result to JScript. Some examples (that should give you the idea): WSH, HTA, ASP.

Modify Value of Parameters of Request

I want to know if it is possible to modify the value of the parameter of the request.
But i don't know how to do this.
I try with
$requestContent = $this->getRequest()->request->get('tactill_customerbundle_customertype');
Next I use
$request->request->replace()
But I don't how to use this method in my case.
Thanks
The replace method replaces all of the parameters in the request, so you probably do not want to do that.
I would use the set method instead - So you can do:
$request->request->set('tactill_customerbundle_customertype', $newValue)
You can read more in the Symfony2 documentation (http://api.symfony.com/2.0/) - you are looking for Symfony\Component\HttpFoundation\Request (which is the $request variable), which then returns a Symfony\Component\HttpFoundation\ParameterBag when you call the request() method.

can any one list all the valid arguments for setstyle() function for UIcomponents?

i am working with actionscript flex and using UIcomponents i need all the valid arguments for this function for example
component.setStyle("borderColor","white");
i need all valid strings for first string parameter and 2nd valid argument for there value setting,
i have some of them that are given below but i need all possible values for this function
inputs.setStyle("backgroundColor",0xA9C0E7);
inputs.setStyle("borderColor",0x9E9FFF);
inputs.setStyle("cornerRadius", 20);
thanx
regards
Locate reference for UIComponent
See "Styles" section.
http://examples.adobe.com/flex3/consulting/styleexplorer/Flex3StyleExplorer.html#

VTL evaluate or define an object reference

I would like to create a macro that takes a string as a parameter and evaluates that to an object. Something like:
#macro( valueTest $objRef)
#define( $obj )#evaluate("$${objRef}")#end
$obj.foo ## This would have to be translated to $obj.getFoo()
#end
Unfortunately the $obj variable does not point to object reference that could be used to call methods. $obj is a String and $obj.foo does not try to execute getFoo.
Somewhy I have a feeling that this is the nature of evaluate and it is not possible to do what I want to.
the reason why I want to do smth like this is because we have quite few macros that take both command bind path and command itself as a parameter and I am hoping the latter could be derived from first.
Unfortunately, Velocity does not have a mechanism to define functions which return object references. Macros are really intended to be a shortcut to display text.
In cases like this, the way to proceed is generally to create a "tool" in Java and put an instance in the context. A tool is just an ordinary class with a method that returns what you are looking for
e.g.
create an object with an "eval" method, then put it in the context as "referenceEvaluator".
#set($obj = $referenceEvaluator.eval($objRef))
You might find that your code is clearer if you avoid the double evaluation and just insert an object into the context named $obj that does what you want. (better performance, too).

Howto use the has_filter wordpress function with an object based callback

I have several plugins, all of which are based on using objects to hold the plugin.
In one plugin class named "test_plugin" I have:
apply_filter('wp_list_pages', array(&$this, 'wp_list_pages'));
I would like to use the has_filter function in one plugin to try to detect the presence of the other plugin.
I cant find any examples of the has_filter function being used with an object based callback.
I have tried:
has_filter('wp_list_pages', array('test_plugin', 'wp_list_pages'));
But this only returns false. I have written some debugging output to display the contents of the $wp_filters global variable and the callback is definitely registered in the $wp_filters array.
Take a look at the _wp_filter_build_unique_id function defined at the bottom of wp-includes/plugin.php. That's where the array key for $wp_filters is generated. It looks like it does something like this for your case:
$obj_idx = get_class($this).'wp_list_pages';
and then appends an integer to the end of that to make sure it's unique. That integer is also added to a field called wp_filter_id on your object.

Resources