Exemplo n.º 1
0
 public void EmitRemoteEvent(CodeBuilder b, CommentData comments)
 {
     b.AppendSummaryAndRemarks(comments, true, true);
     b.BeginBlock("public event {0} {1}", RemoteEventHandlerName, CSharp.Escape(PublicName));
     b.BeginBlock("add");
     b.BeginBlock("if(m_{0} == null)", PublicName);
     b.AppendLine("var call = new {0}ActivateRenderProcessCall();", EventName);
     b.AppendLine("call.sender = proxyId;");
     b.AppendLine("call.RequestExecution(this);");
     b.EndBlock();
     b.AppendLine("m_{0} += value;", PublicName);
     b.EndBlock();
     b.BeginBlock("remove");
     b.AppendLine("m_{0} -= value;", PublicName);
     b.BeginBlock("if(m_{0} == null)", PublicName);
     b.AppendLine("var call = new {0}DeactivateRenderProcessCall();", EventName);
     b.AppendLine("call.sender = proxyId;");
     b.AppendLine("call.RequestExecution(this);");
     b.EndBlock();
     b.EndBlock();
     b.EndBlock();
     b.AppendLine();
     b.AppendLine("{0} m_{1};", RemoteEventHandlerName, PublicName);
     b.AppendLine();
 }
    public override void EmitRemoteClass(CodeBuilder b)
    {
        b.AppendLine();

        b.AppendSummaryAndRemarks(Comments, true, Category == StructCategory.Client);
        b.BeginClass(RemoteClassName + " : CfrStructure", GeneratorConfig.ClassModifiers(RemoteClassName, "public sealed"));
        b.AppendLine();

        if (NeedsWrapFunction)
        {
            b.BeginFunction("Wrap", RemoteClassName, "RemotePtr remotePtr", "internal static");
            b.AppendLine("if(remotePtr == RemotePtr.Zero) return null;");
            b.AppendLine("var weakCache = CfxRemoteCallContext.CurrentContext.connection.weakCache;");
            b.AppendLine("return ({0})weakCache.GetOrAdd(remotePtr.ptr, () => new {0}(remotePtr));", RemoteClassName);
            b.EndBlock();
            b.AppendLine();
            b.AppendLine();
        }

        b.AppendLine("private {0}(RemotePtr remotePtr) : base(remotePtr) {{}}", RemoteClassName);
        b.AppendLine("public {0}() : base(new {1}CtorRemoteCall(), new {1}DtorRemoteCall()) {{}}", RemoteClassName, ClassName);

        foreach (var sm in StructMembers)
        {
            b.AppendLine();
            b.AppendLine("{0} m_{1};", sm.MemberType.RemoteSymbol, sm.PublicName);
            b.AppendLine("bool m_{0}_fetched;", sm.PublicName);
            b.AppendLine();

            b.AppendSummaryAndRemarks(sm.Comments, true);
            b.BeginBlock("public {1} {0}", CSharp.Escape(sm.PublicName), sm.MemberType.RemoteSymbol);
            b.BeginBlock("get");
            b.BeginIf("!m_{0}_fetched", sm.PublicName);
            b.AppendLine("var call = new {0}Get{1}RemoteCall();", ClassName, sm.PublicName);
            b.AppendLine("call.sender = RemotePtr.ptr;");
            b.AppendLine("call.RequestExecution(RemotePtr.connection);");
            b.AppendLine("m_{0} = {1};", sm.PublicName, sm.MemberType.RemoteWrapExpression("call.value"));
            b.AppendLine("m_{0}_fetched = true;", sm.PublicName);
            b.EndBlock();
            b.AppendLine("return m_{0};", sm.PublicName);
            b.EndBlock();
            b.BeginBlock("set");
            b.AppendLine("var call = new {0}Set{1}RemoteCall();", ClassName, sm.PublicName);
            b.AppendLine("call.sender = RemotePtr.ptr;");
            b.AppendLine("call.value = {0};", sm.MemberType.RemoteUnwrapExpression("value"));
            b.AppendLine("call.RequestExecution(RemotePtr.connection);");
            b.AppendLine("m_{0} = value;", sm.PublicName);
            b.AppendLine("m_{0}_fetched = true;", sm.PublicName);
            b.EndBlock();
            b.EndBlock();
        }

        b.EndBlock();
    }
