public virtual Variable OnCompare( Variable a, Variable b ) { return null; }
public virtual Variable OnGetIndex( Context ctx, Variable key, bool isprop ) { return sgsGetPropertyByName( key, isprop ); }
public bool SetSubItem( string key, Variable val, bool isprop ) { return ctx.SetIndex( this, ctx.Var( key ), val, isprop ); }
public bool Unset( Variable key ) { return NI.Unset( _sgsEngine.ctx, var, key.var ) != 0; }
public bool sgsSetPropertyByName( Variable key, Variable val, bool isprop ) { _sgsEngine.Push( val ); bool ret = sgsSetPropertyByName( key, _sgsEngine, isprop, _sgsEngine.StackSize() - 1 ); _sgsEngine.Pop( 1 ); return ret; }
public string ConvertToString() { Variable v2 = new Variable( ctx, var ); NI.ToStringBufP( ctx.ctx, ref v2.var ); string s = v2.GetString(); v2.Release(); return s; }
public bool SetIndex( Int64 key, Variable val ) { return ctx.SetIndex( this, ctx.Var( key ), val, false ); }
// callback implementation helpers public Variable sgsGetPropertyByName( Variable key, bool isprop ) { SGSClassInfo cinfo = GetClassInfo(); SGSPropInfo propinfo; if( !cinfo.props.TryGetValue( key, out propinfo ) || !propinfo.canRead ) { if( backingStore != null ) return backingStore.GetSubItem( key, isprop ); return null; } object obj; if( propinfo.info is FieldInfo ) obj = (propinfo.info as FieldInfo).GetValue( this ); else // PropertyInfo obj = (propinfo.info as PropertyInfo).GetValue( this, null ); return _sgsEngine.ObjVar( obj ); }
public void IterGetKeyValue( out Variable key, out Variable val ) { NI.Variable outkey, outval; NI.IterGetData( _sgsEngine.ctx, var, out outkey, out outval ); key = _sgsEngine.Var( outkey, false ); val = _sgsEngine.Var( outval, false ); }
public bool SetIndex( Variable key, Variable val ) { return ctx.SetIndex( this, key, val, false ); }
public Variable GetSubItem( Variable key, bool isprop ) { return ctx.GetIndex( this, key, isprop ); }
public Variable GetProp( Variable key ) { return ctx.GetIndex( this, key, true ); }
public Variable GetIndex( Variable key ) { return ctx.GetIndex( this, key, false ); }
public virtual bool OnSetIndex( Context ctx, Variable key, Variable val, bool isprop ) { return sgsSetPropertyByName( key, ctx, isprop, 1 ); }
public bool SetProp( Variable key, Variable val ) { return ctx.SetIndex( this, key, val, true ); }
public virtual Variable OnSub( Variable a, Variable b ) { return null; }
public bool SetProp( string key, Variable val ) { return ctx.SetIndex( this, ctx.Var( key ), val, true ); }
public bool sgsSetPropertyByName( Variable key, Context ctx, bool isprop, int valueOnStack ) { SGSClassInfo cinfo = GetClassInfo(); SGSPropInfo propinfo; if( !cinfo.props.TryGetValue( key, out propinfo ) || !propinfo.canWrite ) { if( backingStore != null ) return backingStore.SetSubItem( key, ctx.StackItem( valueOnStack ), isprop ); return false; } if( propinfo.parseVarMethod == null ) throw new SGSException( RC.ENOTFND, string.Format( "Property cannot be set - no Context.ParseVar method exists that supports this type ({0})", propinfo.propType ) ); object[] args = new object[]{ null, ctx.StackItem( valueOnStack ) }; propinfo.parseVarMethod.Invoke( ctx, args ); if( propinfo.info is FieldInfo ) (propinfo.info as FieldInfo).SetValue( this, args[0] ); else // PropertyInfo (propinfo.info as PropertyInfo).SetValue( this, args[0], null ); return true; }
public bool SetSubItem( Variable key, Variable val, bool isprop ) { return ctx.SetIndex( this, key, val, isprop ); }
public Int32 ArrayFind( Variable val ) { return NI.ArrayFind( _sgsEngine.ctx, var, val.var ); }
public Int32 ArrayRemove( Variable val, bool all ) { return NI.ArrayRemove( _sgsEngine.ctx, var, val.var, all ? 1 : 0 ); }