viernes, febrero 18, 2005
Great essay about the current the most known political problem in Mexico
Found a great article about the political situation against Manuel Lopez Obrador, where together the two most important political groups, with the current federal government, try to keep him out of the electionf for president next 2006. The link, at Proceso, here.
viernes, febrero 11, 2005
Problems with the C Mono api
I spent almost a day solving a small problem I had creating structs from the C Mono api. When I returned this instance of struct, an exception was thrown, advising that it was not having a value...
Struct types in Mono are value based types, and since that, they cannot be null. Based in this, I could not figure out the reason for the exception. Then I remembered a similar problem I had when I defined a function, returning a MonoObject * (MonoObject* is the representation of the object C# type), that did not return the correct value (I forgot to add the return statement).
To create an instance in the C api, the class must be passed (a look into mono/samples/embed is a good beginning to begin to understand the C api), which is a MonoClass*. So, with classes you do:
But..., there is the trick for structs (I had to go and read the code of Reflection after a day suffering. Mental note: remember to go to check the code when having a weird error). The trick here, is to unbox the struct before calling the constructor. Structs are allocated as value types, and finishing the stack frame where they were defined (the function itself), they dissapear. Boxing refers to the process of allocating a structure (and anything value based) as a reference type. Unbox is the oposite.
So, we would have this code for structs:
The question here is: structs created from the C Mono api must be created using mono_object_new, which creates boxed structs? The answer is: yes. The runtime can know the times of structs, but, the hacker would not be able to know this, even at compile time.
I hope this helps anybody (in the future, mostly) to avoid this problem.
Struct types in Mono are value based types, and since that, they cannot be null. Based in this, I could not figure out the reason for the exception. Then I remembered a similar problem I had when I defined a function, returning a MonoObject * (MonoObject* is the representation of the object C# type), that did not return the correct value (I forgot to add the return statement).
To create an instance in the C api, the class must be passed (a look into mono/samples/embed is a good beginning to begin to understand the C api), which is a MonoClass*. So, with classes you do:
MonoObject *obj;
...
/* mono_object_new (MonoDomain *d, MonoClass *klass)
* receives as first arg the current domain and a pointer to
* a defined class */
obj = mono_object_new (mono_domain_get (), klass);
/* Constructors must be called (they are common MonoMethod*'s) after the object is
* created; basically, with mono_object_new the object is only allocated.
* Note: mono_runtime_invoke (MonoMethod*, MonoObject*,
* void **params, MonoObject **exception)
*/
mono_runtime_invoke (ctor, obj, params, NULL);
/* Return a fresh instance, with its constructor called */
return obj;
But..., there is the trick for structs (I had to go and read the code of Reflection after a day suffering. Mental note: remember to go to check the code when having a weird error). The trick here, is to unbox the struct before calling the constructor. Structs are allocated as value types, and finishing the stack frame where they were defined (the function itself), they dissapear. Boxing refers to the process of allocating a structure (and anything value based) as a reference type. Unbox is the oposite.
So, we would have this code for structs:
/* First, create the instance, boxed */
obj = mono_object_new (mono_domain_get (), klass);
/* Unbox on a void* variable */
o = mono_object_unbox (obj);
/* Call the method/constructor on the unboxed */
mono_runtime_invoke (ctor, o, params, NULL);
/* But ... return the MonoObject* representation */
return obj;
The question here is: structs created from the C Mono api must be created using mono_object_new, which creates boxed structs? The answer is: yes. The runtime can know the times of structs, but, the hacker would not be able to know this, even at compile time.
I hope this helps anybody (in the future, mostly) to avoid this problem.
viernes, febrero 04, 2005
Latest news
Haven't post recently, mainly because I've been doing some work that is not very fun to be shown here.
Anyway, we are releasing Mono 1.1.4, which is the development version, and we will mark it as stabler than the 1.X series, because of minor number of bugs, better performance, and more features.
Yesterday had chance to met Miguel de Icaza at a conference that took pace at the UNAM, in Mexico city, and finally received my so long-time-wished Mono t-shirt ;-)
Finally, I want to share my my very friends a very delicious and bright idea of my friend Mauricio, who, in a moment of ilumination -both alcoholic and sex ..ehr, I mean, intelectual- reached the maximum state of inteligence, and changed the way I see the world now:
We are ugly man, we are ugly
(We was explaining me the big importance of having charisma with ladies, and how, being that much awful and super mega ultra ugly, just like he himself is, can someone be a 'ladiesman', and refering to both of us when he said that of 'we are ...').
Thanks Maurimal. You have changed the world ;-)
Anyway, we are releasing Mono 1.1.4, which is the development version, and we will mark it as stabler than the 1.X series, because of minor number of bugs, better performance, and more features.
Yesterday had chance to met Miguel de Icaza at a conference that took pace at the UNAM, in Mexico city, and finally received my so long-time-wished Mono t-shirt ;-)
Finally, I want to share my my very friends a very delicious and bright idea of my friend Mauricio, who, in a moment of ilumination -both alcoholic and sex ..ehr, I mean, intelectual- reached the maximum state of inteligence, and changed the way I see the world now:
We are ugly man, we are ugly
(We was explaining me the big importance of having charisma with ladies, and how, being that much awful and super mega ultra ugly, just like he himself is, can someone be a 'ladiesman', and refering to both of us when he said that of 'we are ...').
Thanks Maurimal. You have changed the world ;-)
miércoles, enero 12, 2005
More work on ReflectionOnly apis
I've been keeping working around ReflectionOnly apis. Last week I sent a patch to the list, waiting for Paolo/Zoltan aproval. I didn't receive any answer in the next days; however, I jsut got this from Zoltan:
Most of the code looks ok to me. However, my code review skills are
not very good. Better
wait until Paolo reviews it.
Les Miserables
Today finished the book "Les Miserables", from the hand of Victor Hugo, one of the greatest writers all of times, without any doubt. I have to say that this has been the hardest book I have ever read, and also one of my favorites -with Oscar Wilde's Portrait of Dorian Gray and Alejandro Dumas' Count of Montechrist-.
It is definitely an excellent reference to understand the person as a unit of the society, and to begin to act as good person. Certainly, it is sad, but the reward is huge. A good way to find a hope -and also get a compromise- in this society, in which, at least in Mexico, the sadness and injustice are very common things. The discrimination, implicit or explicit, based on the color of your skin, your eyes, your hair, your economical status, the car you have, and even your beliefs, are examples. Fortunately, I thinkg that we have also persons who belive that the world can be changed for good, and better, they act to make it sure.
The Hobbit
Some days ago I read that David Limon ended the book "The hobbit". Since I read the three last books, I found his description very pleasant, and I want to read it.
Most of the code looks ok to me. However, my code review skills are
not very good. Better
wait until Paolo reviews it.
Les Miserables
Today finished the book "Les Miserables", from the hand of Victor Hugo, one of the greatest writers all of times, without any doubt. I have to say that this has been the hardest book I have ever read, and also one of my favorites -with Oscar Wilde's Portrait of Dorian Gray and Alejandro Dumas' Count of Montechrist-.
It is definitely an excellent reference to understand the person as a unit of the society, and to begin to act as good person. Certainly, it is sad, but the reward is huge. A good way to find a hope -and also get a compromise- in this society, in which, at least in Mexico, the sadness and injustice are very common things. The discrimination, implicit or explicit, based on the color of your skin, your eyes, your hair, your economical status, the car you have, and even your beliefs, are examples. Fortunately, I thinkg that we have also persons who belive that the world can be changed for good, and better, they act to make it sure.
The Hobbit
Some days ago I read that David Limon ended the book "The hobbit". Since I read the three last books, I found his description very pleasant, and I want to read it.
viernes, diciembre 31, 2004
ReflectionOnly apis
Since I want to end this year with a good thing, I will talk about a new mini api contained in the 2.0 version of .Net, called ReflectionOnly. As its title says, this is a group of methods that load assemblies and retrieve the metainformation. The difference with the Load methods, is that the last retrieve information and also prepare the environment to execute code contained withint them (late binding is something that uses this feature).
Since there can be time when it is important to only load the metainformation -based on performance, for example-, ReflectionOnly methods help that.
Probably we will include this in Mono in the next weeks, as long as I finish the methods -currently I have a working Assembly.ReflectionOnlyLoadFrom method- and let them to be reviewed by the jit guys.
Below an example:
Output
Since there can be time when it is important to only load the metainformation -based on performance, for example-, ReflectionOnly methods help that.
Probably we will include this in Mono in the next weeks, as long as I finish the methods -currently I have a working Assembly.ReflectionOnlyLoadFrom method- and let them to be reviewed by the jit guys.
Below an example:
using System;
using System.Reflection;
public class Tester {
static void Main ()
{
Assembly ass1, ass2;
AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoad;
ass1 = Assembly.ReflectionOnlyLoadFrom ("AssemblyRefParent.dll");
ass2 = Assembly.ReflectionOnlyLoadFrom ("AssemblyRefChild.dll");
Type t = ass2.GetType ("Child");
if (t == null) {
Console.WriteLine ("Type Child could not be loaded");
return;
}
Console.WriteLine ("Parent of Child = {0}", t.BaseType.Name);
Console.WriteLine ("ReflectionOnly Assemblies:");
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
Console.WriteLine ("\t{0}, ReflectionOnly = {1}", a.FullName, a.ReflectionOnly);
}
}
static void OnAssemblyLoad (object o, AssemblyLoadEventArgs args)
{
Assembly loaded = args.LoadedAssembly;
Console.WriteLine ("Assembly Loaded = {0}", loaded.FullName);
Console.WriteLine ("Is Reflection Only = {0}\n", loaded.ReflectionOnly);
}
}
Output
Assembly Loaded = AssemblyRefParent, Culture=neutral
Is Reflection Only = True
Assembly Loaded = AssemblyRefChild, Culture=neutral
Is Reflection Only = True
Parent of Child = Parent
ReflectionOnly Assemblies:
AssemblyRefDriver, Culture=neutral, ReflectionOnly = False
mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, ReflectionOnly = False
AssemblyRefChild, Culture=neutral, ReflectionOnly = True
AssemblyRefParent, Culture=neutral, ReflectionOnly = True
jueves, diciembre 30, 2004
My wishes for the next year
This has been a year with good and bad things. But for the next year, I have my purposes and things to do, and also my wishes for the three wise men (as we call him in Mexico).
My wishes are:
And because I could not get my wishes done, I add them to next purposes:
My wishes are:
- Be hired in a *certain* company.
- A laptop (today everybody has a laptop, except me).
And because I could not get my wishes done, I add them to next purposes:
- Work in the new GC engine for Mono
- Move to a different city (Boston or Frankfurt would be ok ;-) )
- Finish a novel in which I'm working on (an be a good one, I don't want to be one of the so many geeks that _try_ to be good writers)
sábado, diciembre 18, 2004
Great article about the Mexico gov
Today I found a very interesting article (in Spanish) about the mexican governmentm, and the reasons that show that we have to improve tons of things.
Unfortunately, as I have mentioned earlier, in Mexico it is more difficult to deliver this kind of information to the people, because of the government managed news, because of the paid political magazines, and because the people here in Mexico is used to believe everything shown in TV.
Currently I just can say that I see in Manuel Lopez Obrador the best choice for president in next 2006 elections, against the bad options that the two other main political groups could offer us.
The link here.
Unfortunately, as I have mentioned earlier, in Mexico it is more difficult to deliver this kind of information to the people, because of the government managed news, because of the paid political magazines, and because the people here in Mexico is used to believe everything shown in TV.
Currently I just can say that I see in Manuel Lopez Obrador the best choice for president in next 2006 elections, against the bad options that the two other main political groups could offer us.
The link here.
Suscribirse a:
Entradas (Atom)