Exemplo n.º 3
0
    private void EmitPublicEvent(CodeBuilder b, int cbIndex, CefCallbackFunction cb)
    {
        var isSimpleGetterEvent = cb.Signature.ManagedParameters.Length == 1 &&
                                  cb.Signature.ReturnType.IsCefStructPtrType;

        b.AppendSummaryAndRemarks(cb.Comments, false, true);
        b.BeginBlock("public event {0} {1}", cb.EventHandlerName, CSharp.Escape(cb.PublicName));
        b.BeginBlock("add");
        b.BeginBlock("lock(eventLock)");
        if (isSimpleGetterEvent)
        {
            b.BeginBlock("if(m_{0} != null)", cb.PublicName);
            b.AppendLine("throw new CfxException(\"Can't add more than one event handler to this type of event.\");");
            b.EndBlock();
        }
        else
        {
            b.BeginBlock("if(m_{0} == null)", cb.PublicName);
        }
        b.AppendLine("CfxApi.{3}.{0}_set_callback(NativePtr, {1}, {2}_native_ptr);", CefStruct.CfxName, cbIndex, cb.Name, CefStruct.ClassName.Substring(3));
        if (!isSimpleGetterEvent)
        {
            b.EndBlock();
        }
        b.AppendLine("m_{0} += value;", cb.PublicName);
        b.EndBlock();
        b.EndBlock();
        b.BeginBlock("remove");
        b.BeginBlock("lock(eventLock)");
        b.AppendLine("m_{0} -= value;", cb.PublicName);
        b.BeginBlock("if(m_{0} == null)", cb.PublicName);
        b.AppendLine("CfxApi.{2}.{0}_set_callback(NativePtr, {1}, IntPtr.Zero);", CefStruct.CfxName, cbIndex, CefStruct.ClassName.Substring(3));
        b.EndBlock();
        b.EndBlock();
        b.EndBlock();
        b.EndBlock();
        b.AppendLine();

        if (isSimpleGetterEvent)
        {
            b.AppendLine("/// <summary>");
            b.AppendLine("/// Retrieves the {0} provided by the event handler attached to the {1} event, if any.", cb.Signature.ReturnType.PublicSymbol, CSharp.Escape(cb.PublicName));
            b.AppendLine("/// Returns null if no event handler is attached.");
            b.AppendLine("/// </summary>");
            b.BeginBlock("public {0} Retrieve{1}()", cb.Signature.ReturnType.PublicSymbol, cb.Signature.ReturnType.PublicSymbol.Substring(3));
            b.AppendLine("var h = m_{0};", cb.PublicName);
            b.BeginIf("h != null");
            b.AppendLine("var e = new {0}();", cb.PublicEventArgsClassName);
            b.AppendLine("h(this, e);");
            b.AppendLine("return e.m_returnValue;");
            b.BeginElse();
            b.AppendLine("return null;");
            b.EndBlock();
            b.EndBlock();
            b.AppendLine();
        }

        b.AppendLine("private {0} m_{1};", cb.EventHandlerName, cb.PublicName);
    }
 public override void EmitPostNativeCallbackStatements(CodeBuilder b, string var)
 {
     if (Struct.IsRefCounted)
     {
         b.BeginBlock("if({0}_release)", var);
         b.BeginBlock("for(size_t i = 0; i < {0}; ++i)", CountArg.VarName);
         b.AppendLine("{0}[i]->base.release((cef_base_ref_counted_t*){0}[i]);", var);
         b.EndBlock();
         b.EndBlock();
     }
 }
Exemplo n.º 5
0
 public override void EmitPreNativeCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0} *{1}_tmp = ({0}*)malloc({2} * sizeof({0}));", Struct.OriginalSymbol, var, CountArg.VarName);
     b.BeginBlock("if({0}_tmp)", var);
     b.BeginBlock("for(size_t i = 0; i < {0}; ++i)", CountArg.VarName);
     b.AppendLine("{0}_tmp[i] = *{0}[i];", var);
     b.EndBlock();
     b.AppendLine("*{0}_nomem = 0;", var);
     b.BeginElse();
     b.AppendLine("{0} = 0;", CountArg.VarName);
     b.AppendLine("*{0}_nomem = 1;", var);
     b.EndBlock();
 }
