Embed phalanger & inject an object in scripting context
12 posts
• Page 2 of 2 • 1, 2
Re: Embed phalanger & inject an object in scripting context
Is there any way to force compiler configuration loading ? Due to my setup of mono, I think I need to manually initialize the compiler with the classLibrary.
EDIT : I managed to manually load PhpNetClassLibrary and make var_dump work by calling the following code
Now this code (.net property call) gives an error :
EDIT :
I think that in PhpGetMemberBinder.FallbackInvokeMember the test
EDIT :
target.Value is not a CLRObject but my .net type, how to wrap it ?
FINAL EDIT :
Found it (thx to the source being open !) : I needed to wrap the browser object like that :
Maybe the documentation should be updated ?
EDIT : I managed to manually load PhpNetClassLibrary and make var_dump work by calling the following code
- Code: Select all
_context.ApplicationContext.AssemblyLoader.Load(new[] { new CompilationParameters.ReferenceItem() {
LibraryRoot = ".",
Reference = "PhpNetClassLibrary, Version=3.0.0.0, Culture=neutral, PublicKeyToken=4af37afe3cde05fb" }
});
Now this code (.net property call) gives an error :
- Code: Select all
$test = $browser->Window;
- Code: Select all
System.InvalidCastException: Cannot cast from source type to destination type.
at PHP.Core.PhpVariable.IsEmpty (object) <0x001b1>
at PHP.Core.Binders.PhpGetMemberBinder.<FallbackInvokeMember>b__6 (object) <0x00013>
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object,PHP.Core.Reflection.DTypeDesc) <0x0003f>
at System.Dynamic.UpdateDelegates.UpdateAndExecute2<object, PHP.Core.Reflection.DTypeDesc, object> (System.Runtime.CompilerServices.CallSite,object,PHP.Core.Reflection.DTypeDesc) <0x003c7>
at <php^1>.<Global>.<php^1>.<Main> (PHP.Core.ScriptContext,System.Collections.Generic.Dictionary`2<string, object>,PHP.Core.Reflection.DObject,PHP.Core.Reflection.DTypeDesc,bool) <0x001ed>
at PHP.Core.DynamicCode.EvalInternal (string,string,string,PHP.Core.EvalKinds,PHP.Core.ScriptContext,System.Collections.Generic.Dictionary`2<string, object>,PHP.Core.Reflection.DObject,PHP.Core.Reflection.DTypeDesc,PHP.Core.Reflection.SourceCodeDescriptor,bool,PHP.Core.NamingContext) <0x00360>
at PHP.Core.DynamicCode.Eval (string,bool,PHP.Core.ScriptContext,System.Collections.Generic.Dictionary`2<string, object>,PHP.Core.Reflection.DObject,PHP.Core.Reflection.DTypeDesc,string,int,int,int,PHP.Core.NamingContext) <0x000b3>
at Kimono.Host.PhpInterpreter.Eval (string) <0x0002f>
at Kimono.Host.PhpInterpreter..ctor (Kimono.Dom.IDomBrowser) <0x001ab>
at Kimono.Sandbox.Run (Kimono.Dom.IDomBrowser) <0x000af>
EDIT :
I think that in PhpGetMemberBinder.FallbackInvokeMember the test
- Code: Select all
if ((obj = target.Value as DObject) != null)
EDIT :
target.Value is not a CLRObject but my .net type, how to wrap it ?
FINAL EDIT :
Found it (thx to the source being open !) : I needed to wrap the browser object like that :
- Code: Select all
PHP.Core.Operators.SetVariable(_context, null, "browser", ClrObject.Wrap(browser));
Maybe the documentation should be updated ?
- nelson4070
- Posts: 7
- Joined: April 19th, 2013, 1:04 am
Re: Embed phalanger & inject an object in scripting context
Excellent! I've realized once I saw this
I'm glad you've found it, great work!
Thanks,
- Code: Select all
if ((obj = target.Value as DObject) != null)
I'm glad you've found it, great work!
Thanks,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
12 posts
• Page 2 of 2 • 1, 2
Return to PHP/C# interoperability
Who is online
Users browsing this forum: No registered users and 2 guests