Skip to content

Commit

Permalink
fix everything so we build again
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Feb 7, 2011
1 parent 060ae04 commit bbd7d5c
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion ParrotSharp.sln
Expand Up @@ -21,7 +21,7 @@ Global
{F90A2E1A-B062-4BFC-B4FF-7E09A2CB73F0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = ParrotSharp.csproj
StartupItem = ParrotSharpTest\ParrotSharpTest.csproj
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 3 additions & 3 deletions ParrotSharpTest/PMC_Test.cs
Expand Up @@ -13,7 +13,7 @@ public class PMC_Test {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(Parrot_Test.ParentInterpreter, exename);

Parrot_PMC box = "This is a parrot string".ToParrotStringPMC(parrot);
IParrot_PMC box = "This is a parrot string".ToParrotStringPMC(parrot);
Assert.AreEqual("This is a parrot string", box.ToString(), "Can't box string into a PMC");
}

Expand All @@ -22,7 +22,7 @@ public class PMC_Test {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(Parrot_Test.ParentInterpreter, exename);

Parrot_PMC pmc_string = "This is a parrot string".ToParrotStringPMC(parrot);
IParrot_PMC pmc_string = "This is a parrot string".ToParrotStringPMC(parrot);
IPMCFactory<CallContext> sign_factory = CallContext.GetFactory(parrot);
CallContext sign = sign_factory.Instance();
sign.Signature = "PiSS->".ToParrotString(parrot);
Expand All @@ -40,7 +40,7 @@ public class PMC_Test {
string exename = AppDomain.CurrentDomain.FriendlyName;
Parrot parrot = new Parrot(Parrot_Test.ParentInterpreter, exename);

Parrot_PMC pmc_string = "This is a parrot string".ToParrotStringPMC(parrot);
IParrot_PMC pmc_string = "This is a parrot string".ToParrotStringPMC(parrot);
IPMCFactory<CallContext> sign_factory = CallContext.GetFactory(parrot);
CallContext sign = sign_factory.Instance();
sign.Signature = "Pi->".ToParrotString(parrot);
Expand Down
3 changes: 2 additions & 1 deletion src/IParrot_PMC.cs
Expand Up @@ -3,9 +3,10 @@ namespace ParrotSharp
{
public interface IParrot_PMC
{
Parrot_String GetParrotString();
Parrot Parrot { get; }
IntPtr RawPointer { get; }
Parrot_PMC FindMethod(string name);
void InvokeMethod(Parrot_String name, Pmc.CallContext signature);
}
}

16 changes: 10 additions & 6 deletions src/Parrot_PMC.cs
Expand Up @@ -21,10 +21,11 @@ public class Parrot_PMC : ParrotPointer, IParrot_PMC

public override string ToString()
{
return this.GetParrotString().ToString();
return this.ParrotStringValue.ToString();
}

protected Parrot_String ParrotStringValue {
protected Parrot_String ParrotStringValue
{
get {
IntPtr value_ptr = IntPtr.Zero;
int result = Parrot_api_pmc_get_string(this.Parrot.RawPointer, this.RawPointer, out value_ptr);
Expand Down Expand Up @@ -62,7 +63,8 @@ public Parrot_PMC FindMethod(string name)
private static extern int Parrot_api_pmc_find_method(IntPtr interp_pmc, IntPtr pmc_obj, IntPtr ps_name, out IntPtr method);

//TODO add a better way to modify the signature
public void InvokeMethod(Parrot_String name, Pmc.CallContext signature) {
public void InvokeMethod(Parrot_String name, Pmc.CallContext signature)
{
IntPtr sub_ptr;
int result = Parrot_api_pmc_find_method(this.Parrot.RawPointer, this.RawPointer, name.RawPointer, out sub_ptr);
if (result != 1) {
Expand All @@ -85,17 +87,17 @@ public Parrot_PMC FindMethod(string name)
[DllImport("parrot")]
private static extern int Parrot_api_pmc_set_keyed_int(IntPtr interp, IntPtr pmc, int key, IntPtr value);

protected Parrot_PMC this[int key]
protected IntPtr this[int key]
{
get {
IntPtr value_ptr = IntPtr.Zero;
int result = Parrot_api_pmc_get_keyed_int(this.Parrot.RawPointer, this.RawPointer, key, out value_ptr);
if (result != 1)
this.Parrot.GetErrorResult();
return new Parrot_PMC(this.Parrot, value_ptr);
return value_ptr;
}
set {
int result = Parrot_api_pmc_set_keyed_int(this.Parrot.RawPointer, this.RawPointer, key, value.RawPointer);
int result = Parrot_api_pmc_set_keyed_int(this.Parrot.RawPointer, this.RawPointer, key, value);
if (result != 1)
this.Parrot.GetErrorResult();
}
Expand Down Expand Up @@ -133,6 +135,8 @@ public Parrot_PMC FindMethod(string name)
set { this[key.ToParrotString(this.Parrot)] = value; }
}

#endregion

#region PMC-Keyed Indexing

[DllImport("parrot")]
Expand Down
14 changes: 7 additions & 7 deletions src/Pmc/CallSignature.cs
Expand Up @@ -27,25 +27,25 @@ public static IPMCFactory<CallContext> GetFactory(Parrot parrot)

#region Get/Set Parameters

public IParrot_PMC this[int key]
public new IParrot_PMC this[int key]
{
get { return new Parrot_PMC(this.Parrot, base[key]); }
set { base[key] = value.RawPointer; }
}

public IParrot_PMC this[string key]
public new IParrot_PMC this[string key]
{
get { return new Parrot_PMC(this.Parrot, base[key]); }
set { base[key] = value.RawPointer; }
}

public IParrot_PMC this[Parrot_String key]
public new IParrot_PMC this[Parrot_String key]
{
get { return new Parrot_PMC(this.RawPointer, base[key]); }
get { return new Parrot_PMC(this.Parrot, base[key]); }
set { base[key] = value.RawPointer; }
}

public void AddArgument(Parrot_PMC arg)
public void AddArgument(IParrot_PMC arg)
{
this[ArgNum] = arg;
ArgNum++;
Expand All @@ -57,8 +57,8 @@ public void AddArgument(Parrot_PMC arg)

public Parrot_String Signature
{
get { return StringValue; }
set { StringValue = value; }
get { return ParrotStringValue; }
set { ParrotStringValue = value; }
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion src/Pmc/Class.cs
Expand Up @@ -15,7 +15,7 @@ public class Class : Parrot_PMC, IParrot_PMC
[DllImport("parrot")]
private static extern int Parrot_api_pmc_get_class(IntPtr interp, IntPtr key, out IntPtr class_pmc);

public static Class GetClassPMC(Parrot parrot, Parrot_PMC key)
public static Class GetClassPMC(Parrot parrot, IParrot_PMC key)
{
IntPtr class_ptr = IntPtr.Zero;
int result = Parrot_api_pmc_get_class(parrot.RawPointer, key.RawPointer, out class_ptr);
Expand Down
2 changes: 1 addition & 1 deletion src/Pmc/IPMCFactory.cs
Expand Up @@ -5,7 +5,7 @@ namespace ParrotSharp
public interface IPMCFactory<TPmc> where TPmc : class, IParrot_PMC
{
TPmc Instance();
TPmc SpecifyType(Parrot_PMC pmc);
TPmc Instance(Parrot_PMC pmc);
}
}

2 changes: 1 addition & 1 deletion src/Pmc/PMCFactory.cs
Expand Up @@ -15,7 +15,7 @@ public class PMCFactory<TPmc> : IPMCFactory<TPmc> where TPmc : class, IParrot_PM
public PMCFactory (Parrot parrot, string key)
{
this.parrot = parrot;
this.pmc_class = Pmc.Class.GetClassPMC(parrot, key.ToParrotStringPMC(parrot));
this.pmc_class = Pmc.Class.GetClassPMC(this.parrot, key.ToParrotStringPMC(parrot));
}

public PMCFactory (Parrot parrot, string[] key)
Expand Down
5 changes: 3 additions & 2 deletions src/Pmc/String.cs
Expand Up @@ -41,13 +41,14 @@ public static IPMCFactory<String> GetFactory(Parrot parrot)

public IParrot_PMC ToIntegerPMC(int int_base)
{
CallContext cc = CallContext.GetFactory(this.parrot);
CallContext cc = CallContext.GetFactory(this.Parrot).Instance();
cc[0] = this;
cc[1] = int_base.ToParrotIntegerPMC(this.Parrot);
cc.SetParrotString("PiI->P");
cc.Signature = "PiI->P".ToParrotString(this.Parrot);
// TODO: get the method
// TODO: Invoke it
// TODO: get the returns
return null;
}

#endregion
Expand Down

0 comments on commit bbd7d5c

Please sign in to comment.