Exemplo n.º 6
0
 public void EmitPublicEvent(CodeBuilder b, int cbIndex, CommentData comments)
 {
     b.AppendSummaryAndRemarks(comments, false, true);
     b.BeginBlock("public event {0} {1}", EventHandlerName, CSharp.Escape(PublicName));
     b.BeginBlock("add");
     b.BeginBlock("lock(eventLock)");
     b.BeginBlock("if(m_{0} == null)", PublicName);
     b.BeginBlock("if({0}_{1} == null)", Parent.CfxName, Name);
     b.AppendLine("{0}_{1} = {1};", Parent.CfxName, Name);
     b.AppendLine("{0}_{1}_ptr = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate({0}_{1});", Parent.CfxName, Name);
     b.EndBlock();
     b.AppendLine("CfxApi.{0}_set_managed_callback(NativePtr, {1}, {0}_{2}_ptr);", Parent.CfxName, cbIndex, Name);
     b.EndBlock();
     b.AppendLine("m_{0} += value;", PublicName);
     b.EndBlock();
     b.EndBlock();
     b.BeginBlock("remove");
     b.BeginBlock("lock(eventLock)");
     b.AppendLine("m_{0} -= value;", PublicName);
     b.BeginBlock("if(m_{0} == null)", PublicName);
     b.AppendLine("CfxApi.{0}_set_managed_callback(NativePtr, {1}, IntPtr.Zero);", Parent.CfxName, cbIndex);
     b.EndBlock();
     b.EndBlock();
     b.EndBlock();
     b.EndBlock();
     b.AppendLine();
     b.AppendLine("private {0} m_{1};", EventHandlerName, PublicName);
 }
Exemplo n.º 7
0
 public override void EmitPostPublicCallStatements(CodeBuilder b, string var)
 {
     base.EmitPostPublicCallStatements(b, var);
     b.BeginBlock("if({0}_nomem != 0)", var);
     b.AppendLine("throw new OutOfMemoryException();");
     b.EndBlock();
 }
Exemplo n.º 8
0
 public override void EmitNativeValueStructDtorStatements(CodeBuilder b, string var)
 {
     b.BeginBlock("if(self->{0})", var);
     b.AppendLine("{0}_clear(self->{1});", Name, var);
     b.AppendLine("{0}_free(self->{1});", Name, var);
     b.EndBlock();
 }
Exemplo n.º 9
0
        public static string GenerateThriftSpec(Type type, List <string> dependentSpecFiles)
        {
            var builder = new CodeBuilder();

            /*
             * foreach (var s in dependentSpecFiles)
             * {
             *  builder.AppendLine("include \"" + s + "\"");
             * }
             */

            builder.AppendLine();
            builder.AppendLine("namespace csharp " + type.Namespace);
            builder.AppendLine("namespace cpp " + type.Namespace);
            builder.AppendLine();


            builder.AppendLine("service " + type.Name);
            builder.BeginBlock();

            foreach (var m in GetServiceCalls(type))
            {
                var return_value_type = m.ReturnType.GetGenericArguments()[0];
                var parameter_type    = m.GetParameters()[0].ParameterType.GetGenericArguments()[0];
                var return_value_name = GetThriftTypeName(return_value_type);
                var parameter_name    = GetThriftTypeName(parameter_type);
                builder.AppendLine(return_value_name + " " + m.Name + "(1: " + parameter_name + " req);");
            }

            builder.EndBlock();
            builder.AppendLine();

            return(builder.ToString());
        }
        public void CodeGen(CodeBuilder builder)
        {
            if (Summary != null)
            {
                builder.AppendSummary(Summary);
            }

            Visibility.CodeGen(builder);

            if (ReturnType != null)
            {
                ReturnType.CodeGen(builder);
            }
            else
            {
                builder.AppendToken("void");
            }

            builder.AppendToken(Name);
            builder.ForceNoWhitespace();

            builder.AppendToken("()");
            builder.BeginBlock();

            Body.CodeGen(builder);

            builder.EndBlock();
        }
Exemplo n.º 11
0
 protected void EmitRemoteClassWrapperFunction(CodeBuilder b)
 {
     b.BeginFunction("Wrap", RemoteClassName, "RemotePtr remotePtr", "internal static");
     b.AppendLine("if(remotePtr == RemotePtr.Zero) return null;");
     b.AppendLine("var weakCache = CfxRemoteCallContext.CurrentContext.connection.weakCache;");
     b.BeginBlock("lock(weakCache)");
     b.AppendLine("var cfrObj = ({0})weakCache.Get(remotePtr.ptr);", RemoteClassName);
     b.BeginBlock("if(cfrObj == null)");
     b.AppendLine("cfrObj = new {0}(remotePtr);", RemoteClassName);
     b.AppendLine("weakCache.Add(remotePtr.ptr, cfrObj);");
     b.EndBlock();
     b.AppendLine("return cfrObj;");
     b.EndBlock();
     b.EndBlock();
     b.AppendLine();
     b.AppendLine();
 }
Exemplo n.º 12
0
 public override void EmitPostNativeCallbackStatements(CodeBuilder b, string var)
 {
     b.BeginBlock("if({0}_tmp_str != {0}->str)", var);
     b.AppendLine("if({0}->dtor) {0}->dtor({0}->str);", var);
     b.AppendLine("cef_string_set({0}_tmp_str, {0}_tmp_length, {0}, 1);", var);
     b.AppendLine("cfx_gc_handle_free((gc_handle_t){0}_tmp_str);", var);
     b.EndBlock();
 }
Exemplo n.º 13
0
 public override void EmitPreNativeCallStatements(CodeBuilder b, string var)
 {
     b.BeginIf("{0}", CountArg.VarName);
     b.BeginBlock("for(size_t i = 0; i < {0}; ++i)", CountArg.VarName);
     b.AppendLine("if({0}[i]) ((cef_base_t*){0}[i])->add_ref((cef_base_t*){0}[i]);", StructArg.VarName);
     b.EndBlock();
     b.EndBlock();
 }
Exemplo n.º 14
0
 public override void EmitRemoteEventArgGetterStatements(CodeBuilder b, string var)
 {
     b.BeginBlock("if(!m_{0}_fetched)", var);
     b.AppendLine("m_{0} = call.{0}_str == IntPtr.Zero ? null : (call.{0}_length == 0 ? String.Empty : CfrRuntime.Marshal.PtrToStringUni(new RemotePtr(call.{0}_str), call.{0}_length));", var);
     b.AppendLine("m_{0}_fetched = true;", var);
     b.EndBlock();
     b.AppendLine("return m_{0};", var);
 }
 public override void EmitPublicCall(CodeBuilder b)
 {
     b.AppendLine("var rangesCount = CfxApi.PrintSettings.cfx_print_settings_get_page_ranges_count(NativePtr);");
     b.AppendLine("IntPtr[] pp = new IntPtr[(ulong)rangesCount];");
     b.AppendLine("PinnedObject pp_pinned = new PinnedObject(pp);");
     b.AppendLine("int ranges_nomem;");
     b.AppendLine("CfxApi.PrintSettings.cfx_print_settings_get_page_ranges(NativePtr, ref rangesCount, pp_pinned.PinnedPtr, out ranges_nomem);");
     b.AppendLine("pp_pinned.Free();");
     b.BeginBlock("if(ranges_nomem != 0)");
     b.AppendLine("throw new OutOfMemoryException();");
     b.EndBlock();
     b.AppendLine("var retval = new CfxRange[(ulong)rangesCount];");
     b.BeginBlock("for(ulong i = 0; i < (ulong)rangesCount; ++i)");
     b.AppendLine("retval[i] = CfxRange.WrapOwned(pp[i]);");
     b.EndBlock();
     b.AppendLine("return retval;");
 }
Exemplo n.º 16
0
 public override void EmitPostPublicRaiseEventStatements(CodeBuilder b, string var)
 {
     b.BeginIf("e.m_{0}_managed == null", var);
     b.BeginBlock("for(int i = 0; i < {1}; ++i)", var, CountArg.VarName);
     b.AppendLine("CfxApi.cfx_release(e.m_{0}[i]);", var);
     b.EndBlock();
     b.EndBlock();
 }
Exemplo n.º 17
0
        public string BuildRdsn(Type service, QueryContext[] contexts)
        {
            //_stages = stages;
            _contexts     = contexts;
            _appClassName = service.Name;

            //BuildInputOutputValueTypes();
            BuildHeaderRdsn(service.Namespace);
            BuildRewrittenTypes();
            _builder.AppendLine("public class " + _appClassName + "Server_impl :" + _appClassName + "Server");
            _builder.BeginBlock();
            BuildServiceClientsRdsn();
            //thrift or protobuf
            BuildServiceCallsRdsn(_appClassName);
            foreach (var c in contexts)
            {
                //never change
                BuildQueryRdsn(c);
            }

            //always thrift
            BuildServer(_appClassName, ServiceContract.GetServiceCalls(service));

            _builder.EndBlock();

            BuildMain();
            BuildFooter();
            return(_builder.ToString());
        }
Exemplo n.º 18
0
    public override void EmitRemoteClass(CodeBuilder b)
    {
        b.AppendLine();

        b.AppendSummaryAndRemarks(Comments, true, Category == StructCategory.ApiCallbacks);
        b.BeginClass(RemoteClassName + " : CfrStructure", GeneratorConfig.ClassModifiers(RemoteClassName, "public sealed"));
        b.AppendLine();

        EmitRemoteClassWrapperFunction(b);

        b.AppendLine("private {0}(RemotePtr remotePtr) : base(remotePtr) {{}}", RemoteClassName);
        b.AppendLine("public {0}() : base(new {1}CtorRemoteCall(), new {1}DtorRemoteCall()) {{}}", RemoteClassName, ClassName);

        foreach (var sm in StructMembers)
        {
            b.AppendLine();
            b.AppendLine("{0} m_{1};", sm.MemberType.RemoteSymbol, sm.PublicName);
            b.AppendLine("bool m_{0}_fetched;", sm.PublicName);
            b.AppendLine();

            b.AppendSummaryAndRemarks(sm.Comments, true);
            b.BeginBlock("public {1} {0}", CSharp.Escape(sm.PublicName), sm.MemberType.RemoteSymbol);
            b.BeginBlock("get");
            b.BeginIf("!m_{0}_fetched", sm.PublicName);
            b.AppendLine("var call = new {0}Get{1}RemoteCall();", ClassName, sm.PublicName);
            b.AppendLine("call.sender = RemotePtr.ptr;");
            b.AppendLine("call.RequestExecution(RemotePtr.connection);");
            b.AppendLine("m_{0} = {1};", sm.PublicName, sm.MemberType.RemoteWrapExpression("call.value"));
            b.AppendLine("m_{0}_fetched = true;", sm.PublicName);
            b.EndBlock();
            b.AppendLine("return m_{0};", sm.PublicName);
            b.EndBlock();
            b.BeginBlock("set");
            b.AppendLine("var call = new {0}Set{1}RemoteCall();", ClassName, sm.PublicName);
            b.AppendLine("call.sender = RemotePtr.ptr;");
            b.AppendLine("call.value = {0};", sm.MemberType.RemoteUnwrapExpression("value"));
            b.AppendLine("call.RequestExecution(RemotePtr.connection);");
            b.AppendLine("m_{0} = value;", sm.PublicName);
            b.AppendLine("m_{0}_fetched = true;", sm.PublicName);
            b.EndBlock();
            b.EndBlock();
        }

        b.EndBlock();
    }
Exemplo n.º 19
0
 public override void EmitPreRemoteCallStatements(CodeBuilder b, string var)
 {
     b.BeginIf("{0} != null", var);
     b.AppendLine("call.{0} = new IntPtr[{0}.Length];", var);
     b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var);
     b.AppendLine("call.{0}[i] = {1};", var, StructPtr.RemoteUnwrapExpression(var + "[i]"));
     b.EndBlock();
     b.EndBlock();
 }
    public override void EmitRemoteCalls(CodeBuilder b, List <string> callIds)
    {
        b.AppendLine();

        b.BeginRemoteCallClass(ClassName, callIds, "CtorRemoteCall");
        b.AppendLine();
        b.BeginBlock("protected override void RemoteProcedure()");
        b.AppendLine("__retval = CfxApi.{0}.{1}_ctor();", ApiClassName, CfxName);
        b.EndBlock();
        b.EndBlock();
        b.AppendLine();

        b.BeginRemoteCallClass(ClassName, callIds, "DtorRemoteCall");
        b.AppendLine();
        b.BeginBlock("protected override void RemoteProcedure()");
        b.AppendLine("CfxApi.{0}.{1}_dtor(nativePtr);", ApiClassName, CfxName);
        b.EndBlock();
        b.EndBlock();
        b.AppendLine();

        foreach (var sm in StructMembers)
        {
            b.BeginRemoteCallClass(ClassName + "Get" + sm.PublicName, callIds);
            b.AppendLine("internal IntPtr sender;");
            b.AppendLine("internal {0} value;", sm.MemberType.PInvokeSymbol);
            b.AppendLine("protected override void WriteArgs(StreamHandler h) { h.Write(sender); }");
            b.AppendLine("protected override void ReadArgs(StreamHandler h) { h.Read(out sender); }");
            b.AppendLine("protected override void WriteReturn(StreamHandler h) { h.Write(value); }");
            b.AppendLine("protected override void ReadReturn(StreamHandler h) { h.Read(out value); }");
            b.BeginBlock("protected override void RemoteProcedure()");
            b.AppendLine("CfxApi.{0}.{1}_get_{2}(sender, out value);", ApiClassName, CfxName, sm.Name);
            b.EndBlock();
            b.EndBlock();
            b.BeginRemoteCallClass(ClassName + "Set" + sm.PublicName, callIds);
            b.AppendLine("internal IntPtr sender;");
            b.AppendLine("internal {0} value;", sm.MemberType.PInvokeSymbol);
            b.AppendLine("protected override void WriteArgs(StreamHandler h) { h.Write(sender); h.Write(value); }");
            b.AppendLine("protected override void ReadArgs(StreamHandler h) { h.Read(out sender); h.Read(out value); }");
            b.BeginBlock("protected override void RemoteProcedure()");
            b.AppendLine("CfxApi.{0}.{1}_set_{2}(sender, value);", ApiClassName, CfxName, sm.Name);
            b.EndBlock();
            b.EndBlock();
        }
    }
 public override void EmitRemotePreCallStatements(CodeBuilder b, string var)
 {
     b.BeginIf("{0} != null", var);
     b.AppendLine("call.{0} = new IntPtr[{0}.Length];", var);
     b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var);
     b.AppendLine("if(!CheckConnection({0}[i], connection)) throw new ArgumentException(\"Render process connection mismatch.\", \"{1}[\" + i + \"]\");", CSharp.Escape(var), var);
     b.AppendLine("call.{0}[i] = {1};", var, StructPtr.RemoteUnwrapExpression(var + "[i]"));
     b.EndBlock();
     b.EndBlock();
 }
 public override void EmitPublicEventArgGetterStatements(CodeBuilder b, string var)
 {
     b.BeginIf("m_{0}_managed == null", var);
     b.AppendLine("m_{0}_managed = new {1}[m_{0}.Length];", var, Struct.ClassName);
     b.BeginBlock("for(int i = 0; i < m_{0}.Length; ++i)", var);
     b.AppendLine("m_{0}_managed[i] = {1}.Wrap(m_{0}[i]);", var, Struct.ClassName);
     b.EndBlock();
     b.EndBlock();
     b.AppendLine("return m_{0}_managed;", var);
 }
Exemplo n.º 23
0
 public void EmitRemoteRaiseEventFunction(CodeBuilder b, CommentData comments)
 {
     b.BeginBlock("internal void raise_{0}(object sender, {1} e)", PublicName, RemoteEventArgsClassName);
     b.AppendLine("var handler = m_{0};", PublicName);
     b.AppendLine("if(handler == null) return;");
     b.AppendLine("handler(this, e);");
     b.AppendLine("e.m_isInvalid = true;");
     b.EndBlock();
     b.AppendLine();
 }
Exemplo n.º 24
0
 public override void EmitPreProxyCallStatements(CodeBuilder b, string var)
 {
     b.AppendLine("{0}[] {1}_unwrapped;", Struct.ClassName, var);
     b.BeginIf("{0} != null", var);
     b.AppendLine("{0}_unwrapped = new {1}[{0}.Length];", var, Struct.ClassName);
     b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var);
     b.AppendLine("{0}_unwrapped[i] = {1};", var, StructPtr.ProxyUnwrapExpression(var + "[i]"));
     b.EndBlock();
     b.BeginElse();
     b.AppendLine("{0}_unwrapped = null;", var);
     b.EndBlock();
 }
Exemplo n.º 25
0
 public override void EmitRemoteEventArgGetterStatements(CodeBuilder b, string var)
 {
     b.BeginIf("m_{0}_managed == null", var);
     b.AppendLine("m_{0}_managed = new {1}[({2})m_{3}];", var, Struct.RemoteClassName, CountArg.ArgumentType.PublicSymbol, CountArg.VarName);
     b.AppendLine("var currentPtr = m_{0};", var);
     b.BeginBlock("for({0} i = 0; i < ({0})m_{1}; ++i)", CountArg.ArgumentType.PublicSymbol, CountArg.VarName);
     b.AppendLine("m_{0}_managed[i] = {1}.Wrap(currentPtr);", var, Struct.ClassName);
     b.AppendLine("currentPtr += m_{0}_structsize;", var);
     b.EndBlock();
     b.EndBlock();
     b.AppendLine("return m_{0}_managed;", var);
 }
 public override void EmitRemoteEventArgGetterStatements(CodeBuilder b, string var)
 {
     b.BeginIf("m_{0}_managed == null", var);
     b.AppendLine("var {0} = new RemotePtr[(ulong)call.{1}];", var, CountArg.VarName);
     b.AppendLine("m_{0}_managed = new {1}[{0}.Length];", var, Struct.RemoteClassName);
     b.BeginIf("{0}.Length > 0", var);
     b.AppendLine("CfrRuntime.Marshal.Copy(new RemotePtr(connection, call.{0}), {0}, 0, {0}.Length);", var);
     b.BeginBlock("for(int i = 0; i < {0}.Length; ++i)", var);
     b.AppendLine("m_{0}_managed[i] = {1}.Wrap({0}[i]);", var, Struct.RemoteClassName);
     b.EndBlock();
     b.EndBlock();
     b.EndBlock();
     b.AppendLine("return m_{0}_managed;", var);
 }
Exemplo n.º 27
0
    public void EmitApiClass(CodeBuilder b)
    {
        b.BeginClass(ClassName.Substring(3), "internal static");
        b.AppendLine();

        b.BeginBlock("static {0} ()", ApiClassName);
        b.AppendLine("CfxApiLoader.Load{0}Api();", ClassName);
        b.EndBlock();
        b.AppendLine();

        EmitApiDeclarations(b);

        b.EndBlock();
    }
 public override void EmitNativeCall(CodeBuilder b, string functionName)
 {
     b.AppendLine("cef_range_t *ranges_tmp = (cef_range_t*)malloc(*rangesCount * sizeof(cef_range_t));");
     b.BeginIf("ranges_tmp");
     b.AppendLine("*ranges_nomem = 0;");
     b.AppendLine("self->get_page_ranges(self, rangesCount, ranges_tmp);");
     b.BeginBlock("for(size_t i = 0; i < *rangesCount; ++i)");
     b.AppendLine("ranges[i] = (cef_range_t*)malloc(sizeof(cef_range_t));");
     b.AppendLine("*ranges[i] = ranges_tmp[i];");
     b.EndBlock();
     b.AppendLine("free(ranges_tmp);");
     b.BeginElse();
     b.AppendLine("*ranges_nomem = 1;");
     b.EndBlock();
 }
Exemplo n.º 29
0
    private void EmitPublicProperty(CodeBuilder b, StructProperty p)
    {
        var propertyName = p.Getter.PublicName;

        if (p.Getter.Name.StartsWith("get_"))
        {
            propertyName = propertyName.Substring(3);
        }

        propertyName = CSharp.Escape(propertyName);

        b.BeginBlock("public {0} {1}", p.Getter.PublicReturnType.PublicSymbol, propertyName);

        b.BeginBlock("get");
        p.Getter.Signature.EmitPublicCall(b, ApiClassName, p.Getter.CfxApiFunctionName);
        b.EndBlock();
        if (p.Setter != null)
        {
            b.BeginBlock("set", p.Getter.PublicReturnType.PublicSymbol);
            p.Setter.Signature.EmitPublicCall(b, ApiClassName, p.Setter.CfxApiFunctionName);
            b.EndBlock();
        }
        b.EndBlock();
    }
Exemplo n.º 30
0
    public void EmitPublicProperty(CodeBuilder b, CefCallbackType setter)
    {
        var propertyName = this.PublicName;

        if (Name.StartsWith("get_"))
        {
            propertyName = propertyName.Substring(3);
        }

        propertyName = CSharp.Escape(propertyName);

        b.BeginBlock("public {0} {1}", PublicReturnType.PublicSymbol, propertyName);

        b.BeginBlock("get");
        Signature.EmitPublicCall(b);
        b.EndBlock();
        if (setter != null)
        {
            b.BeginBlock("set", PublicReturnType.PublicSymbol);
            setter.Signature.EmitPublicCall(b);
            b.EndBlock();
        }
        b.EndBlock();
    }